pidof
Linux · Processes · reference only
What it does
Returns the process IDs (PIDs) of the processes running a given program.
Syntax
pidof [opciones] programa...
Options and parameters
programaName of the program whose PID you want.
-sReturns a single PID.
-xAlso includes scripts running under that name.
-o PIDOmits that PID from the results.
-cOnly returns processes running under the same root directory.
Usage examples
pidof sshdShows the PIDs of the SSH server.
pidof -s nginxShows a single nginx PID.
pidof -x backup.shFinds the PID of a running script.
kill $(pidof -s firefox)Terminates a Firefox process using its PID.
Notes and common mistakes
- If no process has that name it prints nothing and returns a non-zero exit status.