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.
01Command
$ pgrep -a firefox02What 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
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- pgrep, pkill, pidwait - look up, signal, or wait for processes based on name and other attributesEvidence: "-a, --list-full List the full command line as well as the process ID. The process ID will be separated from the command line by a single space."
- Ubuntu Manpage: pgrep, pkill, pidwait - look up, signal, or wait for processesEvidence: The pgrep program displays "the process IDs of the selected processes"; -a/--list-full lists the full command line together with each PID.
Last verified: 2026-09-19 · Category: System & Settings
06Related solutions
Refresh the package index from all configured repositories, then install newer versions of every upgradable package.
Find every occurrence of a pattern across all files in a tree, printed as file:line:number matches.
Unpack a gzipped tarball into the current directory while printing each file as it is extracted.