Monday, November 15, 2021

[SOLVED] Find the port number of a specific process by using the PID

Issue

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

enter image description here

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

sudo netstat -anpe | grep ${#PID}

Solution

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

192.168.43.6:42010   198.252.206.25:443


Answered By - MonsieurMemons