Linux如何查看端口

netstat -tunlp 

netstat -tunlp |grep 端口号,用于查看指定的端口号的进程情况,如查看80端口的情况,netstat -tunlp |grep 80


# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program nam
tcp        0      0 127.0.0.1:32000             0.0.0.0:*                   LISTEN      1474/java           
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      2134/php-fpm             
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      2065/mysqld         
tcp        0      0 127.0.0.1:11211             0.0.0.0:*                   LISTEN      2103/memcached                
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      2123/nginx          
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      2145/pure-ftpd (SER 
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1490/sshd           
udp        0      0 127.0.0.1:11211             0.0.0.0:*                               2103/memcached      
udp        0      0 172.17.177.27:123           0.0.0.0:*                               1501/ntpd           
udp        0      0 127.0.0.1:123               0.0.0.0:*                               1501/ntpd           
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               1501/ntpd

# netstat -tunlp | grep 80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      2123/nginx


 -t (tcp) 仅显示tcp相关选项
 -u (udp)仅显示udp相关选项
 -n 拒绝显示别名,能显示数字的全部转化为数字
 -l 仅列出在Listen(监听)的服务状态
 -p 显示建立相关链接的程序名