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

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

ps

See what is running, find a process ID, and combine with grep to hunt down a program.

kill

Terminate processes politely or forcibly — and understand what -9 really does.

systemctl

Start, stop, enable and inspect services — the control panel of modern Linux.

Concepts involved: Process · PID (Process ID)

More how-to guides

Check disk space in Linux

See how much space is left, and find out what is using it.

Extract a .tar.gz archive

Unpack tar.gz, tar.bz2, tar.xz and zip archives from the command line.

Free a port that is already in use

Find which process holds a port and stop it cleanly.

Find and replace text in files

Replace text in one file or across a whole project, safely.