May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

pgrep (ps grep)

News Linux process management Recommended Books Recommended Links How to kill all processes for a particular user pkill command pgrep ps command
pstree kill command killall Controlling System Processes Unix Signals systemd Zombies Xinetd
process table SIGKILL SIGTERM Admin Horror Stories bash Tips and Tricks Tips Humor Etc

Command pgrep is a command line utility similar to ps It was initially written for Solaris 7 operating system. Later it was reimplementation for all major OS that have /proc pseudo filesystem including Linux, BSD and HP-UX 11.3.

Options are identical with those implemented on Solaris, so Solaris documentation can be used for Linux pgrep.

Like in ps process name can be specified with extended regular expression patterns, and, by default, returns their ID. Functionally, the pgrep  command combines the ps  command with the grep  command.

The syntax:

pgrep [-option] pattern 
Options Description
- l long listings (name of the profess and its PID)
-g pgrplist Matches the processes with the process group ID.
-G gidlist Matches the active processes with the group ID(s) specified in the command line. For example, if you are searching for processes running with the group ID sysman, specify the command pgrep G sysman.
-d delim Specifies a delimiter for separating PIDs.
-n Matches the most recent process.
-P ppidlist The processes are matched with the parent process ID in the listing.
-s sidlist The processes are matched with the session ID in the list.
-t termlist Matches the terminal on which the process is running.
-u euidlist Matches processes with the effective used ID in the list. The effective uid is the uid of the executable file when the SUID of the file is set.
-U uidlist Matches processes with the real uid in the list. The real uid is the uid that the user uses when starting a task or a process.
-v Matches all processes except those that meet the specified criteria in the command line.
-f Matches pattern against full arguments rather than the name of the executable file.
-x Matches the processes that exactly match the specified pattern.

The following example displays the process ID for the process sh:

$ pgrep sh

The following command displays the process ID of all those processes matching the in  pattern:

$ pgrep in*
The pgrep  command with the l  option displays the name of the processes, which contains the string in  along with their PIDs.
$ pgrep -l in
    1 init
  111 in.routed
  118 in.ndpd
  156 inetd
  133 rpcbind

The following command displays the processes owned by user James:

$ pgrep -u james

You can combine options. In the following example, both the l  and the u  options are used together with the pgrep  command to display the names of all the processes run by user James, along with his process ID.

$ pgrep -l -u james
 1459 sh
 1464 csh 

The -d  option is used to specify a delimiter for separating PIDs when more than one process ID is tested in the output of the pgrep  command. The following example uses delimiters for the listed processes for the user James.

$ pgrep d";" u james
951; 1042; 1051


You can specify more than one user ID by using a comma (,) as a field separator.


pgrep's default behaviour (returning the process identifier(s) of the named task(s)) is invoked by typing:

pgrep taskname

This is roughly equivalent to the following command:

ps ax | grep taskname | grep -v grep | awk '{print $1}'

Hence, pgrep simplifies an otherwise complex task.

pgrep also has additional functionality, e.g.:

pgrep -l -G other
pgrep -v -u root
pgrep -u root sshd
pgrep -u root,daemon

Examples from man page
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 netscape processes run nicer:

$ renice +4 `pgrep netscape`

Top Visited
Past week
Past month


Old News ;-)

[Sep 01, 2010] Solaris Operating System pgrep - can I see the switches a process is running with -

Please note that option -f recommended in the second answer just allow to match the pattern against the whole command line which is not what the question was about.

"gev_d" <> writes:
> Now i use pgrep alot, but I'd like to see what options the process is
> running with. for example, let's say I'm running named, but I started
> it with the wrong conf file, how would I be able to see this with
> pgrep ( if that is possible )?

How about something like this?

% ps -fp `pgrep -d, named`
James Carlson, KISS Network <>
Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677

gev_d <> wrote:
> Hi All,
> I used to use ps -ef | grep process_name to find if a process was
> running. What i liked about this was that it showed the whole command
> line argument ( switches and values and all)

pgrep -f

Recommended Links


pgrep, pkill - look up or signal processes based on name and other



pgrep [-flvx] [-d delimiter] [-n|-o] [-P ppid,...] [-g pgrp,...]
[-s sid,...] [-u euid,...] [-U uid,...] [-G gid,...]

[-t term,...] [pattern]

pkill [-signal] [-fvx] [-n|-o] [-P ppid,...] [-g pgrp,...]
[-s sid,...] [-u euid,...] [-U uid,...] [-G gid,...]

[-t term,...] [pattern]


pgrep looks through the currently running processes and lists the process IDs which matches 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


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.


-d delimiter
Sets the string used to delimit each process ID in the output (by default a newline). (pgrep only.)
The pattern is normally only matched against the process name. When -f is set, the full command line is used.
-g pgrp,...
Only match processes in the process group IDs listed. Process group 0 is translated into pgrep's or pkill's own process group.
-G gid,...
Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used.
List the process name as well as the process ID. (pgrep only.)
Select only the newest (most recently started) of the matching processes.
Select only the oldest (least recently started) of the matching processes.
-P ppid,...
Only match processes whose parent process ID is listed.
-s sid,...
Only match processes whose process session ID is listed. Session ID 0 is translated into pgrep's or pkill's own session ID.
-t term,...
Only match processes whose controlling terminal is listed. The terminal name should be specified without the "/dev/" prefix.
-u euid,...
Only match processes whose effective user ID is listed. Either the numerical or symbolical value may be used.
-U uid,...
Only match processes whose real user ID is listed. Either the numerical or symbolical value may be used.
Negates the matching.
Only match processes whose name (or command line if -f is specified) exactly match the pattern.
Defines the signal to send to each matched process. Either the numeric or the symbolic signal name can be used. (pkill only.)


Specifies an Extended Regular Expression for matching against the process names or command lines.


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

unix$ pgrep


u root named

Example 2: Make syslog reread its configuration file:


pkill -HUP syslogd

Example 3: Give detailed information on all xterm processes:

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

Example 4: Make all netscape processes run nicer:

unix$ renice +4 'pgrep netscape'

Exit Status

  1. One or more processes matched the criteria.
  2. No processes matched.
  3. Syntax error in the command line.
  4. Fatal error: out of memory etc.


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.


pkill and pgrep were introduced in Sun's Solaris 7. This implementation is fully compatible.


Kjetil Torgrim Homme <[email protected]>



Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy


War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes


Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law


Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D

Copyright © 1996-2021 by Softpanorama Society. was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site


The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 12, 2019