Linux / Bash, using ps -o to get process by specific name?

Rick picture Rick · Sep 24, 2010 · Viewed 128.5k times · Source

I am trying to use the ps -o command to get just specific info about processes matching a certain name. However, I am having some issues on this, when I try to use this even to just get all processes, like so, it just returns a subset of what a normal ps -ef would return (it doesn't return nearly the same number of results so its not returning all running processes)

ps -ef -o pid,time,comm

I want to try something like this (below) but incorporate the ps -o to just get specific info from it (just the PID)

ps -ef |grep `whoami`| grep firefox-bin

Any advice is appreciated as to how to do this properly, thanks

Answer

Alex Howansky picture Alex Howansky · Sep 24, 2010

This will get you the PID of a process by name:

pidof name

Which you can then plug back in to ps for more detail:

ps -p $(pidof name)