
Linux: Showing Open Ports and the Processes that Own Them
How do you list the open TCP and UDP ports on your server and the processes that own them? The answer is to use either the netstat or the lsof command:
netstat
$ sudo netstat -lptu Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 *:ftp *:* LISTEN 3825/vsftpd tcp 0 0 *:ssh *:* LISTEN 3539/sshd tcp 0 0 localhost:6600 *:* LISTEN 3922/mpd tcp 0 0 localhost:mysql *:* LISTEN 30004/mysqld tcp 0 0 *:svn *:* LISTEN 3810/svnserve tcp6 0 0 [::]:ssh [::]:* LISTEN 3539/sshd tcp6 0 0 [::]:microsoft-ds [::]:* LISTEN 3805/smbd tcp6 0 0 localhost:6600 [::]:* LISTEN 3922/mpd tcp6 0 0 [::]:netbios-ssn [::]:* LISTEN 3805/smbd tcp6 0 0 [::]:www
…