- Return PIDs of any running processes with a matching command string:pgrep [process_name]- Search full command line with parameters instead of just the process name:pgrep -f "[process_name] [parameter]"- Search for process run by a specific user:pgrep -u root [process_name]
pgrep [options] pattern pkill [options] pattern
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,
will only list the processes called sshd AND owned by root. On the other hand,
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.
Example 1: Find the process ID of the named daemon:
Example 2: Make syslog reread its configuration file:
Example 3: Give detailed information on all xterm processes:
Example 4: Make all netscape processes run nicer:
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 or pkill process will never report itself as a match.
The options -n and -o and -v can not be combined. Let me know if you need to do this.
Defunct processes are reported.
ps(1), regex(7), signal(7), killall(1), skill(1), kill(1), kill(2)
Kjetil Torgrim Homme
Please send bug reports to