10

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.

24

-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

1
  • 2
    I'd never thought I have asked such rare question. It has been impact-full. Thanks for the simple explanation... – PatilSaheb Aug 22 '18 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.