Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find ports opened by process ID in Linux?

Suppose the PID of the process is already known

like image 501
omg Avatar asked Jun 03 '09 02:06

omg


People also ask

What is PID netstat?

The State column specifies the connection's state when the Netstat command executed. The PID column shows the process identifier (PID) associated with the TCP connection. The PID is the information you're. after, but few people can identify a process by its PID.


2 Answers

You can use the command below:

lsof -i -P |grep pid 
like image 43
Waveter Avatar answered Sep 21 '22 00:09

Waveter


netstat --all --program | grep '3265' 
  • --all show listening and non-listening sockets.
  • --program show the PID and name of the program to which socket belongs.

You could also use a port scanner such as Nmap.

like image 70
Jorge Zuanon Avatar answered Sep 20 '22 00:09

Jorge Zuanon