Home  >  Article  >  Operation and Maintenance  >  What is the command to check the port status?

What is the command to check the port status?

王林
王林Original
2020-07-04 13:48:0640491browse

The command to view the port status is "netstat", and its syntax is "netstat -ntlp". The netstat command is generally used to check the network connection of each port of the machine. Netstat is used to access the network and related information in the kernel. A program that provides TCP connection, TCP and UDP listening and other related reports.

What is the command to check the port status?

#The command to check the port status in Linux system is netstat.

(Recommended learning: linux tutorial)

The netstat command is used to display statistical data related to IP, TCP, UDP and ICMP protocols, and is generally used to test the machine Network connection status of each port.

netstat is a program that accesses network and related information in the kernel. It can provide relevant reports on TCP connections, TCP and UDP monitoring, and process memory management.

The parameters of the netstat command are described as follows:

  • -t: Specifies to display the TCP port

  • -u: Specifies to display the UDP Port

  • -l : Show only listening sockets

  • -p : Show process identifier and program name for each socket /Ports all belong to one program

  • -n: No DNS polling is performed, and the IP is displayed

This command can be combined with the grep command to view A specific port and service situation:

Example:

netstat -ntlp   //查看当前所有tcp端口
netstat -ntulp |grep 80   //查看所有80端口使用情况
netstat -an | grep 3306   //查看所有3306端口使用情况
查看一台服务器上面哪些服务及端口
netstat  -lanp
查看一个服务有几个端口。比如要查看mysqld
ps -ef |grep mysqld
查看某一端口的连接数量,比如3306端口
netstat -pnt |grep :3306 |wc

The above is the detailed content of What is the command to check the port status?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn