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.
Asked
Active
Viewed 315 times
1 Answers
0
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
...
...

grub
- 1,118
- 1
- 7
- 12