Htop is an enhanced version of top command. It displays all processes running on the system by PID plus uptime, load average, memory utilization, and other important statistics. It shows the information in a well-organized manner, which allows the users to find the system matrics easily. In this tutorial, we will look at how we can retrieve the system information with the use of htop command in CentOS8. It works on all Linux distribution and comes up installed by default in most cases.

Htop Installation

To verify if the package is installed or not, open up the terminal and use the following command.

# rpm –q htop

Check if htop is already installed

As shown in the screenshot above, the package not installed. To install the htop package in CentOS 8, open up the terminal and use the following command.

# dnf install –y htop

Install htop with dnf command

After the installation is complete, it’s a time to retrieve the system metrics, for this use the following command.

# htop

Start htop

It will retrieve all the system metrics, as shown below.

Htop command on CentOS

htop command Sections

There are different sections in htop command those sections, are as follows.

  • Header Section
  • Body
  • Footer Section.

Header Section:

The header section shows information about system metrics, which includes CPU, memory utilization, load average, Tasks, Swap utilization, and uptime.

Header section

Body Section:

The body section includes metrics like Process ID’s, user who owns that process, memory utilization, CPU and the time, etc.

process list

Footer Section:

The footer section includes the htop menu section.

htop menu

htop command usage

Now, we can perform several actions with the use of htop command, these actions are as follows, and we will discuss it one by one.

  • Sorting output.
  • List processes in a tree-like format.
  • Filtering processes.
  • Searching a Process.
  • Killing a Process.

Sorting output:

Htop command provides multiple options to sort the output. To sort out the metrics navigate to the column header option according to which you want to sort out and click on that option. In the screenshot attached below, I sorted out according to memory utilization. By default, it uses CPU% for sorting.

Sorting

List Processes in a tree-like format:

To display the process in a hierarchical order, creating a parent-child (inherit) relation. To display the metrics according to the relationship, press the F5 function key. The sample output is attached below.

Tree view

Filtering processes:

We can also filter the processes with the help of htop command, for this press F4 function key. It will prompt you to enter the path to filter the metrics and press enter at the footer section. In the output shown below, I have displayed the process by providing the path /usr/libexec.

Filtering processes

Searching a process:

We can also search the process with the help of htop command, for this use the F3 function key and enter the process name you want to search. It will highlight that specific process, i searched the libexec process gsd-color. The image attached below used for the reference.

Search for a process

Killing a process:

To kill any process with the htop command, use the F9 function key or the letter K. I have selected the signal and press enter, it will kill the process. Kill a process using htop

Getting help:

To get further assistance, use the F1 function key. A list of options will appear in front of you, as shown below.

Htop help

Conclusion

In this tutorial, we learned the use of htop command in CentOS 8. We saw how to kill the process, sorting the processes, searching the specific process, filtering the process, and display the process according to a parent-child relationship. I hope this tutorial will help you with a better understanding of htop command.

How to use htop to monitor system processes in CentOS 8
Avatar

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn