根据端口查进程号和根据进程号查进程名
根据端口查进程号
- ss -tnlp|grep 80
1
2
3
4LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=977,fd=6),("nginx",pid=976,fd=6),("nginx",pid=975,fd=6),("nginx",pid=974,fd=6),("nginx",pid=973,fd=6),("nginx",pid=972,fd=6),("nginx",pid=971,fd=6),("nginx",pid=970,fd=6))
LISTEN 0 4096 127.0.0.1:8088 0.0.0.0:*
LISTEN 0 511 [::]:80 [::]:* users:(("nginx",pid=977,fd=7),("nginx",pid=976,fd=7),("nginx",pid=975,fd=7),("nginx",pid=974,fd=7),("nginx",pid=973,fd=7),("nginx",pid=972,fd=7),("nginx",pid=971,fd=7),("nginx",pid=970,fd=7))
LISTEN 0 4096 *:8086 *:* - netstat -tnlp|grep 80
1
2
3
4tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 970/nginx: worker p
tcp 0 0 127.0.0.1:8088 0.0.0.0:* LISTEN -
tcp6 0 0 :::80 :::* LISTEN 970/nginx: worker p
tcp6 0 0 :::8086 :::* LISTEN - - lsof -i -P|grep 80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18nginx 970 tellw 6u IPv4 31007 0t0 TCP *:80 (LISTEN)
nginx 970 tellw 7u IPv6 31008 0t0 TCP *:80 (LISTEN)
nginx 971 tellw 6u IPv4 31007 0t0 TCP *:80 (LISTEN)
nginx 971 tellw 7u IPv6 31008 0t0 TCP *:80 (LISTEN)
nginx 972 tellw 6u IPv4 31007 0t0 TCP *:80 (LISTEN)
nginx 972 tellw 7u IPv6 31008 0t0 TCP *:80 (LISTEN)
nginx 973 tellw 6u IPv4 31007 0t0 TCP *:80 (LISTEN)
nginx 973 tellw 7u IPv6 31008 0t0 TCP *:80 (LISTEN)
nginx 974 tellw 6u IPv4 31007 0t0 TCP *:80 (LISTEN)
nginx 974 tellw 7u IPv6 31008 0t0 TCP *:80 (LISTEN)
nginx 975 tellw 6u IPv4 31007 0t0 TCP *:80 (LISTEN)
nginx 975 tellw 7u IPv6 31008 0t0 TCP *:80 (LISTEN)
nginx 976 tellw 6u IPv4 31007 0t0 TCP *:80 (LISTEN)
nginx 976 tellw 7u IPv6 31008 0t0 TCP *:80 (LISTEN)
nginx 977 tellw 6u IPv4 31007 0t0 TCP *:80 (LISTEN)
nginx 977 tellw 7u IPv6 31008 0t0 TCP *:80 (LISTEN)
kdeconnec 2637 tellw 20u IPv6 35280 0t0 UDP *:1716
transmiss 8984 tellw 23u IPv4 80630 0t0 UDP tellw-notebo:43972->_gateway:5351 - fuser -v 80/tcp
1
2
3
4
5
6
7
8
9用户 进程号 权限 命令
80/tcp: tellw 970 F.... nginx
tellw 971 F.... nginx
tellw 972 F.... nginx
tellw 973 F.... nginx
tellw 974 F.... nginx
tellw 975 F.... nginx
tellw 976 F.... nginx
tellw 977 F.... nginx根据进程号查进程名
- ps -p 970 -o comm=
1
nginx
- ps aux|grep 970
1
2
3tellw 970 0.0 0.0 55848 5764 ? S 21:06 0:00 nginx: worker process
root 9702 0.0 0.0 0 0 ? I 22:39 0:00 [kworker/u16:0-events_power_efficient]
tellw 10695 0.0 0.0 13364 2432 pts/0 S+ 23:00 0:00 grep --color=auto 970根据进程名查进程号
pidof nginx1
977 976 975 974 973 972 971 970 969
https://zhuanlan.zhihu.com/p/474922957 Linux运维必知:如何从其 PID 中查找进程名称
https://zhuanlan.zhihu.com/p/45920111 如何在 Linux 中查看进程占用的端口号
9.22.23.5