ArticleDirectory
- 1. List all TCP ports (including listeners and ports not listened)
- 2. List all TCP ports in the listener status
- 3. display the statistics of all ports
- 4. display the PID of the Process occupying a specific TCP port
Preface to learn a command in Linux, run the netstat command to display network-related information, such as network connection, route table, interface status (interface statistics), and masquerade connection, multicast members (multicase memberships. Netstat information: the output result of netstat is as follows:
- One is to activate an Internet connection, called an active TCP connection. "Recv-Q" and "send-Q" indicate the receiving queue and the sending queue. These numbers are generally 0. If not, the package is accumulating in the queue. This can only be seen in rare cases.
- The other is an active Unix domain socket called an active Unix domain socket interface (same as a network socket, but only used for local communication, and the performance can be doubled ). PROTO: displays the protocol used for the connection. refcnt: indicates the process number connecting to the current set of interfaces. types: displays the current status of the set of interfaces. Path: the path name used by other processes connected to the set interface.
Common parameters-A (all) show all options. Listen is not displayed by default.
-T (TCP) only displays TCP-related options
-U (UDP) only displays UDP-related options
-N: aliases are not displayed. All digits can be converted to digits.
-L only lists the service statuses that have been listened to by listen.
-P: displaysProgramName
-R: displays route information and route tables.
-E: Display extension information, such as uid.
-S: statistics by Protocol
-C runs the netstat command at every fixed time.
Tip: The listen and listening statuses can only be viewed using-A or-L.
Common commands 1. list all TCP ports (including listening and not listening) 2. list all TCP ports in the listener status. 3. display the statistics of all ports 4. the PID netstat-P of the process that occupies a specific TCP port can be used with other switches to add the "PID/process name" to the netstat output, this is suitable for troubleshooting can easily find specific port running programs reference connection http://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316661.html