pkill Command
Intermediate Process Management man(1)Send signals to processes based on name and attributes
👁 10 views
📅 Updated: Mar 15, 2026
SYNTAX
pkill [OPTION]... PATTERN
What Does pkill Do?
pkill sends signals to processes based on name patterns and other criteria. It is more flexible than killall because it matches against the full command line, not just the process name, and supports regex patterns.
pkill and pgrep are companion commands — pgrep finds processes, pkill kills them, using the same matching syntax. pkill supports matching by process name, full command line, user, group, terminal, and parent PID.
pkill is the recommended tool for killing processes by pattern in scripts. It is safer than killall because its matching behavior is consistent across all Unix/Linux systems.
pkill and pgrep are companion commands — pgrep finds processes, pkill kills them, using the same matching syntax. pkill supports matching by process name, full command line, user, group, terminal, and parent PID.
pkill is the recommended tool for killing processes by pattern in scripts. It is safer than killall because its matching behavior is consistent across all Unix/Linux systems.
Options & Flags
| Option | Description | Example |
|---|---|---|
| -f | Match against full command line, not just process name | pkill -f 'python3 manage.py runserver' |
| -u | Match processes owned by user | pkill -u nobody |
| -9 | Send SIGKILL instead of default SIGTERM | pkill -9 -f "node server" |
| -x | Require exact match of process name | pkill -x nginx |
| -t | Match processes on terminal | pkill -t pts/2 |
| -P | Match by parent PID | pkill -P 1234 |
| -n | Kill only the newest matching process | pkill -n python3 |
| -o | Kill only the oldest matching process | pkill -o python3 |
Practical Examples
#1 Kill by process name
Sends SIGTERM to all processes whose name matches nginx.
$ pkill nginx#2 Kill by full command line
Matches against the entire command line, useful when process name alone is not unique.
$ pkill -f 'node app.js'#3 Kill user sessions
Kills all of john's processes on terminal pts/3.
$ pkill -u john -t pts/3#4 Force kill by pattern
Force kills all PHP queue workers.
$ pkill -9 -f 'php artisan queue:work'#5 Kill child processes
Kills all direct children of process 1234.
$ pkill -P 1234#6 Kill newest instance
Kills only the most recently started Chrome process.
$ pkill -n chromeTips & Best Practices
Test with pgrep first: Before running pkill, test your pattern with pgrep -a pattern to see which processes would match. This prevents accidentally killing wrong processes.
-f matches broadly: pkill -f matches the FULL command line. pkill -f 'python' would match any process with 'python' anywhere in its arguments. Be specific.
pkill vs killall: pkill matches by pattern (partial match by default). killall matches by exact name. pkill supports -f for full command line matching.
Frequently Asked Questions
What is the difference between pkill and killall?
pkill matches process name patterns and supports full command line matching (-f). killall requires exact process names. pkill is more flexible and consistent across systems.
How do I kill a process by command line arguments?
Use pkill -f 'pattern'. For example: pkill -f 'python3 manage.py' kills only the Django manage.py process, not all Python processes.
How do I test which processes pkill would kill?
Use pgrep -a pattern first. pgrep shows matching PIDs and commands without killing anything.
Related Commands
More Process Management Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →