kill (terminate a process)

The kill command terminates a process. Call it like this:

kill PID

The argument PID is the process ID of the program you want to terminate. You can display processes' ID numbers by running →ps. kill has a cousin that lets you terminate programs by name. It's called pkill and is invoked like so:


This will kill all processes whose name matches the regular expression PATTERN. For example, pkill fire will kill firefox, firestarter etc. Be careful with this command. Before executing it, you should check which processes match PATTERN by running pgrep -l PATTERN (see the section on →ps).

Saying that kill terminates processes is a simplification. The underlying mechanism is that kill sends signals to processes. By default, kill sends the signal 15, named SIGTERM, which kindly asks a process to terminate itself. There are many more signals. Sometimes a process won't terminate itself on receiving SIGTERM due to a malfunction. In that case, you can send it the signal 9, named SIGKILL, like this:

kill -9 PID

This is a harsh way of terminating a process that deserves the name “killing”. It terminates the process abruptly without giving it the opportunity to do clean-up work, so it should only be used when the process doesn't respond to SIGTERM.

Signals are ubiquitous in Linux. Remember the keyboard shortcuts Ctrl-c (terminate a process) and Ctrl-z (pause a process) from Chapter 1? They send the signals SIGINT and SIGTSTP respectively. If you want to learn more about signals, run →man 7 signal, but note that the important signals have been covered in this section. In 99% of all cases you'll use kill to send SIGTERM (kill's default action) or SIGKILL (kill -9).

The command xkill specializes in killing graphical programs. When you run it, your mouse pointer will turn into a cross hair or skull and crossbones. Click on any window to terminate the underlying application. xkill works differently from kill. It does not send signals but tells the X server, which manages graphical programs, to close the connection to a client program.