System and processes
The pidof command
Returns the PID of a program by name. Handy for scripts that need the exact number.
Syntax
pidof programaCopy-ready examples
$ pidof sshdPID of the SSH serverYou can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- If there are several instances it returns several numbers; if there are none it prints nothing.
FAQ
How does it differ from pgrep?
pidof requires the exact name; pgrep searches by pattern.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course