方法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
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)
方法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