简体   繁体   中英

Find the port number of a specific process by using the PID

I am a newbee in this. I am using Netstat to find the port number of a specific PID. I have used the following comman to find the PIDs of all the process. My goal is to search for the port number only by using the PID of a process.I am using Linux, certain options like find , findstr is not working, so I tried the Following commands. Kindly give some suggestion. Thanks in advance

netstat -anop

在此处输入图像描述

To show the port number I have used the following code by PID

sudo netstat -anpe | grep ${#PID}

The port number is shown after the local or foreign address, is the number followed by the semicolumn, ie :

192.168.43.6:42010   198.252.206.25:443

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM