pkill(1)
Send signals to processes by name or other attributes instead of by process ID.
Synopsis
pkill [OPTION]... PATTERNDescription
pkill sends a signal (default: SIGTERM) to all processes matching the given criteria. It's a convenient alternative to ps + grep + kill when you want to target processes by name, user, or other attributes without knowing their exact PID.
The PATTERN argument is treated as an extended regular expression by default. pkill matches against the process name (the command name as shown in ps output), but can also match against full command lines, usernames, and other process attributes using various options.
Related command pgrep displays matching process IDs instead of signaling them, useful for seeing what would be affected before running pkill.
Common options
| Flag | What it does |
|---|---|
-signal | Specify signal to send (SIGTERM by default); use number (9, 15) or name (KILL, TERM) |
-f | Match against full command line instead of just process name |
-u USERNAME | Only match processes owned by the specified user |
-U USERNAME | Only match processes with real UID of specified user |
-g PGID | Only match processes in the specified process group ID |
-P PID | Only match processes with specified parent process ID |
-l | List matching process names and IDs instead of sending signal |
-a | Display full command line of matching processes with -l |
-x | Require exact match of process name (whole word only) |
-n | Select only the newest matching process |
-o | Select only the oldest matching process |
-c | Count matching processes; useful to verify before killing |
Examples
Forcefully kill all Firefox processes (SIGKILL signal)
pkill -9 firefoxTerminate all sshd processes owned by user 'john'
pkill -u john sshdList all Python processes matching 'myapp' in their command line
pkill -l 'python.*myapp'Kill Node.js processes running server.js by matching full command
pkill -f 'node.*server.js'Count how many nginx processes would be matched (useful verification)
pkill -c nginxKill only the newest Java process, leaving others running
pkill -n javaPause (SIGSTOP) all child processes of PID 1234
pkill -SIGSTOP -P 1234Kill apache2 processes owned by 'nobody' user with exact name match
pkill -x -u nobody apache2