info > pgrep(1)

๐Ÿ“– NAME

pgrep, pkill, pidwait โ€” look up, signal, or wait for processes based on name and other attributes

๐Ÿš€ Quick Reference

Use CaseCommandDescription
๐Ÿ” Find PID by exact process namepgrep -x sshdLists PIDs of processes named exactly sshd
๐Ÿ” Find PID of a daemon owned by rootpgrep -u root namedLists PIDs of named processes owned by root
๐Ÿ” Count matching processespgrep -c httpdPrints number of httpd processes
๐Ÿ” List process name and PIDpgrep -l sshdShows both name and PID
๐Ÿ” List full command line and PIDpgrep -a processShows full command line and PID
๐Ÿ” Match against full command linepgrep -f "pattern"Matches pattern against full command line
๐Ÿ” Case-insensitive matchpgrep -i processIgnores case when matching
๐Ÿ” Invert matchpgrep -v processLists processes not matching pattern
๐Ÿ” Most recently started processpgrep -n bashSelects newest matching process
๐Ÿ” Oldest processpgrep -o bashSelects oldest matching process
๐Ÿ” Processes with specific parent PIDpgrep -P 1234Matches child processes of PID 1234
๐Ÿ” Processes by user (effective UID)pgrep -u rootMatches processes owned by root
๐Ÿ” Processes by grouppgrep -G 1000Matches processes with real group ID 1000
๐Ÿ” Processes by terminalpgrep -t pts/0Matches processes on terminal pts/0
๐Ÿ” Processes by session IDpgrep -s 100Matches processes in session 100
๐Ÿ” Processes older than N secondspgrep -O 3600Matches processes older than 3600 seconds
๐Ÿ” Processes from a PID filepgrep -F /var/run/sshd.pidReads PIDs from file
๐Ÿ” Thread IDs instead of PIDspgrep -w processShows all thread IDs
๐Ÿ” Processes by namespacepgrep --ns 1Matches processes in same namespace as PID 1
๐Ÿšฆ Send signal to processpkill -HUP syslogdSends SIGHUP to syslogd
๐Ÿšฆ Kill process by namepkill chromeSends SIGTERM to all chrome processes
๐Ÿšฆ Echo killed processespkill -e sshdDisplays name and PID of killed processes
๐Ÿšฆ Custom signalpkill -SIGKILL processSends SIGKILL
โณ Wait for processes to exitpidwait processWaits for all matching processes to terminate

๐Ÿ“ SYNOPSIS

pgrep [options] pattern
pkill [options] pattern
pidwait [options] pattern

๐Ÿ“˜ DESCRIPTION

pgrep looks through the currently running processes and lists the process IDs which match the selection criteria to stdout. All the criteria have to match. For example,

$ pgrep -u root sshd

will only list the processes called sshd AND owned by root. On the other hand,

$ pgrep -u root,daemon

will list the processes owned by root OR daemon.

pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.

pidwait will wait for each process instead of listing them on stdout.

โš™๏ธ OPTIONS

๐Ÿ”ง -signal, --signal

Defines the signal to send to each matched process. Either the numeric or the symbolic signal name can be used. (pkill only.)

๐Ÿ”ข -c, --count

Suppress normal output; instead print a count of matching processes. When count does not match anything, e.g. returns zero, the command will return non-zero value. Note that for pkill and pidwait, the count is the number of matching processes, not the processes that were successfully signaled or waited for.

๐Ÿ”— -d, --delimiter delimiter

Sets the string used to delimit each process ID in the output (by default a newline). (pgrep only.)

๐Ÿ“ข -e, --echo

Display name and PID of the process being killed. (pkill only.)

๐Ÿ“œ -f, --full

The pattern is normally only matched against the process name. When -f is set, the full command line is used.

๐Ÿ‘ฅ -g, --pgroup pgrp,...

Only match processes in the process group IDs listed. Process group 0 is translated into pgrep's, pkill's, or pidwait's own process group.

๐Ÿ‘ฅ -G, --group gid,...

Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used.

๐Ÿ”  -i, --ignore-case

Match processes case-insensitively.

๐Ÿท๏ธ -l, --list-name

List the process name as well as the process ID. (pgrep only.)

๐Ÿ“‹ -a, --list-full

List the full command line as well as the process ID. (pgrep only.)

๐Ÿ†• -n, --newest

Select only the newest (most recently started) of the matching processes.

๐Ÿ•ฐ๏ธ -o, --oldest

Select only the oldest (least recently started) of the matching processes.

โณ -O, --older secs

Select processes older than secs.

๐Ÿง‘โ€๐Ÿ‘งโ€๐Ÿ‘ฆ -P, --parent ppid,...

Only match processes whose parent process ID is listed.

๐Ÿ–ฅ๏ธ -s, --session sid,...

Only match processes whose process session ID is listed. Session ID 0 is translated into pgrep's, pkill's, or pidwait's own session ID.

๐Ÿ–ฅ๏ธ -t, --terminal term,...

Only match processes whose controlling terminal is listed. The terminal name should be specified without the "/dev/" prefix.

๐Ÿ‘ค -u, --euid euid,...

Only match processes whose effective user ID is listed. Either the numerical or symbolical value may be used.

