Which language do you prefer? English 简体中文 繁体中文

Part of Linux Commands Cheat Sheet

Search processes by command

pgrep nginx

# -x for exactly match
pgrep -x nginx

Sample output:


Display command

pgrep -l nginx
pgrep -a nginx

Sample output:

# -l
24910 nginx
26578 nginx
26579 nginx

# -a
24910 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
26578 nginx: worker process
26579 nginx: worker process

Search child processes

pgrep -aP 24910

List processes

Use ps instead: Ps Command in Linux

Use pgrep with ps:

# list processes with command node
pgrep node | xargs --no-run-if-empty ps -p

Search and kill processes

Use pkill instead: Pkill Command in Linux


pgrep(1) - Linux man page