使用 netstat
$ sudo netstat -tulnp | grep ':22'
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 963/sshd: /usr/sbin
使用 lsof
$ sudo lsof -i :22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 963 root 3u IPv4 21816 0t0 TCP *:ssh (LISTEN)
sshd 292636 root 4u IPv4 3082489 0t0 TCP iZ7xvhevxjvf4dzop816ukZ:ssh->113.140.11.124:55978 (ESTABLISHED)
sshd 292692 xiao 4u IPv4 3082489 0t0 TCP iZ7xvhevxjvf4dzop816ukZ:ssh->113.140.11.124:55978 (ESTABLISHED)
sshd 292957 root 4u IPv4 3082136 0t0 TCP iZ7xvhevxjvf4dzop816ukZ:ssh->113.140.11.124:55979 (ESTABLISHED)
sshd 293033 xiao 4u IPv4 3082136 0t0 TCP iZ7xvhevxjvf4dzop816ukZ:ssh->113.140.11.124:55979 (ESTABLISHED)
使用 ss
$ sudo ss -tulnp | grep ':22'
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=963,fd=3))
$ sudo ss -nltp | grep ':22'
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=963,fd=3))
使用 fuser
$ sudo fuser 22/tcp
22/tcp: 963 292636 292692 292957 293033
标签:sshd,22,0.0,占用,sudo,端口,TCP,Linux,0t0
From: https://www.cnblogs.com/Undefined443/p/18049156