Skip to main content

pkill Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for finding and terminating processes by name, user, and pattern with pkill in Linux

The `pkill` command sends signals to processes that match a name, user, terminal, or full command pattern. This cheatsheet covers safe matching patterns, common signals, and practical process-control examples.

Basic Syntax

Core pkill command forms.

CommandDescription
pkill process_nameSend SIGTERM to matching process names
pkill -f "pattern"Match against full command line
pkill -u username process_nameMatch only processes owned by a user
pkill -x process_nameMatch exact process name only
pkill -l process_nameKill matching processes and print their name and PID

Common Signals

Frequently used signals with pkill.

CommandDescription
pkill -15 process_nameGraceful stop (SIGTERM, default)
pkill -9 process_nameForce kill (SIGKILL)
pkill -HUP process_nameReload/reopen config for daemons
pkill -INT process_nameInterrupt process (SIGINT)
pkill -USR1 process_nameSend user-defined signal 1

Match Controls

Limit matches to avoid terminating the wrong process.

CommandDescription
pkill -x nginxKill only exact nginx process name
pkill -f "python3 app.py"Match a specific command string
pkill -u deploy -x nodeMatch exact node only for user deploy
pkill -t pts/2Match processes attached to terminal pts/2
pkill -P 1234Match child processes of PID 1234

Safer Workflow

Preview targets before signaling processes.

CommandDescription
pgrep -a nginxPreview matching processes and command lines
pgrep -afu deploy nodePreview user-scoped full-command matches
pgrep -f "python3 app.py"Confirm full-pattern matches first
pkill -x nginxExecute only after preview validation
echo $?Check exit code (0 match found, 1 none found)

Service and App Examples

Practical process control patterns.

CommandDescription
pkill -HUP nginxAsk Nginx master process to reload
pkill -u www-data -x php-fpmStop php-fpm workers for one user
pkill -f "gunicorn: worker"Signal Gunicorn worker processes
pkill -f "node server.js"Stop a specific Node.js app instance
pkill -x firefoxClose all Firefox processes for current user

Troubleshooting

Quick checks for common pkill issues.

IssueCheck
Nothing happenedVerify matches with pgrep -a using the same pattern
Wrong process was terminatedUse -x or stricter -f pattern matching
Operation not permittedUse sudo or run as the process owner
Process did not stopTry SIGTERM first, then escalate to -9 only if needed
Script fails when nothing matchesHandle exit code 1 as a non-match condition

Use these guides for deeper signal and process-management workflows.

GuideDescription
pkill Command in LinuxFull pkill guide with examples
kill Command in LinuxSend signals by PID
pgrep Command in LinuxSearch processes by name and pattern
ps Command in LinuxInspect current process list
top Command in LinuxMonitor processes in real time