方法1:lsof -i :22或者lsof -i tcp:22 可以查詢到22端口對應的是sshd服務
[root@oldboylinux ~]# lsof -i tcp:22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 1464 root 3u IPv4 13497 0t0 TCP *:ssh (LISTEN)
sshd 1464 root 4u IPv6 13506 0t0 TCP *:ssh (LISTEN)
sshd 1650 root 3r IPv4 14658 0t0 TCP 192.168.1.110:ssh->192.168.1.103:51295 (ESTABLISHED)
[root@oldboylinux ~]# lsof -i :22
方法2:netstat -lntup|grep 22 指令可以查詢到22端口對應的是sshd服務
[root@oldboylinux ~]# netstat -lntup|grep 22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1464/sshd
tcp 0 0 :::22 :::* LISTEN 1464/sshd
本文轉自sandshell部落格51CTO部落格,原文連結http://blog.51cto.com/sandshell/1948354如需轉載請自行聯系原作者
sandshell