netstat
获得要查看的进程的pid
ps aux|grep process_name
命令
netstat -p program_pid
举栗子
[root@localhost ~]
root 11940 0.0 0.0 46212 1160 ? Ss 13:02 0:00 nginx: master process /usr/local/nginx/sbin/nginx
wp 11941 0.0 0.1 46672 1920 ? S 13:02 0:00 nginx: worker process
root 12066 0.0 0.0 112824 980 pts/0 S+ 13:27 0:00 grep --color=auto nginx
[root@localhost ~]
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 36 localhost.localdoma:ssh 192.168.186.1:7433 ESTABLISHED 8707/sshd: root@pts
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ] DGRAM 17663 709/chronyd /var/run/chrony/chronyd.sock
unix 2 [ ] DGRAM 13599 1/systemd /run/systemd/shutdownd
unix 3 [ ] DGRAM 441 1/systemd /run/systemd/notify
unix 2 [ ] DGRAM 443 1/systemd /run/systemd/cgroups-agent
unix 5 [ ] DGRAM 457 1/systemd /run/systemd/journal/socket
unix 15 [ ] DGRAM 459 1/systemd /dev/log
unix 3 [ ] STREAM CONNECTED 21433 1459/master
unix 3 [ ] STREAM CONNECTED 21485 1459/master
unix 3 [ ] STREAM CONNECTED 21470 1459/master
unix 2 [ ] DGRAM 19471 706/dbus-daemon
unix 3 [ ] STREAM CONNECTED 17844 726/systemd-logind
unix 3 [ ] STREAM CONNECTED 14948 1/systemd /run/systemd/journal/stdout
unix 2 [ ] DGRAM 22266 1520/qmgr
unix 2 [ ] DGRAM 17682 702/VGAuthService
unix 3 [ ] STREAM CONNECTED 21453 1459/master
unix 3 [ ] STREAM CONNECTED 21498 1459/master
unix 3 [ ] STREAM CONNECTED 14848 1/systemd /run/systemd/journal/stdout
unix 3 [ ] STREAM CONNECTED 21477 1459/master
unix 3 [ ] STREAM CONNECTED 21462 1459/master
unix 3 [ ] STREAM CONNECTED 18552 706/dbus-daemon
unix 3 [ ] STREAM CONNECTED 18781 1/systemd /run/systemd/journal/stdout
unix 3 [ ] STREAM CONNECTED 21494 1459/master
unix 3 [ ] STREAM CONNECTED 21449 1459/master
unix 3 [ ] STREAM CONNECTED 18820 706/dbus-daemon /run/dbus/system_bus_socket
lsof
1. lsof -c process_name
命令
lsof -c process_name
举栗子
[root@localhost ~]
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 11940 root cwd DIR 253,0 151 12971 /usr/local/nginx
nginx 11940 root rtd DIR 253,0 237 64 /
nginx 11940 root txt REG 253,0 7688160 17030071 /usr/local/nginx/sbin/nginx
nginx 11940 root mem REG 253,0 61560 36534 /usr/lib64/libnss_files-2.17.so
nginx 11940 root mem REG 253,0 155744 59473 /usr/lib64/libselinux