Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am looking for the cleanest way on linux to find the port status for a port being used by a specified program name via the command line. I have seen that netstat -p lists all pids but haven't seen anything corresponding to specific process names. Any help would be appreciated.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Theoretically you should see the program name with the paramter -p and the PID. Be aware that you need root rights to display the program name of processes which arent running under your user.

-p without root permissions:

$ netstat -lnp
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      -               
...
...

-p with root permissions

$ sudo netstat -lnp
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1553/apache2    
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      1392/vsftpd     
...
...
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.