Killing Linux Programs Using Terminal Commands.
Nowadays, Linux applications perform admirably well. With newer and better programs offering exceptional features, computer users can leverage their machines to the fullest. However, it is not uncommon to experience program crashes. On such occasions, clicking the close button on your favorite Linux app won't cut it. These lockups can be quite frustrating, disrupting your workflow significantly. That's why we've put together this article to show you the various ways you can swiftly terminate misbehaving programs using the Terminal interface on Linux. We'll explore multiple command options and highlight some helpful graphical user interface (GUI) tools.
Beware of spoilers: before diving in, check out our video tutorial at the end of this article by clicking on the link provided.
Using pkill
The easiest and most efficient way to end hanged programs from your Linux Terminal is to use the pkill command. Pkill is an excellent option because it does not require you to know the process ID number (PID) of the program. Instead, all you need to do is type in the name of the program you want to terminate, and pkill takes care of the rest. Here's an example:
- pkill firefox

For most users, this command is sufficient to stop unresponsive programs. However, some instances may require you to use stronger commands. For example, if you want to kill a program running as the root user or its specific user, you need to attach 'sudo' to it. If even that is not enough, then you can use "-9." Adding "-9" on the end of a pkill statement usually does the trick when all other options fail. Here's an example:
sudo pkill -9 rootprogram
Using Pidof & Kill
When the pkill command fails, you can use another handy command called 'kill.' Kill works similarly to pkill, except that it kills programs based on their ID numbers rather than their names. The downside of using kill is that you first need to find out the PID of the problematic program before using the command. You can retrieve the PID by using the 'pidof' command. Here's how it works:
- pidof firefox

Once the PID appears in the terminal, copy it and paste it into the 'kill' statement. Keep in mind that if you're trying to kill a root program, you'll need to use the 'sudo' command too. If the program still refuses to stop, use "-9" again. Here's an example:
sudo kill -9 2219
Kill Programs with Htop
If you don't want to kill programs one by one using individual commands in the Terminal, consider installing HTOP. This tool is available both locally and over SSH. Since it runs within the Terminal interface, it is still ideal when terminating unresponsive apps. HTOP is a superior replacement for the TOP system management tool found on many Linux systems. It boasts multiple enhancements, including graphics that make it easy to read CPU/RAM usage and identify processes.

HTOP boasts many features, including horizontal/vertical scrolling without disrupting the tool and the ability to terminate any process without requiring knowledge of its process ID. It also presents various modes to kill processes.
It is important to note that Ncurses is essential for HTOP to function appropriately. Find and install "ncurses" in your Linux distribution's package management tool if HTOP does not install it for you.
Installation of HTOP
To install HTOP, use the commands below based on your Linux distribution:
- Ubuntu
- sudo apt install htop
- Debian
- sudo apt-get install htop
- Arch Linux
- sudo pacman -S htop
- Fedora
- sudo dnf install htop
- OpenSUSE
- sudo zypper install htop
- Other Linuxes
Download the latest HTOP version for your Linux distribution by accessing a terminal and using the package management tool to install "htop." If it is unavailable, consider navigating to the official website, downloading the source code, and constructing it yourself!
Using HTOP
To launch HTOP, open a terminal window and input "htop." Alternatively, search for "htop" in the application menu, and it should also appear in the "system" or comparable category.
Once HTOP is running, use the arrow keys to pick the process you want to manage. Press F9 to expose the "Kill" menu, sort procedures with F6, and search for running applications with F3. Press F1 on your keyboard for assistance in operating the HTOP tool or enter "man htop" in the terminal.
Lastly, to quit the HTOP tool entirely, press the Q or F10 button. It is necessary to acknowledge that forcibly shutting down software from the Terminal might result in the loss of your work. While tabs in a browser can recover, other programs will rely on their own built-in recovery tools. If such is not available, you may lose some data.
-
10th Grade Science: Life Processes with Complimentary Ncert Solutions 2023-07-25 00:51:45
Solution: The inner lining of the small intestine undergoes a structural modification, forming villi, which are finger-like projections. These villi serve to increase the surface area for the absorption of digested food. Furthermore, they have a high vascularity, meaning they are well-supplied
-
Creating a Lovely and Simple Homemade Rakhi 2023-07-25 00:50:08
Creating Your Own Homemade RakhiThe glimmer in your eyes and the fervent desires in your heart paint a clear picture: you're filled with ideas for surprising your loved ones on Raksha Bandhan! Are you aware of what that entails? It means that Raksha Bandhan is fast approaching, leaving us with limited
-
10th Grade Science Life Processes: Access Ncert Solutions for Free 2023-07-25 00:03:33
Solution: The inner lining of the small intestine undergoes a transformation into tiny finger-like projections known as villi that enhance the surface area for the absorption of digested food. These villi are abundantly supplied with blood vessels, making them highly vascularized. Additionally,
-
10 Years - Information on Wikipedia 2023-07-24 02:56:26
A decade, which comes from the Ancient Greek word δεκάς (dekas) meaning 'a group of ten', is a span of ten years. Decades can refer to any period of ten years, whether it is someone's lifespan or a specific grouping of calendar years.Usage:Any period of ten years is considered a "decade". For