Ubuntu – How to search for a process by name 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 sibling pkill, exists precisely for this purpose:

  • pgrep firefox will list all processes whose commands match firefox
  • pgrep -f firefox will list all processes whose entire command lines match firefox
  • pgrep -x firefox will list all processes whose commands exactly match firefox
  • ... and so on.

And naturally, pgrep will exclude itself from the match, so none of the grep rituals associated with ps | grep are needed.


The other set of tools for this are the pidof and killall commands. These aren't as flexible as pgrep and pkill.

  • pidof firefox will list processes whose command is firefox
Related Question