killall
Kill processes by name
TLDR
Terminate a process using the default SIGTERM (terminate) signal
List available signal names (to be used without the 'SIG' prefix)
Interactively ask for confirmation before termination
Terminate a process using the SIGINT (interrupt) signal, which is the same signal sent by pressing
Force kill a process
SYNOPSIS
killall [-V | --version | -q | --quiet]
killall [-g | --process-group] [-i | --interactive] [-o | --older-than TIME] [-p | --pid PID] [-r | --regexp] [-s | --signal SIGNAL] [-u | --user USER] [-w | --wait] [-y | --younger-than TIME] [-e | --exact] [-l | --list-signals] [-v | --verbose]
process_name [...]
PARAMETERS
-e, --exact
Require an exact match for the process name. No partial matches are allowed.
-g, --process-group
Kill the process group ID to which the process belongs, rather than just the process itself.
-i, --interactive
Interactively confirm before killing processes. Useful for preventing accidental shutdowns.
-o, --older-than TIME
Kill only processes that are older than the specified TIME. TIME can be in minutes, hours, days, weeks, months, or years (e.g., '1h', '2d').
-p, --pid PID
Kill only processes whose process ID (PID) matches the given PID. This option restricts killing to a specific instance.
-q, --quiet
Suppress warnings if no processes are found to be killed. Useful in scripts.
-r, --regexp
Interpret the process name as a POSIX Extended Regular Expression, allowing more flexible pattern matching.
-s, --signal SIGNAL
Send a specified signal (e.g., KILL, TERM, HUP) instead of the default SIGTERM. Signals can be specified by name or number.
-u, --user USER
Kill only processes owned by the specified USER. Can be a username or UID.
-v, --verbose
Report whether the signal was successfully sent to processes. Provides more detailed output.
-w, --wait
Wait for all killed processes to actually die. This is useful in scripts that need to ensure processes are gone before proceeding.
-y, --younger-than TIME
Kill only processes that are younger than the specified TIME. Similar to --older-than.
DESCRIPTION
The killall command on Linux is used to terminate running processes by their name, rather than by their Process ID (PID). It sends a specified signal (by default, SIGTERM) to all processes whose executable name matches the provided argument. This makes it particularly useful for easily shutting down all instances of a specific application or service, for example, all instances of 'firefox' or 'apache'.
Unlike the traditional kill command which requires PIDs, killall simplifies process management by allowing users to target processes directly by their descriptive name. It's an efficient tool for system administrators and users alike to manage multiple instances of processes quickly and effectively.
CAVEATS
The most significant caveat of killall concerns its behavior across different Unix-like systems. On Linux, killall specifically terminates processes by their name. However, on some Solaris and System V Unix systems, killall without any arguments means to kill all processes that the current user has permission to kill, which is a highly destructive and dangerous operation, especially for root. Users should always be aware of the system they are on when using this command.
Additionally, processes might respawn if managed by a system service (e.g., systemd, init, supervisord), so killing them with killall might only be a temporary solution unless the service itself is stopped or reconfigured. Care must be taken to ensure the correct process names are targeted to avoid unintended system instability.
SIGNALS
Processes respond to various signals, and killall by default sends SIGTERM (15), which is a polite request for a process to terminate. Processes can catch and handle SIGTERM, allowing them to perform cleanup before exiting. If a process does not respond to SIGTERM, a more forceful signal like SIGKILL (9) can be sent using -s KILL. SIGKILL cannot be caught or ignored by processes, ensuring termination but preventing any graceful shutdown procedures.
Other common signals include SIGHUP (1), often used to tell daemons to reload their configuration, and SIGINT (2), typically sent by pressing Ctrl+C.
HISTORY
The killall command has a somewhat contentious history due to its differing implementations across various Unix-like operating systems. While the Linux version (part of the psmisc package) is designed to kill processes by name, its System V and Solaris counterparts historically lacked this name-based filtering and instead were designed to kill all processes. This difference led to many system administrators accidentally wiping out entire systems when migrating from Linux to other Unix variants without realizing the distinction.
The Linux implementation was developed to provide a convenient and safer alternative for mass process termination compared to manually finding PIDs with ps and then using kill. Its evolution has focused on providing robust and flexible options for targeted process management.