Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-04-2011, 04:55 PM   #1
LQ Newbie
Registered: Feb 2011
Location: Waterloo, Ontario, Canada
Distribution: Ubuntu 10.10, Arch
Posts: 11

Rep: Reputation: 0
How do I find the pid of a certain process?

Hi, this is my first time posting here.
I tried googling how to use grep, but I still dont rlly understand how does grep work
I know that this command
"pid aux | less"
displays all the processes and their pid
but it would be too time consuming to search for the pid of one specific process
is there a way to use "grep" to find pid of a certain process?

i tried "grep process-name pid aux"
but it doesnt work

Old 02-04-2011, 05:01 PM   #2
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
The 'pgrep' command does the work for you:

pgrep process-name
From 'man pgrep':

pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout.
Old 02-04-2011, 05:06 PM   #3
LQ Newbie
Registered: Feb 2011
Location: Waterloo, Ontario, Canada
Distribution: Ubuntu 10.10, Arch
Posts: 11

Original Poster
Rep: Reputation: 0
thank you very much, it works every well

But a friend of mine told me "ps aux | grep process_name" would work, and it did

so im just wondering here
since to read the output of "ps aux", i use the command "ps aux | less"
does that mean If i want to do something to the output of a certain command, I should always add "|" to it and type another command following it?

I ve played around with a few commands, my assumption seems to be true :P
but thx again for telling me about pgrep, its a lot more convenient than having to type ps aux | grep something

Last edited by BeyondSora; 02-04-2011 at 05:21 PM.
Old 02-04-2011, 05:24 PM   #4
LQ Newbie
Registered: Jan 2011
Posts: 1

Rep: Reputation: 1
the | symbol means pipe .

A pipe can pass the standard output of one operation to the standard input of another

so you could do cat /etc/group | grep root this would show only the groups root appears in.

or if you were building a RAID cat /proc/mdstat | watch -n 1 would show you the RAID building.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how find pid of process in C language (POSIX) shifter Programming 6 04-20-2007 02:13 PM
Looking for a way to find a PID and kill the process it belongs to johngreenwood Programming 6 01-14-2007 05:45 AM
How to find the PID of a process using C programming? socialjazz Programming 3 10-06-2006 12:53 AM
using bash to find the pid of a process called "name" poiuytrewq Linux - Newbie 3 10-25-2004 09:01 PM
How to find the pid to stop a process.... vous Linux - Networking 6 08-14-2003 04:18 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:08 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration