5、pgrep 查找进程PID

1、pgrep 命令

根据用户给出的信息在当前运行进程中查找并列出符合条件的进程ID(PID)。

语法:

pgrep (选项) 进程名称

选项:

-l, --list-name       同时列出进程名和PID
-i, --ignore-case     忽略大小写
-f, --full            匹配完整命令行(而不只是进程名)
-u, --euid            匹配有效用户ID或用户名
-x, --exact           精确匹配整个进程名
-n, --newest          仅显示找到的最大(结束)进程号;
-o, --oldest          仅显示找到的最小(起始)进程号;
-c, --count           只显示匹配的进程数量
-P 指定父进程号;
-g 指定进程组;
-t 指定开启进程的终端;

例子:

[root@localhost ~]# pgrep -l more
2493 more
[root@localhost ~]# pgrep -l ls
770 alsactl
789 vmtoolsd
796 lsmd
1945 pulseaudio

 

posted @ 2025-11-17 14:41  chao_xiong  阅读(4)  评论(0)    收藏  举报