How to Find a Process ID (PID) in Linux
Locate a process PID with ps, pgrep and pidof before inspecting or stopping it.
A PID is the numeric identifier assigned to a running process. Finding the correct PID matters because PIDs are reused after processes exit.
Step by step
1 Search by name
$ pgrep nginx Returns PIDs for processes whose names match nginx.
2 Show the full command line
$ pgrep -af python Shows command-line context and matches the full command line.
3 Inspect a PID
$ ps -fp 12345 Confirm the owner, parent PID and command before acting.
4 Use pidof
$ pidof nginx A simple alternative when you only need PIDs for a program name.
Tips worth knowing
- Use `pgrep -af` when several instances share an executable.
- For systemd services, `systemctl status SERVICE` often exposes the main PID.
- Perform a fresh lookup before sending a signal.
Frequently asked questions
How do I find the PID of a process?
Use `pgrep`, `ps`, `pidof` or a process viewer such as top.
What does PID stand for?
Process ID, the numeric identifier of a running process.
The commands behind it
See what is running, find a process ID, and combine with grep to hunt down a program.
killTerminate processes politely or forcibly — and understand what -9 really does.
systemctlStart, stop, enable and inspect services — the control panel of modern Linux.
Concepts involved: Process · PID (Process ID)
More how-to guides
See how much space is left, and find out what is using it.
Extract a .tar.gz archiveUnpack tar.gz, tar.bz2, tar.xz and zip archives from the command line.
Free a port that is already in useFind which process holds a port and stop it cleanly.
Find and replace text in filesReplace text in one file or across a whole project, safely.