netstat
This command is commonly used in network monitoring. Using this command, you can view the services currently monitored by the system and the services that have been established, as well as the corresponding ports, protocols and other information.
netstat
Although there are many parameters, not many are commonly used, mainly the following parameters:
netstat -[atunlp]
Recommended related video tutorials: linux video tutorial
-a: all, means to list all connections, service monitoring, Socket information
-t: tcp, list the services of tcp protocol
-u: udp, list the services of the udp protocol
-n: port number, use the port number to display
-l: listening, list the current listening service
-p: program, list the PID of the service program
For example:
Check whether the port number 19090 is occupied, as follows:
netstat -tunlp |grep 19090
The result shows:
tcp 0 0 0.0.0.0:19090 0.0.0.0:* LISTEN 26596/java
Related Recommended article tutorials: linux 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!