指令
sudo lsof -i :端口号
案例一
% sudo lsof -i :80
Password:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 314 root 4u IPv6 0xfd2222a5a53fcf99 0t0 TCP *:http (LISTEN)
BaiduNetd 569 jiqing 95u IPv4 0xfd2222a5abe39b81 0t0 TCP 192.168.2.28:51132->220.181.43.8:http (ESTABLISHED)
WeChat 571 jiqing 45u IPv6 0xfd2222a5a53fdc59 0t0 TCP 192.168.2.28:50849->101.91.37.36:http (ESTABLISHED)
httpd 950 _www 4u IPv6 0xfd2222a5a53fcf99 0t0 TCP *:http (LISTEN)
httpd 1509 _www 4u IPv6 0xfd2222a5a53fcf99 0t0 TCP *:http (LISTEN)
httpd 1510 _www 4u IPv6 0xfd2222a5a53fcf99 0t0 TCP *:http (LISTEN)
httpd 1511 _www 4u IPv6 0xfd2222a5a53fcf99 0t0 TCP *:http (LISTEN)
案例二
sudo lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 1775 root 6u IPv4 0xfd2222a5abd8b361 0t0 TCP *:http-alt (LISTEN)
nginx 1776 nobody 6u IPv4 0xfd2222a5abd8b361 0t0 TCP *:http-alt (LISTEN)
httpd是apache进程,nginx是nginx进程。
80端口被apache使用了,8080端口被nginx使用。