Killall – Terminate misbehaving processes by name

There is a time tested way of terminating hung applications or processes in Linux. That is right, you use the kill command. But to do that you need to figure out the process ID of the misbehaving process because the kill command needs the ID of the process you wish to terminate.

Fortunately, there is another easier to use command called killall which allows you to terminate a process by its name. killall is a command line tool which sends a signal to all processes running any of the specified commands. If no signal name is specified, SIGTERM is sent.

The basic syntax of killall command is as follows :

$ killall <name of the process or application>

For example, if the Firefox web browser on my machine suddenly stopped responding, I can forcefully close Firefox as follows :

$ killall firefox

The above command will close all instances of Firefox web browser on my machine.

The following are a few other uses of killall.

Kill only processes of a specified user

# killall -u rkms firefox

-u option specifies the particular user.

Send a particular signal to the process

By default, killall sends the SIGTERM Linux signal to the process. SIGTERM (15) terminates or ends a program operation gracefully. But if you want to send the SIGKILL (9) signal, then you use the -s option as follows :

$ killall -s 9 firefox

Other killall options

The above command can also be run in interactive mode using the -i option.

$ killall -i -s 9 firefox

Get a list of Linux signals using -l option.

$ killall -l
HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM
STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH IO PWR SYS
UNUSED

Though I should say, it gives a cryptic output. You will get a more useful output using the kill -l command.

As an end note, you can use the -r option with killall to use regular expressions. And use -v to get verbose output.

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Related posts: