Ubuntu – What does “ps -ef|grep processname” mean

command linegrepps

I want to know exactly what this particular command

ps -ef|grep processname

means and how it works. I know that this should be associated with processname which we want to search for, but I don't get the prefix part; what do -ef and |(pipe) do and how does -ef|grep as a whole work. Upon googling a bit I found grep is used for searching purposes, but I would love a simple explanation of how this command setting works.

Best Answer

-e and -f are options to the ps command, and pipes take the output of one command and pass it as the input to another. Here is a full breakdown of this command:

  • ps - list processes
  • -e - show all processes, not just those belonging to the user
  • -f - show processes in full format (more detailed than default)
  • command 1 | command 2 - pass output of command 1 as input to command 2
  • grep find lines containing a pattern
  • processname - the pattern for grep to search for in the output of ps -ef

So altogether

ps -ef | grep processname

means: look for lines containing processname in a detailed overview/snapshot of all current processes, and display those lines