1. Home
  2. Linux

How To Kill Programs From The Terminal In Linux

Linux apps run pretty well these days. Newer, better programs with excellent features that help us get the most out of our computers come out every day. Unfortunately, sometimes, these programs stop working. When your favorite Linux program locks up, clicking the close-button doesn’t work. Lockups are the worst and cause tons of problems that can get in the way of your workflow. That’s why in this article, we’ll be going over all the best ways to quickly kill programs from the Terminal in Linux.  We’ll go over multiple commands, as well as some useful GUI tools to use as well.

Using Pkill

By far the easiest way to quickly kill programs from the Terminal in Linux is with the pkill command. Pkill is useful because it doesn’t require that the average user know the specific PID (process ID number). Instead, you’ll be able to end a process by just typing the name. Here’s an example of pkill in action.

pkill firefox

For most users, running a non-root pkill command will be enough to end a stubborn, frozen program. It isn’t always the case though, and sometimes you’ll need to flex some muscles. For example, if you’d like to kill a program that is running as the root user, or it’s own user, you’ll need to attach sudo to it.

sudo kill rootprogram

Still, even by using the pkill tool to end the root program may not be enough. Sometimes, an application works in such a way that a simple kill command isn’t going to help. When this happens, you can use -9. Adding -9 on the end of pkill will usually end the program by force when all other options fail.

sudo pkill -9 rootprogram

Using Pidof And kill

When the Pkill command fails, there’s another excellent alternative: kill. Kill functions about the same way as pkill, except it works based on process ID numbers, rather than just the name of the program (like pkill firefox, etc.). The downside to killing programs with the kill command is that you’ll need first to discover what the problematic program’s PID is before using the kill command. The way to do this is by using the pidof command. Here’s how it works.

pidof firefox

After pidof completes its search for the correct ID, you’ll see the output in the terminal. For example:

pidof firefox

OUTPUT: 2219

We can then take the 2219 PID and use it to kill Firefox.

kill 2219

Keep in mind that if you’re looking to kill a root program, you’ll need to do:

sudo kill 2219

Lastly, if an application refuses to stop, try using -9. It works similarly to pkill.

sudo kill -9 2219

Kill Programs With Htop

Don’t want to use individual commands to kill unresponsive programs on Linux? Consider installing HTOP. Like Pkill and Kill, it’s still possible to use this tool over SSH and remotely. Since it runs in a terminal, it’s still beneficial when killing programs. Htop is an improved version of the TOP system management tool included on most Linux systems. It has a lot of enhancements, such as graphics for better reading of CPU/RAM usage, and processes.

HTOP has other improvements like allowing the user to scroll as much horizontally/vertically without fear of interrupting the tool. It also lets users kill any process they want without needing to know the process ID and shows several different ways to kill things.

Note: HTOP requires Ncurses to function correctly. Install “ncurses” by searching in your Linux distribution’s package management tool (if htop doesn’t install it for you).

Install HTOP


sudo apt install htop


sudo apt-get install htop

Arch Linux

sudo pacman -S htop


sudo dnf install  htop


sudo zypper install htop

Other Linuxes

Grab the latest version of Htop for your Linux distribution by opening up a terminal and using the package management tool to install “htop.” If you can’t find it (for some reason), consider visiting the official website, downloading the source code and building it yourself!

Using HTOP

Launch the HTOP tool at any time by opening a terminal window, and entering the command “htop.” Alternatively, the HTOP tool can be run at any time by simply searching for “htop” in the application menu. There should also be a shortcut for it under “system” or something similar.

When HTOP is open, use the arrow key to select a process you’d like to manage. Press F9 to open the “Kill” menu. Sort processes with F6, and search for running programs with F3. Need help using the HTOP tool? Press the F1 button on your keyboard to bring up the help menu. Entering “man htop” in the terminal also works.

Lastly, to exit the HTOP tool entirely, just press the Q button on the keyboard. Using the F10 button also works to quit.

We should mention that if you force kill programs from the Terminal, there’s a chance you might lose your work. With a browser, you can probably recover tabs but for other programs you will have to rely on their own built-in recovery mechanisms. If there aren’t any, it’s possible you might lose some data.

Leave a comment