In Linux, how does one view the developed port ?, View development ports 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:
[Html] view plain copy
Netstat-lntp
Command Parsing:
-L list all listening ports
-N: the address and port number are displayed in numbers. domain name resolution is not performed to speed up information display.
-P indicates the process that occupies the port number.
-T list TCP connections
-A lists all the current connections, tcp, udp, and all the connections of all sockets under the unix protocol.
-U: List udp connections
Example of whether to use domain name resolution for-n:
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.
[Html] view plain copy
Netstat-alt
Find the process of a specific port:
[Html] view plain copy
Netstat-phosphatase | grep 8010
View the user name or user id:
[Html] view plain copy
Netstat-altep
Lists the user IDs of tcp in the current process.
[Html] view plain copy
Netstat-altne
Here, if you use the-n and-e options together, the attribute of the User column is the User ID, not the User name. You can use the-ep option 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:
[Html] view plain copy
Netstat-ie
2. lsof command
Command Format: lsof-I: port_number
[Html] view plain copy
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.
[Html] view plain copy
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.