{
    "mode": "man",
    "parameter": "pgrep",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pgrep/1/json",
    "generated": "2026-06-13T22:56:05Z",
    "synopsis": "pgrep [options] pattern\npkill [options] pattern\npidwait [options] pattern",
    "sections": {
        "NAME": {
            "content": "pgrep,  pkill,  pidwait  - look up, signal, or wait for processes based on name and other at‐\ntributes\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pgrep [options] pattern\npkill [options] pattern\npidwait [options] pattern\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "pgrep looks through the currently running processes and lists the process IDs which match the\nselection criteria to stdout.  All the criteria have to match.  For example,\n\n$ pgrep -u root sshd\n\nwill only list the processes called sshd AND owned by root.  On the other hand,\n\n$ pgrep -u root,daemon\n\nwill list the processes owned by root OR daemon.\n\npkill  will send the specified signal (by default SIGTERM) to each process instead of listing\nthem on stdout.\n\npidwait will wait for each process instead of listing them on stdout.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "-signal\n--signal signal\nDefines the signal to send to each matched process.  Either the numeric  or  the  sym‐\nbolic signal name can be used.  (pkill only.)\n",
            "subsections": [
                {
                    "name": "-c --count",
                    "content": "Suppress  normal output; instead print a count of matching processes.  When count does\nnot match anything, e.g. returns zero, the command will return  non-zero  value.  Note\nthat  for  pkill  and  pidwait, the count is the number of matching processes, not the\nprocesses that were successfully signaled or waited for.\n",
                    "flag": "-c",
                    "long": "--count"
                },
                {
                    "name": "-d --delimiter",
                    "content": "Sets the string used to delimit each process ID in the output (by default a  newline).\n(pgrep only.)\n",
                    "flag": "-d",
                    "long": "--delimiter"
                },
                {
                    "name": "-e --echo",
                    "content": "Display name and PID of the process being killed.  (pkill only.)\n",
                    "flag": "-e",
                    "long": "--echo"
                },
                {
                    "name": "-f --full",
                    "content": "The  pattern  is  normally only matched against the process name.  When -f is set, the\nfull command line is used.\n",
                    "flag": "-f",
                    "long": "--full"
                },
                {
                    "name": "-g --pgroup",
                    "content": "Only match processes in the process group IDs listed.  Process group 0  is  translated\ninto pgrep's, pkill's, or pidwait's own process group.\n",
                    "flag": "-g",
                    "long": "--pgroup"
                },
                {
                    "name": "-G --group",
                    "content": "Only  match processes whose real group ID is listed.  Either the numerical or symboli‐\ncal value may be used.\n",
                    "flag": "-G",
                    "long": "--group"
                },
                {
                    "name": "-i --ignore-case",
                    "content": "Match processes case-insensitively.\n",
                    "flag": "-i",
                    "long": "--ignore-case"
                },
                {
                    "name": "-l --list-name",
                    "content": "List the process name as well as the process ID.  (pgrep only.)\n",
                    "flag": "-l",
                    "long": "--list-name"
                },
                {
                    "name": "-a --list-full",
                    "content": "List the full command line as well as the process ID.  (pgrep only.)\n",
                    "flag": "-a",
                    "long": "--list-full"
                },
                {
                    "name": "-n --newest",
                    "content": "Select only the newest (most recently started) of the matching processes.\n",
                    "flag": "-n",
                    "long": "--newest"
                },
                {
                    "name": "-o --oldest",
                    "content": "Select only the oldest (least recently started) of the matching processes.\n",
                    "flag": "-o",
                    "long": "--oldest"
                },
                {
                    "name": "-O --older",
                    "content": "Select processes older than secs.\n",
                    "flag": "-O",
                    "long": "--older"
                },
                {
                    "name": "-P --parent",
                    "content": "Only match processes whose parent process ID is listed.\n",
                    "flag": "-P",
                    "long": "--parent"
                },
                {
                    "name": "-s --session",
                    "content": "Only match processes whose process session ID is listed.  Session ID 0  is  translated\ninto pgrep's, pkill's, or pidwait's own session ID.\n",
                    "flag": "-s",
                    "long": "--session"
                },
                {
                    "name": "-t --terminal",
                    "content": "Only  match  processes whose controlling terminal is listed.  The terminal name should\nbe specified without the \"/dev/\" prefix.\n",
                    "flag": "-t",
                    "long": "--terminal"
                },
                {
                    "name": "-u --euid",
                    "content": "Only match processes whose effective user ID is listed.  Either the numerical or  sym‐\nbolical value may be used.\n",
                    "flag": "-u",
                    "long": "--euid"
                },
                {
                    "name": "-U --uid",
                    "content": "Only match processes whose real user ID is listed.  Either the numerical or symbolical\nvalue may be used.\n",
                    "flag": "-U",
                    "long": "--uid"
                },
                {
                    "name": "-v --inverse",
                    "content": "Negates the matching.  This option is usually used in pgrep's  or  pidwait's  context.\nIn  pkill's  context the short option is disabled to avoid accidental usage of the op‐\ntion.\n",
                    "flag": "-v",
                    "long": "--inverse"
                },
                {
                    "name": "-w --lightweight",
                    "content": "Shows all thread ids instead of pids in pgrep's or pidwait's context.  In pkill's con‐\ntext this option is disabled.\n",
                    "flag": "-w",
                    "long": "--lightweight"
                },
                {
                    "name": "-x --exact",
                    "content": "Only  match  processes whose names (or command lines if -f is specified) exactly match\nthe pattern.\n",
                    "flag": "-x",
                    "long": "--exact"
                },
                {
                    "name": "-F --pidfile",
                    "content": "Read PIDs from file.  This option is more useful for pkillorpidwait than pgrep.\n",
                    "flag": "-F",
                    "long": "--pidfile"
                },
                {
                    "name": "-L --logpidfile",
                    "content": "Fail if pidfile (see -F) not locked.\n",
                    "flag": "-L",
                    "long": "--logpidfile"
                },
                {
                    "name": "-r --runstates",
                    "content": "Match only processes which match the process state.\n\n--ns pid\nMatch processes that belong to the same namespaces. Required to run as root  to  match\nprocesses from other users. See --nslist for how to limit which namespaces to match.\n\n--nslist name,...\nMatch  only  the  provided  namespaces.  Available  namespaces:  ipc,  mnt,  net, pid,\nuser,uts.\n",
                    "flag": "-r",
                    "long": "--runstates"
                },
                {
                    "name": "-q --queue",
                    "content": "Use sigqueue(3) rather than kill(2) and the value argument is used to specify an inte‐\nger  to  be sent with the signal. If the receiving process has installed a handler for\nthis signal using the SASIGINFO flag to sigaction(2) , then it can obtain  this  data\nvia the sivalue field of the siginfot structure.\n",
                    "flag": "-q",
                    "long": "--queue"
                },
                {
                    "name": "-V --version",
                    "content": "Display version information and exit.\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "-h --help",
                    "content": "Display help and exit.\n",
                    "flag": "-h",
                    "long": "--help"
                }
            ]
        },
        "OPERANDS": {
            "content": "pattern\nSpecifies  an  Extended  Regular  Expression for matching against the process names or\ncommand lines.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Example 1: Find the process ID of the named daemon:\n\n$ pgrep -u root named\n\nExample 2: Make syslog reread its configuration file:\n\n$ pkill -HUP syslogd\n\nExample 3: Give detailed information on all xterm processes:\n\n$ ps -fp $(pgrep -d, -x xterm)\n\nExample 4: Make all chrome processes run nicer:\n\n$ renice +4 $(pgrep chrome)\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "0      One or more processes matched the criteria. For pkill and pidwait, one  or  more  pro‐\ncesses must also have been successfully signalled or waited for.\n1      No processes matched or none of them could be signalled.\n2      Syntax error in the command line.\n3      Fatal error: out of memory etc.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "The  process  name used for matching is limited to the 15 characters present in the output of\n/proc/pid/stat.  Use the -f option to match against the complete command line, /proc/pid/cmd‐\nline.\n\nThe running pgrep, pkill, or pidwait process will never report itself as a match.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "The options -n and -o and -v can not be combined.  Let me know if you need to do this.\n\nDefunct processes are reported.\n\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "ps(1), regex(7), signal(7), sigqueue(3), killall(1), skill(1), kill(1), kill(2)\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Kjetil Torgrim Homme ⟨kjetilho@ifi.uio.no⟩\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "Please send bug reports to ⟨procps@freelists.org⟩\n\n\n\nprocps-ng                                    2020-06-04                                     PGREP(1)",
            "subsections": []
        }
    },
    "summary": "pgrep,  pkill,  pidwait  - look up, signal, or wait for processes based on name and other at‐ tributes",
    "flags": [
        {
            "flag": "-c",
            "long": "--count",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-d",
            "long": "--delimiter",
            "arg": null,
            "description": "Sets the string used to delimit each process ID in the output (by default a newline). (pgrep only.)"
        },
        {
            "flag": "-e",
            "long": "--echo",
            "arg": null,
            "description": "Display name and PID of the process being killed. (pkill only.)"
        },
        {
            "flag": "-f",
            "long": "--full",
            "arg": null,
            "description": "The pattern is normally only matched against the process name. When -f is set, the full command line is used."
        },
        {
            "flag": "-g",
            "long": "--pgroup",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-G",
            "long": "--group",
            "arg": null,
            "description": "Only match processes whose real group ID is listed. Either the numerical or symboli‐ cal value may be used."
        },
        {
            "flag": "-i",
            "long": "--ignore-case",
            "arg": null,
            "description": "Match processes case-insensitively."
        },
        {
            "flag": "-l",
            "long": "--list-name",
            "arg": null,
            "description": "List the process name as well as the process ID. (pgrep only.)"
        },
        {
            "flag": "-a",
            "long": "--list-full",
            "arg": null,
            "description": "List the full command line as well as the process ID. (pgrep only.)"
        },
        {
            "flag": "-n",
            "long": "--newest",
            "arg": null,
            "description": "Select only the newest (most recently started) of the matching processes."
        },
        {
            "flag": "-o",
            "long": "--oldest",
            "arg": null,
            "description": "Select only the oldest (least recently started) of the matching processes."
        },
        {
            "flag": "-O",
            "long": "--older",
            "arg": null,
            "description": "Select processes older than secs."
        },
        {
            "flag": "-P",
            "long": "--parent",
            "arg": null,
            "description": "Only match processes whose parent process ID is listed."
        },
        {
            "flag": "-s",
            "long": "--session",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-t",
            "long": "--terminal",
            "arg": null,
            "description": "Only match processes whose controlling terminal is listed. The terminal name should be specified without the \"/dev/\" prefix."
        },
        {
            "flag": "-u",
            "long": "--euid",
            "arg": null,
            "description": "Only match processes whose effective user ID is listed. Either the numerical or sym‐ bolical value may be used."
        },
        {
            "flag": "-U",
            "long": "--uid",
            "arg": null,
            "description": "Only match processes whose real user ID is listed. Either the numerical or symbolical value may be used."
        },
        {
            "flag": "-v",
            "long": "--inverse",
            "arg": null,
            "description": "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 op‐ tion."
        },
        {
            "flag": "-w",
            "long": "--lightweight",
            "arg": null,
            "description": "Shows all thread ids instead of pids in pgrep's or pidwait's context. In pkill's con‐ text this option is disabled."
        },
        {
            "flag": "-x",
            "long": "--exact",
            "arg": null,
            "description": "Only match processes whose names (or command lines if -f is specified) exactly match the pattern."
        },
        {
            "flag": "-F",
            "long": "--pidfile",
            "arg": null,
            "description": "Read PIDs from file. This option is more useful for pkillorpidwait than pgrep."
        },
        {
            "flag": "-L",
            "long": "--logpidfile",
            "arg": null,
            "description": "Fail if pidfile (see -F) not locked."
        },
        {
            "flag": "-r",
            "long": "--runstates",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-q",
            "long": "--queue",
            "arg": null,
            "description": "Use sigqueue(3) rather than kill(2) and the value argument is used to specify an inte‐ ger to be sent with the signal. If the receiving process has installed a handler for this signal using the SASIGINFO flag to sigaction(2) , then it can obtain this data via the sivalue field of the siginfot structure."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Display version information and exit."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "Display help and exit."
        }
    ],
    "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)"
    ],
    "see_also": [
        {
            "name": "ps",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/ps/1/json"
        },
        {
            "name": "regex",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/regex/7/json"
        },
        {
            "name": "signal",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/signal/7/json"
        },
        {
            "name": "sigqueue",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/sigqueue/3/json"
        },
        {
            "name": "killall",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/killall/1/json"
        },
        {
            "name": "skill",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/skill/1/json"
        },
        {
            "name": "kill",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/kill/1/json"
        },
        {
            "name": "kill",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/kill/2/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Find processes by name.",
        "examples": [
            {
                "description": "Return PIDs of any running processes with a matching command string",
                "command": "pgrep {{process_name}}"
            },
            {
                "description": "Print the process name in addition to the PID ([l]ong output)",
                "command": "pgrep -l {{process_name}}"
            },
            {
                "description": "Match processes against the [f]ull argument list instead of just the process name",
                "command": "pgrep -f \"{{process_name}} {{parameter}}\""
            },
            {
                "description": "Print the PID together with the [f]ull argument [l]ist for each match",
                "command": "pgrep -fl \"{{process_name}}\""
            },
            {
                "description": "Search for processes run by a specific [u]ser (effective UID)",
                "command": "pgrep -u {{username}} {{process_name}}"
            },
            {
                "description": "Select only the [n]ewest (most recently started) matching process",
                "command": "pgrep -n {{process_name}}"
            }
        ]
    }
}