LinuxCommandLibrary

pidof

finds the process IDs of the named programs and prints them on standard output

TLDR

List all process IDs with given name

$ pidof bash
copy
List a single process ID with given name
$ pidof -s bash
copy
List process IDs including scripts
$ pidof -x script.py
copy
Kill all processes with given name
$ kill $(pidof name)
copy
Show thread IDs instead of process IDs
$ pidof -t process_name
copy

SYNOPSIS

pidof [-s] [-c] [-q] [-w] [-x] [-o omitpid] [-t] [-S separator] program...

DESCRIPTION

pidof finds the process IDs (PIDs) of the named programs and prints them on standard output. It is useful for scripting and identifying running processes by name.

PARAMETERS

-s

Single shot - only return one PID
-c
Only return process IDs running with the same root directory
-q
Quiet mode - suppress output and only set exit status
-w
Show processes without visible command line (e.g., kernel threads)
-x
Also return PIDs of shells running the named scripts
-o omitpid
Omit processes with the specified PID; use %PPID for parent process
-t
Show thread IDs instead of PIDs
-S separator
Use specified separator between PIDs (default is space)

CAVEATS

Exit status 0 means at least one matching program was found; exit status 1 means no matching program was found. When using -x for scripts, the script name must match exactly.

HISTORY

pidof is part of the sysvinit package and provides a way to find process IDs by name, complementing commands like pgrep.

SEE ALSO

pgrep(1), pkill(1), killall(1), ps(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community