LINUX Checks whether the port is occupied

LINUX Checks whether the port is occupied

I have never been able to figure out whether the port is occupied. After asking many people, I finally figured it out. Now let me summarize:

1.netstat -anp |grep port number

As follows, I take 3306 as an example, netstat -anp |grep 3306 (note here, I am operating as a normal user, so I added sudo. If you are operating as a root user, you can view it without adding sudo), as shown in Figure 1:

Figure 1

In Figure 1, the monitoring status is LISTEN, which means it is occupied. The last column shows that it is occupied by the service mysqld. Check the specific port number. As long as there is a line like the one in the figure, it means it is occupied.

2.netstat -nultp (no need to add port number here)

This command is used to view all currently used ports, as shown in Figure 2:

Figure 2

As you can see from the picture, my port 82 is not occupied.

3.netstat -anp |grep 82 to check the usage of port 82, as shown in Figure 3:

Figure 3

It can be seen that there is no LISTEN line, so it means that it is not occupied. Note that the LISTENING in the figure does not mean that the port is occupied. Do not confuse it with LISTEN. When checking the specific port, you must see the line of tcp, port number, and LISTEN to indicate that the port is occupied.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to release port occupation in Linux
  • Detailed example of Linux command to check port usage
  • Python writes a small program to detect Linux port usage

<<:  JavaScript style object and CurrentStyle object case study

>>:  Detailed tutorial on deploying Django project using Docker on centos8

Recommend

About the correct way to convert time in js when importing excel

Table of contents 1. Basics 2. Problem Descriptio...

MySQL intercepts the sql statement of the string function

1. left(name,4) intercepts the 4 characters on th...

Explanation of the precautions for Mysql master-slave replication

1. Error error connecting to master 'x@xxxx:x...

How to solve the problem of character set when logging in to Linux

Character set error always exists locale: Cannot ...

SQL Server database error 5123 solution

Because I have a database tutorial based on SQL S...

The basic principles and detailed usage of viewport

1. Overview of viewport Mobile browsers usually r...

JavaScript to switch multiple pictures

This article shares the specific code of JavaScri...

How to stop CSS animation midway and maintain the posture

Preface I once encountered a difficult problem. I...

How to use nginx to block a specified interface (URL)

1. Introduction Sometimes, after the web platform...

Comprehensive understanding of HTML basic structure

Introduction to HTML HyperText Markup Language: H...

How to use union all in MySQL to get the union sort

Sometimes in a project, due to some irreversible ...

How to enter and exit the Docker container

1 Start the Docker service First you need to know...

Vue implements an Input component that gets the key display shortcut key effect

I encountered a requirement to customize shortcut...

Comprehensive understanding of Node event loop

Table of contents Node Event Loop Event loop diag...

CSS style reset and clear (to make different browsers display the same effect)

In order to make the page display consistent betwe...