Find a Process PID by Name with pgrep

Use pgrep -a to look up the process ID (PID) of any running program by name and see its full command line.

LinuxprocesscommandTerminalLow risk
Run pgrep -a firefox to print the PID(s) of Firefox together with the full command that launched each one.

01Command

Command
$ pgrep -a firefox

02What it does

pgrep searches the process table for names that match the pattern and prints matching PIDs one per line. The -a (--list-full) flag also shows the full command line, which helps when several processes share a name. Without -a you only get bare PIDs; add -l to see just the program name next to each PID, or -f to match against the whole command line instead of only the process name.

03Risk

RiskLow risk
!Warning: pgrep matches by name, so a short pattern can match more processes than you expect — run pgrep -a first to confirm exactly which PIDs you found before signaling anything.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-19 · Category: System & Settings

06Related solutions