Mutual query of Linux port number and PID
Recently used Linux to play Tomcat, boot time will always error (8080/8009/8005)
So tidy up the Internet messy view PID and port commands, in case of record.
1. Query the PID number by port number
First MyEclipse the error when you will be prompted: "8009 Port is occupied", then you have to rely on this port to see which processes running under the port
Use the command to view all port conditions running under the current system:sudo netstat-antup
Note: Please check the permissions under Sudo, otherwise some of the PID is not viewable, I used to use root permission to bypass a lot .
2. Use PID to query port number
If you are aware of the process PID, how can you see the process of the PID?
Use the command:sudo netstat-antup|grep pid number to inquire about the opening of the target port! Of course, if you want to know the PID number:
is to use the PID to view the port 1024来, we can see that the port is in the state of listen listening, and the port is 80.
3. Use the process name to query the PID number
Sometimes we are familiar with some common processes, then we can use the PS command to query the target PID number:
Using the command:sudo ps-ef|grep The process name to view the PID of the process is very convenient. But the premise is that you need to know the name of the process, such as if some system background process can not be seen.
This command is used to view: The MySQL database pid is 2807, and it has already told us the port number is: 3306.
From for notes (Wiz)
"Linux port number and PID mutual query"