Home >Operation and Maintenance >Linux Operation and Maintenance >How to check whether a port is occupied in Linux
In Linux, you can use the netstat command to check whether the port is occupied. Method: 1. Log in to the system, right-click on a blank space on the desktop, and select "Open Terminal"; 2. In the terminal, execute the "netstat -anp | grep port number" command to view the output results. If "LISTEN" appears after the port, then Occupied.
The operating environment of this tutorial: CentOS 7 system, Dell G3 computer.
In Linux, you can use the netstat command to check whether the port is occupied.
Linux netstat command is used to display network status.
Using the netstat command allows you to know the network status of the entire Linux system.
Specific method:
1. Log in to the system, right-click on a blank space on the desktop and select "Open Terminal"
2. Terminal execution command: netstat -anp |grep port number
Take port 3306
as an example, execute the following command
netstat -anp |grep 3306
The usage of port 3306
will be displayed. When LISTEN
appears behind the port, it means the port is occupied.
Extended knowledge:
If you want to view all currently used ports, you can use the following command:
netstat -nultp
It can be seen from the picture that port 82 is not occupied.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to check whether a port is occupied in Linux. For more information, please follow other related articles on the PHP Chinese website!