What Is the pkill Command in Linux?¶
Introduction¶
The pkill command sends signals to processes selected by name or pattern. It is useful for beginners, Linux administrators, DevOps engineers, and RHCSA students because it solves practical terminal tasks.
What the Command Does¶
Use pkill to work with the specific Linux object it manages. Before changing anything, identify the target and run a read-only check when possible.
Basic Syntax¶
pkill OPTIONS PATTERN
The syntax includes the command, any options, and the target object.
Common Options¶
-u: match processes by user.-f: match full command line.-HUP: send SIGHUP.
Practical Examples¶
pkill firefox
sudo pkill -HUP rsyslogd
pkill -u student
pkill -f "python app.py"
Verification command:
pgrep -a firefox
Example output:
2345 /usr/lib64/firefox/firefox
2351 /usr/lib64/firefox/firefox -contentproc
When to Use This Command¶
Use pkill when you need to signal processes by name, user, or full command pattern instead of manually collecting PIDs.
Common Mistakes¶
- Using a broad pattern that matches unrelated processes.
- Using
-fwithout previewing with pgrep. - Forgetting that pkill may affect multiple processes at once.
Quick Reference¶
pkill firefox
sudo pkill -HUP rsyslogd
pgrep -a firefox
Related Guides¶
Summary¶
The pkill command is safest when you understand the target, choose the right option, and verify the result with a separate command.