LinuxCommandLibrary

killall

Kill processes by name

TLDR

Terminate a process using the default SIGTERM (terminate) signal

$ killall [process_name]
copy

List available signal names (to be used without the 'SIG' prefix)
$ killall [[-l|--list]]
copy

Interactively ask for confirmation before termination
$ killall [[-i|--interactive]] [process_name]
copy

Terminate a process using the SIGINT (interrupt) signal, which is the same signal sent by pressing
$ killall -INT [process_name]
copy

Force kill a process
$ killall -KILL [process_name]
copy

SYNOPSIS

killall [options] process_name...

PARAMETERS

-e
    Require an exact match for very long names. If a command name is longer than 15 characters, the full name may not be available (i.e. the default matching is on the first 15 characters).

-I
    Ask for confirmation before killing processes.

-g
    Kill the process group to which the process belongs.

-i
    Interactive: Ask for confirmation before killing each process.

-l
    List all known signal names. These can be used with the -s option.

-q
    Do not report if no processes were killed.

-r
    Interpret the process name as an extended regular expression.

-s signal_name
    Send the specified signal instead of SIGTERM. The signal can be specified by name (e.g., SIGHUP) or by number (e.g., 1).

-u user
    Kill only processes owned by the specified user(s).

-v
    Report if no processes were killed.

-V
    Display version information.

--version
    Display version information and exit.

-w
    Wait for all killed processes to die. killall waits for all processes to die. It returns successfully only if all processes die or if killall itself is killed. Note that killall may wait forever if the signal was ignored, the process was blocked, or the process takes forever to die.

--help
    Display help text and exit.

-n
    Only show a report of what will be killed.

-Z context
    Kill only processes having the specified SELinux security context.

DESCRIPTION

The killall command is a utility used to send a signal to processes based on their name. It's a powerful tool for terminating processes that might not be easily identifiable by their PID (Process ID). Unlike the kill command, which requires a PID, killall allows you to specify a process name directly.

By default, killall sends the SIGTERM (signal 15) signal, which requests the process to terminate gracefully. If the process doesn't terminate after a reasonable time, you can use the -9 option to send the SIGKILL (signal 9) signal, which forces immediate termination.

killall is especially useful for terminating multiple instances of the same program, or for targeting specific programs without needing to manually find their PIDs. The command provides functionalities like case-insensitive name matching and can be instructed to only kill processes owned by specified users.

CAVEATS

Using killall with a short or common process name can unintentionally terminate processes you didn't intend to kill. Always double-check the process name before executing the command, especially when using SIGKILL (-9).

SIGNAL HANDLING

When you use killall, you're essentially sending signals to processes. The default signal (SIGTERM) gives the process a chance to clean up before exiting. However, SIGKILL bypasses any cleanup, potentially leading to data loss or corruption. Use SIGKILL only as a last resort.

USER PRIVILEGES

You typically need root privileges (using sudo) to kill processes owned by other users. Without sufficient privileges, you can only kill processes owned by your own user account.

HISTORY

The killall command has been a part of various Unix-like operating systems for a long time. It was designed to provide a more user-friendly way to terminate processes compared to using PIDs directly with the kill command. Over time, it has been enhanced with additional features and options to provide more control over process termination.

SEE ALSO

kill(1), pkill(1), ps(1), top(1)

Copied to clipboard