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

  • programa

    Name of the program whose PID you want.

  • -s

    Returns a single PID.

  • -x

    Also includes scripts running under that name.

  • -o PID

    Omits that PID from the results.

  • -c

    Only returns processes running under the same root directory.

Usage examples

  • pidof sshd

    Shows the PIDs of the SSH server.

  • pidof -s nginx

    Shows a single nginx PID.

  • pidof -x backup.sh

    Finds 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.

Related commands