๐Ÿ‘ค -U, --uid uid,...

Only match processes whose real user ID is listed. Either the numerical or symbolical value may be used.

๐Ÿ™… -v, --inverse

Negates the matching. This option is usually used in pgrep's or pidwait's context. In pkill's context the short option is disabled to avoid accidental usage of the option.

๐Ÿงต -w, --lightweight

Shows all thread ids instead of pids in pgrep's or pidwait's context. In pkill's context this option is disabled.

๐ŸŽฏ -x, --exact

Only match processes whose names (or command lines if -f is specified) exactly match the pattern.

๐Ÿ“„ -F, --pidfile file

Read PIDs from file. This option is more useful for pkill or pidwait than pgrep.

๐Ÿ”’ -L, --logpidfile

Fail if pidfile (see -F) not locked.

โฌ†๏ธ -r, --runstates D,R,S,Z,...

Match only processes which match the process state.

๐ŸŒ --ns pid

Match processes that belong to the same namespaces. Required to run as root to match processes from other users. See --nslist for how to limit which namespaces to match.

๐ŸŒ --nslist name,...

Match only the provided namespaces. Available namespaces: ipc, mnt, net, pid, user, uts.

๐Ÿ“จ -q, --queue value

Use sigqueue(3) rather than kill(2) and the value argument is used to specify an integer to be sent with the signal. If the receiving process has installed a handler for this signal using the SA_SIGINFO flag to sigaction(2), then it can obtain this data via the si_value field of the siginfo_t structure.

โ„น๏ธ -V, --version

Display version information and exit.

โ“ -h, --help

Display help and exit.

๐Ÿ“ OPERANDS

pattern โ€” Specifies an Extended Regular Expression for matching against the process names or command lines.

๐Ÿ’ก EXAMPLES

Example 1: Find the process ID of the named daemon:

$ pgrep -u root named

Example 2: Make syslog reread its configuration file:

$ pkill -HUP syslogd

Example 3: Give detailed information on all xterm processes:

$ ps -fp $(pgrep -d, -x xterm)

Example 4: Make all chrome processes run nicer:

$ renice +4 $(pgrep chrome)

๐Ÿšช EXIT STATUS

0One or more processes matched the criteria. For pkill and pidwait, one or more processes must also have been successfully signalled or waited for.
1No processes matched or none of them could be signalled.
2Syntax error in the command line.
3Fatal error: out of memory etc.

๐Ÿ“ NOTES

The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat. Use the -f option to match against the complete command line, /proc/pid/cmdline.

The running pgrep, pkill, or pidwait process will never report itself as a match.

๐Ÿ› BUGS

The options -n and -o and -v can not be combined. Let me know if you need to do this.

Defunct processes are reported.

๐Ÿ“š SEE ALSO

ps(1), regex(7), signal(7), sigqueue(3), killall(1), skill(1), kill(1), kill(2)

โœ๏ธ AUTHOR

Kjetil Torgrim Homme <kjetilho AT ifi.no>

๐Ÿ“ฅ REPORTING BUGS

Please send bug reports to <procps AT freelists.org>

procps-ng   2020-06-04   PGREP(1)

pgrep(1)
๐Ÿ“– NAME ๐Ÿš€ Quick Reference ๐Ÿ“ SYNOPSIS ๐Ÿ“˜ DESCRIPTION โš™๏ธ OPTIONS
๐Ÿ”ง -signal, --signal ๐Ÿ”ข -c, --count ๐Ÿ”— -d, --delimiter delimiter ๐Ÿ“ข -e, --echo ๐Ÿ“œ -f, --full ๐Ÿ‘ฅ -g, --pgroup pgrp,... ๐Ÿ‘ฅ -G, --group gid,... ๐Ÿ”  -i, --ignore-case ๐Ÿท๏ธ -l, --list-name ๐Ÿ“‹ -a, --list-full ๐Ÿ†• -n, --newest ๐Ÿ•ฐ๏ธ -o, --oldest โณ -O, --older secs ๐Ÿง‘โ€๐Ÿ‘งโ€๐Ÿ‘ฆ -P, --parent ppid,... ๐Ÿ–ฅ๏ธ -s, --session sid,... ๐Ÿ–ฅ๏ธ -t, --terminal term,... ๐Ÿ‘ค -u, --euid euid,... ๐Ÿ‘ค -U, --uid uid,... ๐Ÿ™… -v, --inverse ๐Ÿงต -w, --lightweight ๐ŸŽฏ -x, --exact ๐Ÿ“„ -F, --pidfile file ๐Ÿ”’ -L, --logpidfile โฌ†๏ธ -r, --runstates D,R,S,Z,... ๐ŸŒ --ns pid ๐ŸŒ --nslist name,... ๐Ÿ“จ -q, --queue value โ„น๏ธ -V, --version โ“ -h, --help
๐Ÿ“ OPERANDS ๐Ÿ’ก EXAMPLES ๐Ÿšช EXIT STATUS ๐Ÿ“ NOTES ๐Ÿ› BUGS ๐Ÿ“š SEE ALSO โœ๏ธ AUTHOR ๐Ÿ“ฅ REPORTING BUGS

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-04 07:22 @216.73.216.183
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^