linux怎么查看指定的进程

发布网友 发布时间:2022-04-19 12:04

我来回答

3个回答

热心网友 时间:2022-05-03 05:14

比如要查看nginx主进程,lsof -p pid
root@localhost:~/xly# ps aux|grep nginx
root 5847 0.0 0.0 92428 1728 ? Ss 12月07 0:00 nginx: master process /usr/sbin/nginx
root 5848 0.0 0.0 93020 3036 ? S 12月07 0:49 nginx: worker process
root 5849 0.0 0.0 93020 3036 ? S 12月07 0:51 nginx: worker process
root 5851 0.0 0.0 93020 3032 ? S 12月07 0:46 nginx: worker process
root 5852 0.0 0.0 93020 3036 ? S 12月07 0:48 nginx: worker process
root 16635 0.0 0.0 13424 948 pts/5 S+ 16:41 0:00 grep nginx
root@localhost:~/xly# lsof -p 5847
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 5847 root cwd DIR 8,3 4096 2 /
nginx 5847 root rtd DIR 8,3 4096 2 /
nginx 5847 root txt REG 8,3 873176 95168767 /usr/sbin/nginx
nginx 5847 root mem REG 8,3 101240 7081726 /lib/x86_64-linux-gnu/libresolv-2.19.so
nginx 5847 root mem REG 8,3 22952 7081730 /lib/x86_64-linux-gnu/libnss_dns-2.19.so
nginx 5847 root mem REG 8,3 10432 7078112 /lib/x86_64-linux-gnu/libnss_mdns4_minimal.so.2
nginx 5847 root mem REG 8,3 47712 7081728 /lib/x86_64-linux-gnu/libnss_files-2.19.so
nginx 5847 root mem REG 8,3 47760 7081748 /lib/x86_64-linux-gnu/libnss_nis-2.19.so
nginx 5847 root mem REG 8,3 97296 7081737 /lib/x86_64-linux-gnu/libnsl-2.19.so
nginx 5847 root mem REG 8,3 39824 7081736 /lib/x86_64-linux-gnu/libnss_compat-2.19.so
nginx 5847 root mem REG 8,3 22616 95164316 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
nginx 5847 root mem REG 8,3 14456 95164314 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
nginx 5847 root mem REG 8,3 125392 95164318 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
nginx 5847 root mem REG 8,3 58120 95160898 /usr/lib/x86_64-linux-gnu/libjbig.so.0
nginx 5847 root mem REG 8,3 1265072 95164321 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
nginx 5847 root mem REG 8,3 170064 7078077 /lib/x86_64-linux-gnu/libexpat.so.1.6.0
nginx 5847 root mem REG 8,3 18416 7078084 /lib/x86_64-linux-gnu/libgpg-error.so.0.10.0
nginx 5847 root mem REG 8,3 467208 95160899 /usr/lib/x86_64-linux-gnu/libtiff.so.5.2.0
nginx 5847 root mem REG 8,3 1677008 95165486 /usr/lib/x86_64-linux-gnu/libvpx.so.1.3.0
nginx 5847 root mem REG 8,3 72776 95165705 /usr/lib/x86_64-linux-gnu/libXpm.so.4.11.0
nginx 5847 root mem REG 8,3 244704 95160956 /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.8.0
nginx 5847 root mem REG 8,3 666080 95164383 /usr/lib/x86_64-linux-gnu/libfreetype.so.6.11.1
nginx 5847 root mem REG 8,3 153936 7078141 /lib/x86_64-linux-gnu/libpng12.so.0.50.0
nginx 5847 root mem REG 8,3 281288 95160885 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
nginx 5847 root mem REG 8,3 520608 7078082 /lib/x86_64-linux-gnu/libgcrypt.so.11.8.2
nginx 5847 root mem REG 8,3 1071552 7081727 /lib/x86_64-linux-gnu/libm-2.19.so
nginx 5847 root mem REG 8,3 137400 7078093 /lib/x86_64-linux-gnu/liblzma.so.5.0.0
nginx 5847 root mem REG 8,3 14664 7081731 /lib/x86_64-linux-gnu/libdl-2.19.so
nginx 5847 root mem REG 8,3 1840928 7081742 /lib/x86_64-linux-gnu/libc-2.19.so
nginx 5847 root mem REG 8,3 190648 95164297 /usr/lib/x86_64-linux-gnu/libGeoIP.so.1.6.0
nginx 5847 root mem REG 8,3 417992 95165855 /usr/lib/x86_64-linux-gnu/libgd.so.3.0.0
nginx 5847 root mem REG 8,3 83816 95165297 /usr/lib/x86_64-linux-gnu/libexslt.so.0.8.17
nginx 5847 root mem REG 8,3 247952 95165296 /usr/lib/x86_64-linux-gnu/libxslt.so.1.1.28
nginx 5847 root mem REG 8,3 1461496 95164257 /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.1
nginx 5847 root mem REG 8,3 100728 7078174 /lib/x86_64-linux-gnu/libz.so.1.2.8
nginx 5847 root mem REG 8,3 1930528 7078094 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
nginx 5847 root mem REG 8,3 383112 7078072 /lib/x86_64-linux-gnu/libssl.so.1.0.0
nginx 5847 root mem REG 8,3 252032 7078131 /lib/x86_64-linux-gnu/libpcre.so.3.13.1
nginx 5847 root mem REG 8,3 43368 7081734 /lib/x86_64-linux-gnu/libcrypt-2.19.so
nginx 5847 root mem REG 8,3 141574 7081743 /lib/x86_64-linux-gnu/libpthread-2.19.so
nginx 5847 root mem REG 8,3 149120 7081739 /lib/x86_64-linux-gnu/ld-2.19.so
nginx 5847 root DEL REG 0,4 321504351 /dev/zero
nginx 5847 root 0u CHR 1,3 0t0 1029 /dev/null
nginx 5847 root 1u CHR 1,3 0t0 1029 /dev/null
nginx 5847 root 2w REG 8,3 1406668 103297074 /var/log/nginx/error.log
nginx 5847 root 3u unix 0xffff880109b2ad80 0t0 321502773 socket
nginx 5847 root 4w REG 8,3 1406668 103297074 /var/log/nginx/error.log
nginx 5847 root 6u IPv4 321504347 0t0 TCP *:8090 (LISTEN)
nginx 5847 root 7u IPv4 321504348 0t0 TCP *:http (LISTEN)
nginx 5847 root 8u IPv6 321504349 0t0 TCP *:http (LISTEN)
nginx 5847 root 9u IPv4 321504350 0t0 TCP *:843 (LISTEN)
nginx 5847 root 10u unix 0xffff880109b29f80 0t0 321502774 socket
nginx 5847 root 11u unix 0xffff880109b29180 0t0 321502775 socket
nginx 5847 root 12u unix 0xffff880109b29880 0t0 321502776 socket
nginx 5847 root 13u unix 0xffff880109b2bb80 0t0 321502777 socket
nginx 5847 root 14u unix 0xffff880109b2a680 0t0 321502778 socket
nginx 5847 root 15u unix 0xffff880109b29c00 0t0 321502779 socket
nginx 5847 root 16u unix 0xffff880109b28380 0t0 321502780 socket
nginx 5847 root 17w REG 8,3 32341307 103296811 /var/log/nginx/access.log

热心网友 时间:2022-05-03 06:32

比如进程名叫aaa,可以执行如下命令:ps -ef|grep aaa,
如果有内容说明活着如果你知道进程占用的端口号,比如7777,可以执行:netstat -anp | grep 7777,检查有没有程序占用该端口,若有的话,看pid或pname是否是你想要找的
如果想要找的是某个服务,比如nfs、smb等,可以用service nfs status查看
关于更多Linux的学习,请查阅书籍《linux就该这么学》。

热心网友 时间:2022-05-03 08:07

ps -ef|grep xxxx
声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com