How to Forcibly Kill a Process in Ubuntu Efficiently.
Note: You don’t need to keep restarting your PC to terminate a process.
- Understanding some unix or linux signal terms
- What’s PID
- How to view them and kill.
The kill command is included in Linux and Unix-like operating systems and allows you to terminate blocked or undesirable processes without having to log out or restart the server. As a result, it is critical to the reliability of Linux systems.
The kill command transmits a signal to the given process or process groups, such as KILL process. The TERM signal is issued if no signal is specified. Please keep in mind that the kill command can be found either internally as part of a contemporary shell’s built-in function or outside via/bin/kill. Regardless of whether the kill command is internal or external, the usage and syntax remain the same.
Terms in linux signals
Linux and Unix-like operating system support the standard terminate signals listed
(1) — Hangup detected on controlling terminal or death of controlling process. Use SIGHUP to reload configuration files and open/close log files.
(9) — Kill signal. Use SIGKILL as a last resort to kill process. It will not
save data or cleaning kill the process.
(15) — Termination signal. It is the default and safest way to kill process.
The kill and killall command support more than 60 signals. However, most users only need to use signal 9 or 15. To get a full list of signals,
What is PID?
A Linux or Unix process is a running instance of a program. A chrome, for example, is a running process when you’re exploring the web. The system gives a unique process identification number to the Chrome browser when you launch it . A PID is automatically assigned to a process when it is created on the system. Use the pidof command to find the PID of a chrome or any process: eg. finding the PID of chrome, type:
Using the htop command to view processes and kill them
Htop is a real-time process monitoring tool for Ubuntu operating system. The htop command is similar to top command, but much improved version. Htop is not installed by default on Ubuntu 18, But available from the default Ubuntu software repository. Before using this command, make sure you have it installed: read more https://www.ubuntu18.com/install-htop-ubuntu-18/#:~:text=Htop%20is%20a%20real%2Dtime,command%2C%20but%20much%20improved%20version.&text=Then%2C%20you%20see%20the%20list,every%20Linux%20server%20should%20have.
sudo apt-get install htop
htop open a list of processes, it will show CPU and memory usage along with some other useful statistics.
From there use the arrow keys to select the process you want to kill. Once the process is highlighted, press
f9 to bring up the kill menu, here you'll see all the signals you can send to the process.
Select 9 for kill (by using the arrow keys, or pressing the number key (
9), then hit enter.
q to quit htop.
Ultimately the method you use is up to you,
htop offers a lot of clearly laid-out information and tools to manage processes. You can also use
pkill and others with a little research. If you don't know yet,
man (short for manual) can be used preceding any of these commands, to learn more about them. For example
man kill will explain the use of the kill command and give examples of use.
Please leave a clap if you found this article useful. Thanks!