The killall
command in Bash is used to terminate processes by their name. Unlike the kill
command, which requires a process ID (PID), killall
allows you to specify the name of the process you want to stop, making it easier to manage multiple instances of the same application.
The basic syntax of the killall
command is as follows:
killall [options] [arguments]
-u <user>
: Only kill processes owned by the specified user.-i
: Prompt for confirmation before killing each process.-q
: Suppress error messages for processes that do not exist.-r
: Use regular expressions to match process names.-s <signal>
: Specify a signal to send to the processes (default is TERM
).Here are some practical examples of using the killall
command:
killall firefox
killall -u username
killall -i chrome
killall -r 'python.*'
killall -s KILL apache2
killall
, as it will terminate all matching processes without confirmation (unless the -i
option is used).-q
option to avoid cluttering your terminal with error messages if some processes are not found.pgrep
in combination with killall
for more complex process management tasks, such as filtering processes based on additional criteria.