I want to use netstat -anp to check which program/process is listening a specific port. But the output includes lots of lines in which the value of 'PID/Program Name' column is just a -. For example
Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:902 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:5802 0.0.0.0:* LISTEN 3641/Xvnc tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN 3641/Xvnc I can see 5802 and 5902 is listened by Xvnc, but what for 902, 5801, 139 and 5901? Thanks.
1 Answer
It means that you do not have the appropriate privileges to determine the PID/program. Rerun netstat as the superuser, e.g. sudo netstat -anp.