pgrep flags & options
Basic usage
Find process IDs by name.
pgrep nginx
-l, --list-name
Show the process name alongside the PID.
pgrep -l python
-a, --list-full
Show the full command line.
pgrep -a node
-u, --euid
Match by effective user.
pgrep -u www-data
pgrep -lu root
-f, --full
Match against the full command line, not just the process name.
pgrep -f "python server.py"
-c, --count
Print the count of matching processes instead of PIDs.
pgrep -c nginx
-x, --exact
Match the process name exactly.
pgrep -x ssh
-n, --newest
Select only the most recently started matching process.
pgrep -n python
-o, --oldest
Select only the oldest matching process.
pgrep -o python
-d, --delimiter
Set the output delimiter.
pgrep -d, nginx
pkill
Send a signal to matching processes (same flags as pgrep).
pkill -f "python server.py"
pkill -u testuser