pgrep command for listing PID’s

pgrep is a bash command that looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout.  All the criteria given as parameters to pgrep have to matched.

$ pgrep fi
— List the PID of process names match with “fi”.
$ pgrep -l fi
— Same as above and process name also get listed.
$ pgrep -vl fi
— List all processes, which name not match with “fi”.
$ pgrep -xl fi
— List all processes, which name exactly match with “fi”.
$ pgrep -f sbin
–List all processes, which are running from  some sbin folder. It check the command line also.
$pgrep -c fi
–Show the count of matching processes.
$ pgrep -d, fi
— List the matching process id in CSV format.
$ pgrep -t tty1
— List the process controlling the term tty1.
$ pgrep -u root, jo
— List all processes owned by root and jo.
$ pgrep -u jo gnome
— List the process called sshd and owned  by jo.
$ pgrep -n fi
— Show only the newest process.
$ pgrep -o fi
— Show only the oldest process.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s