"Linux port number and PID Mutual query"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.