linux查看端口占用

方式一:

[root@localhost /]# lsof -i:22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 1219 root 3u IPv4 23508 0t0 TCP *:ssh (LISTEN)
sshd 1219 root 4u IPv6 23519 0t0 TCP *:ssh (LISTEN)

方式二:

[root@localhost /]# netstat -tunlp | grep 22
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1961/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1219/sshd
tcp6 0 0 :::22 :::* LISTEN 1219/sshd
udp 0 0 192.168.122.1:53 0.0.0.0:* 1961/dnsmasq

参数:

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

 

方式三:

[root@localhost /]# ss -lntpd | grep 22
tcp LISTEN 0 5 192.168.122.1:53 *:* users:(("dnsmasq",pid=1961,fd=6))
tcp LISTEN 0 128 *:22 *:* users:(("sshd",pid=1219,fd=3))
tcp LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=1219,fd=4))

 

posted @ 2020-07-03 00:12  初雨诗清风  阅读(513)  评论(0编辑  收藏  举报