GNU/Linux Command – PGREP

pgrep — Match the processes based on name and other attributes

Summary:
The grep command used to match a string in a file. pgrep tool is used to match the processes from the currently running processes, based on name, uid, gid, command line attributes. By default, pgrep list only Process ID. But using -l option, we can get the process name also.

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

Read: man pgrep

Advertisements
Tagged with: ,
Posted in Uncategorized

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

%d bloggers like this: