How to view the developed port in Linux
Introduction: on Linux servers, it is often necessary to check whether certain ports of the system are enabled normally, or to know which processes occupy specific port services. Therefore, this command is very common, this article describes common methods for these commands.
1. check whether a specific port is enabled or occupied
List all tcp connections in the listener status:
netstat -lntp
Vc/examples + CjxwPiAgLXAgIM/examples + examples/bL + samples + dPQzNe909fWtcTL + examples + ICAtdSAgIMHQs/examples + examples/examples =" http://www.2cto.com/uploadfile/Collfiles/20150424/201504241007254.png "alt =" \ ">
From the content display in, we can see that-n can control whether it is displayed as a domain name.
Lists All tcp ports in the listener status.
netstat -alt
Find the process of a specific port:
netstat -alp | grep 8010
View the user name or user id:
netstat -altep
Lists the user IDs of tcp in the current process.
netstat -altne
Here, assume that you
-NAnd
-EThe attribute of the User column is the User ID, not the User name. Use
-EpOption to view both the process name and User Name
-S: list the statistical network information:
-R: List route information
-I prints the network interface information, and-e works with it to output more friendly information.
Output Network Interface Information:
netstat -ie
2. lsof command
Command Format: lsof-I: port_number
lsof -i :8010
3. How to find help information
In linux, a powerful command man is provided to help us find the most comprehensive introduction information.
man netstat
4. Summary
Netstat is a very powerful command that provides the vast majority of required information. lsof is also a very useful tool, but in specific circumstances, lsof may not be able to find out, however, netstat can be queried.
We recommend that you use nestat to query ports first.