Alessandro_Kuramoto

How to find out which process is listening upon a port in Linux

Blog Post created by Alessandro_Kuramoto Employee on Apr 5, 2018

You can use lsof -i :port command:

 

Example:

 

An example of HTTP:
lsof -i :80

 

Example of output:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
apache2 10437 root 3u IPv6 22890556 TCP *:www (LISTEN)
apache2 10438 www-data 3u IPv6 22890556 TCP *:www (LISTEN)

 

 

Using ps and netstat:

 

To show the process name, PID, and other details:
ps aux | grep <process name>

 

To show the IP, port, PID, and other details:
netstat -an | grep LISTEN | grep -v unix

Outcomes