If you are a Windows user and are not used to the GNU/LINUX terminal, or if you are starting out in the world of Tux, you would be surprised at the many things that can be achieved by running commands from there.
Today we introduce you to HTOP, an interactive process viewer for Unix systems. It is a text-mode application (for console or X terminals) and requires ncurses. HTOP is also presented as a natural evolution of TOP (although its developments are totally independent), it has a better organization of information and thanks to its colors, we can easily observe every detail of the processes that are running at that time on our pc.
Installing HTOP in many GNU/LINUX distributions
One of the biggest advantages of HTOP is that it is available through the official repositories for almost all GNU/LINUX distributions: it is only a single command away on the terminal to install it!! Although of course the command is defined by the distribution we are using.
Install HTOP on Debian, Ubuntu and ubuntu-based
Debian, Ubuntu and Ubuntu derivatives use apt as package manager, so the command to run with root privileges is as follows:
apt install htop
Or if the user has permission to use sudo, it can also be used:
sudo apt install htop
Install HTOP on Fedora
Fedora uses the dnf package manager and therefore the command to install HTOP is the following, I remind you that you must have root privileges:
dnf install htop
And after downloading, it will be installed.
Install HTOP on Gentoo
HTOP is also available from the Gentoo package manager called emerge. With root permissions we can use this command to install it:
emerge sys-process/htop
Install HTOP on CentOS 7
CentOS 7 a free alternative to Red Hat Linux Enterprise, the process is a little more complicated than previous distributions but it’s no big deal.
Once logged in as root user, we proceed to download the package containing the EPEL repository:
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Then we must install the downloaded.rpm package that will add the desired repository.
rpm -Uvh epel-release-latest-7.noarch.rpm
Later we verify that the repository is added correctly.
yum repolist
And if EPEL appears in the repository list, we did it correctly and it would already be added.
Now we proceed to install HTOP with the following command:
yum install htop
Now we have HTOP installed in our CentOS 7.
Using HTOP
HTOP as we saw it can be installed on various GNU/LINUX distributions but is also available for Unix and derivatives. For this article we will use HTOP installed on CentOS7.
The command that executes htop is htop 🙂 this command does not need to be executed as root user. Once the command is written and executed, htop will immediately appear in the open terminal session.
exit
htop
This is the screen that is displayed when you run htop. We can notice how it gives us information about CPU or ram memory usage, and the list of all processes running at the moment. However, if we are a little more observant, we will notice that, the HTOP command line interface can be divided into 3 big parts:
- The first shows CPU usage with percentages, RAM and swap memory. On the right side of the header, displays the active tasks and more.
- The second section or main header shows all the active processes of the system.
Each column represents an information or detail, in this header is where most of the HTOP possibilities take place. These are the columns with the information they show:
- PID: Displays the process identifier number.
- User: The user tells us that he has activated this process.
- PRI: It shows the priority with which the process is executed.
- NI: Shows the priority level
- VIRT: The number of virtual memory used by the process.
- RES: Used ram memory (Megabytes)
- SHR: Shared memory used
- S: Process status (Running, sleeping or zombie)
- CPU%: percentage of CPU used by the process
- MEM%: percentage of ram memory used by the process
- TIME+: Active life-time of the process
- Command: The command that executes the process.
As we can see, we have a lot of information available from HTOP.
The last “section” is intended for different actions that HTOP allows us to execute, for example, show help, kill processes, search, sort or exit.
Killing a process with HTOP
Of these options, we usually use more often that of killing a process. To kill a process we must first use the arrow keys to navigate from top to bottom to position ourselves in the process to be killed, then press the F9 key, and then move with the keyboard to option 9:
And by pressing the F5 key we can switch between the sorted or tree-shaped view:
Conclusively, HTOP is a great application executed on the terminal to monitor processes within our Unix-based operating system. Its installation process is quite simple and this is reflected in the large number of GNU/LINUX distributions that have it within their main repositories.
Feel free to share this article on social networks. A lot of people could use it.