netstat命令一般比较难用,往往摸索很久才能获取到你要的信息。但是下面这个命令,绝对让你看得一目了然:
netstat -atunlp
看看吧,一看就明白了:
[root@localhost ~]# netstat -atunlp
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:3306 0.0.0.0:* LISTEN 2182/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1972/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1869/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2283/master
tcp 0 48 10.0.66.232:22 10.0.66.229:2532 ESTABLISHED 2579/sshd
tcp 0 0 :::22 :::* LISTEN 1972/sshd
tcp 0 0 ::1:631 :::* LISTEN 1869/cupsd
tcp 0 0 ::1:25 :::* LISTEN 2283/master
udp 0 0 0.0.0.0:57044 0.0.0.0:* 1819/avahi-daemon
udp 0 0 0.0.0.0:5353 0.0.0.0:* 1819/avahi-daemon
udp 0 0 0.0.0.0:631 0.0.0.0:* 1869/cupsd