In order to search for a process you can use ps
with grep
.
For example to search for firefox
ps aux | grep firefox
How to get the same answer without using grep
?
command lineprocess
In order to search for a process you can use ps
with grep
.
For example to search for firefox
ps aux | grep firefox
How to get the same answer without using grep
?
Best Answer
The
pgrep
command, and its siblingpkill
, exists precisely for this purpose:pgrep firefox
will list all processes whose commands matchfirefox
pgrep -f firefox
will list all processes whose entire command lines matchfirefox
pgrep -x firefox
will list all processes whose commands exactly matchfirefox
And naturally,
pgrep
will exclude itself from the match, so none of thegrep
rituals associated withps | grep
are needed.The other set of tools for this are the
pidof
andkillall
commands. These aren't as flexible aspgrep
andpkill
.pidof firefox
will list processes whose command isfirefox