Home > Article > Operation and Maintenance > How to check port status in linux
#Linux uses the netstat command to view port status.
The parameters of the netstat command are described as follows:
-a: List all network status, including Socket programs;
-c seconds Number: Specify how many seconds to refresh the network status;
-n: Use IP address and port number to display, do not use domain name and service name;
-p: Display PID and program name ;
-t: Display the connection status of the TCP protocol port;
-u: Display the connection status of the UDP protocol port;
-I: Display only the listening status Connection;
-r: Display routing table;
The netstat command can be combined with grep to view a specific port and service status.
netstat -ntlp //查看当前所有tcp端口 netstat -ntulp |grep 80 //查看所有80端口使用情况 netstat -anp | grep 3306 //查看所有3306端口使用情况
Check which services and ports are on a server
netstat -lanp
Check how many ports a service has. For example, you want to check mysqld
ps -ef |grep mysqld
to check the number of connections on a certain port. For example, 3306 port
netstat -pnt |grep :3306 |wc
checks the connection client IP of a certain port. For example, port 3306
netstat -anp |grep 3306
View network port
netstat -an
Recommended tutorial: linux tutorial
The above is the detailed content of How to check port status in linux. For more information, please follow other related articles on the PHP Chinese website!