pkill
Quick Reference
Command Name:
pkill
Category:
process management
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
Syntax
pkill [options] pattern
Options
Option | Description |
---|---|
-signal, --signal signal | Define the signal to send (default: TERM) |
-e, --echo | Display what is killed |
-c, --count | Count of matching processes (instead of signaling) |
-f, --full | Match against full command line |
-g, --pgroup pgrp | Match listed process group IDs |
-G, --group gid | Match real group IDs |
-i, --ignore-case | Case insensitive matching |
-n, --newest | Select most recently started process |
-o, --oldest | Select least recently started process |
-P, --parent ppid | Match only child processes of the given parent PID |
-s, --session sid | Match session IDs |
-t, --terminal term | Match by controlling terminal |
-u, --euid euid | Match by effective user ID |
-U, --uid uid | Match by real user ID |
-v, --inverse | Invert the matching (select processes NOT matching the criteria) |
-x, --exact | Match exactly with the command name |
Examples
How to Use These Examples
The examples below show common ways to use the pkill
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Usage:
pkill firefox
Send the default TERM signal to all processes with "firefox" in their name.
pkill -9 chrome
Send the KILL signal (9) to forcefully terminate all processes with "chrome" in their name.
pkill -HUP nginx
Send the HUP signal to all processes with "nginx" in their name to reload configurations.
Pattern Matching:
pkill -f "python script.py"
Match against the full command line, not just the process name.
pkill -x firefox
Match exactly "firefox", not processes containing "firefox".
Process Filtering:
pkill -u username firefox
Kill only firefox processes owned by the specified user.