[Switch] 10 basic netstat usage and netstat10 usage
5. Obtain the process name, process number, and user ID.
When viewing the port and connection information, you can view the corresponding process name and process number, which is very helpful for the system administrator. For example, if you want to check whether the http service is started or whether the http service is started by Apache or nginx, you can check the process name.
Use-PView process information.
Use-POption, netstat must run under the root permission, otherwise it will not be able to get the process name running under the root permission, and many services, including http and ftp, are running under the root permission.
Compared with the process name and process number, viewing the process owner is more useful. Use-EpYou can view both the process name and user name.
The above lists the listening sockets under the TCP protocol, and displays the process information and some additional information at the same time.
The additional information includes the user name and the index node number of the process. This command is useful for network administrators.
Note:-Assume that you-NAnd-EThe attribute of the User column is the User ID, not the User name.
About Netstat
Netstat is a command line tool used to list all network socket connections on the system, including tcp, udp, and unix sockets, in addition, it can also list sockets in the listening status (that is, waiting for access requests. If you want to check whether the Web service on the system is enabled, you can check whether port 80 is enabled. The above functions make netstat an essential tool for network management and system administrators. In this tutorial, I will list several examples to show you how to use netstat to find network connection information and the port number enabled by the system.
1. List all connections
First, we will introduce the simplest command: to list all the current connections. Use the-a option.
The preceding command lists all connections of all sockets under tcp, udp, and unix protocols. However, this information is not detailed enough. administrators often need to check the connection status of a specific protocol or port.
From: http://www.binarytides.com/linux-netstat-command-examples/
Original: LCTT https://linux.cn/article-2434-1.html Translator: bazz2
Address: https://linux.cn/article-2434-1.html