When too many processes are running on your VPS, especially when using Ubuntu, it can cause your website or application to slow down, so you need to kill Ubuntu processes using htop.
Besides being used to kill processes, htop can also be used to monitor resource usage on your VPS, such as RAM, CPU, Swap Memory, and so on. However, here we will only discuss how to kill processes.
How to Kill Processes in Ubuntu Using htop
There are three options for killing processes. The first is to kill the process directly, the second is using signals, and the third is using the PID.
We will discuss all three in this article. Make sure you are logged into your VPS with root access.
Option 1: Direct Kill Process
For simplicity, we call this a direct kill process because this method is used to immediately terminate a process you select from the htop panel.
First, open htop on your VPS using the following command
sudo htopAfter that, you can choose which process to terminate by using the up or down arrow keys to select the process.
For example, here we will terminate a process with the PID 331847, so make sure the process with this PID is highlighted.
Once the process is selected, you can then press the F9 or Fn+F9 key on your keyboard, and the process will be terminated automatically.
Option 2: Using Signals
For the next option, we can use signals to terminate processes in Ubuntu using htop.
Just like in the first option, you need to open htop, and then you can select which process you want to terminate.
After the process is selected, you can press the k key on your keyboard to choose the signal you want to use.
To terminate a process gracefully, you can press the 3 key on your keyboard, or select the SIGQUIT option in the Send Signalcolumn, then click Enter.
However, if you want to force terminate a process immediately, you can use option number 9 SIGKILL and then press the Enter key.
Now the process you selected has been successfully terminated using htop.
Option 3: Using PID
Unlike the previous three options, terminating a process using the PID does not directly use htop to kill the process. Instead, we only use htop to find the PID of the process we want to terminate.
Open htop via your SSH, then find the process you want to terminate. For example, after opening htop, the process with PID 331844 is using high CPU and we want to terminate it, so we just need to save that PID.
Now exit the htop page by pressing the q key on your keyboard, and you will exit the monitoring screen.
Next, run the command kill PID, or sudo kill PID in your SSH. Since we want to terminate the process with PID 331844, the command used will look like this
kill 331844However, if the process you want to terminate is a root user process, you need to use sudo to terminate that process.
sudo kill 331844Conclusion
That is how to kill processes in Ubuntu using htop. Although there are three different ways, all of them can be used to terminate processes that are consuming too many resources.
It is recommended to double-check the importance of a process before terminating it, especially if it is a Rootuser process, because if you terminate the wrong process, your website or even your VPS might experience issues.
COMMENTS
Loading...