Htop is an interactive and dynamic application for real-time process monitoring on Linux/Unix systems, being the alternative to the familiar top command, pre-installed on most Linux distributions.
Htop has several funtions and features that are not available with the top command:
• The htop can be scrolled vertically to view all processes, but also horizontally for full view of the control panel lines;
• it starts much faster than the top because it does not wait to take the data before launch;
• in htop multiple processes can be closed at the same time, without introducing their PID (identification number);
• it may change the priority of a process without entering its (re-nice) number;
• you can press “e” to print a set of variables for a process;
• you can use the mouse to select processes from the list.
Htop has now reached version 2.2.0, which comes with several improvements.
I will discuss htop by giving as an example a VPS server from ours at MVPS.net. Obviously first you have to connect through ssh to the server.
How to install Htop in Ubuntu and Debian
By installing Htop from the Ubuntu software warehouse, you will have version 2.1.3:
sudo apt-get install htop
But as we want to have version 2.2.0, freshly released, we will use the following commands:
$ sudo apt-get install build-essential
$ sudo apt-get install libncurses5-dev libncursesw5-dev
$ wget http://hisham.hm/htop/releases/2.2.0/htop-2.2.0.tar.gz
$ tar xvfvz htop-2.2.0.tar.gz
$ cd htop-2.2.0
Follow the compile and make commands to compile and install htop:
# sudo make install
The server may need a restart (it did not run the command until I restarted the server).
To see which version we have installed, run the htop command with the -v option:
$ htop -v
htop 2.2.0 – (C) 2004-2018 Hisham Muhammad
Released under the GNU GPL.
How to use the htop command
Running the htop command:
Htop has 3 important sections:
1. Header, where we can see CPU, Memory and Swap information; Also, here are the number of tasks, the average server load time and the time it runs (up-time);
2. List of processes ordered after using the processor;
3. The Footer has different shortcuts, such as help, setup, search, filter, sort by, nice, kill, quit.
Press F2 or S for the Setup menu.
Press F5 or T to view the processes in a tree structure.
Nice (F7 Priority Raise, F8 for Priority Decrease) – Select a process and press one of the two keys (F7 or F8), each press increasing or decreasing the priority by one unit. Maximum priority is -20, minimum 19.
Kill (F9) – To kill a selected process, press F9 or k
If you press F1 for help, you will find other keys that can be pressed instead of the function keys.