zhangzhen0 2018-07-16
方法1、lsof -i:端口号
y@ubuntu:~$ sudo lsof -i:19011
COMMAND PID USERFDTYPE DEVICE SIZE/OFF NODE NAME
docker-pr 5653 root 4u IPv6 731610t0 TCP *:19011 (LISTEN)
方法2、netstat -tunlp|grep 端口号
y@ubuntu:~$ netstat -tunlp|grep 19011
(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)
tcp6 00 :::19011 :::* LISTEN-
y@ubuntu:~$ sudo netstat -tunlp|grep 19011
tcp6 00 :::19011 :::* LISTEN5653/docker-proxy
注意,上述命令,不属于该用户的进程是不会显示的,所以可以切到root用户查看是被root用户的进程占用了指定端口