环境
过程
- 查看端口号
netstat -tnl
- 这里测试8080端口
$ sudo lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 1139 root 13u IPv4 44778 0t0 TCP localhost:45648->localhost:http-alt (ESTABLISHED)
java 4841 root 55u IPv6 45438 0t0 TCP *:http-alt (LISTEN)
$ sudo lsof -i :139
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
smbd 2653 root 33u IPv6 31000 0t0 TCP *:netbios-ssn (LISTEN)
smbd 2653 root 35u IPv4 31002 0t0 TCP *:netbios-ssn (LISTEN)
$ ps -aux | grep 1139
$ ps -aux | grep nginx
root 1137 0.0 0.0 8392 900 ? Ss 10:14 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
root 1138 0.0 0.5 51604 45568 ? S 10:14 0:00 nginx: worker process
root 1139 0.0 0.5 51604 45568 ? S 10:14 0:00 nginx: worker process
root 1140 0.0 0.5 51604 45568 ? S 10:14 0:00 nginx: worker process
root 1141 0.0 0.5 51604 45568 ? S 10:14 0:00 nginx: worker process
uos 5098 0.0 0.0 9292 892 pts/0 S+ 10:43 0:00 grep nginx
参考
manpage
lsof