[linux]查看linux下端口占用:lsof -i

查看端口占用情况的命令:lsof -i

[root@www ~]# lsof -i

COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
nginx 2333 root 6u IPv4 6242 TCP *:http (LISTEN)
nginx 2334 www 6u IPv4 6242 TCP *:http (LISTEN)
sshd 2349 root 3u IPv6 6283 TCP *:ndmp (LISTEN)
sshd 2349 root 4u IPv6 6286 TCP *:ssh (LISTEN)

查看某一端口的占用情况:lsof -i:端口号

[root@www ~]# lsof -i:21

COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
pure-ftpd 2651 root 4u IPv4 7047 TCP *:ftp (LISTEN)
pure-ftpd 2651 root 5u IPv6 7048 TCP *:ftp (LISTEN)

结束占用端口的进程:kill -9 pid

[root@www ~]# kill -9 2651

你可能感兴趣的:([linux]查看linux下端口占用:lsof -i)