查看linux中某个端口(port)是否被占用(netstat,lsof)

2016年11月16日 | 0 条评论 | 2978

netstat -tunlp 会显示所有端口和所有对应的程序,用grep管道可以过滤出想要的关键字段.
列一下22端口占用的程序

[root@leiwan tmp]# netstat -tunlp |grep 22
tcp        0      0 0.0.0.0:42957               0.0.0.0:*                   LISTEN      2230/rpc.statd      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2443/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      2292/cupsd          
tcp        0      0 :::22                       :::*                        LISTEN      2443/sshd           
tcp        0      0 ::1:631                     :::*                        LISTEN      2292/cupsd          
tcp        0      0 :::57609                    :::*                        LISTEN      2230/rpc.statd      
udp        0      0 0.0.0.0:5353                0.0.0.0:*                               2211/avahi-daemon   
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               2292/cupsd          
udp        0      0 0.0.0.0:37167               0.0.0.0:*                               2230/rpc.statd      
udp        0      0 0.0.0.0:52291               0.0.0.0:*                               2211/avahi-daemon   
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               2207/dhclient       
udp        0      0 0.0.0.0:710                 0.0.0.0:*                               2230/rpc.statd      
udp        0      0 :::39834                    :::*                                    2230/rpc.statd


技术咨询
换一个