The htop command is an interactive system-monitoring tool for Linux and Unix-like systems. It’s an alternative to the default command-line tool, top, that comes pre-installed on all Linux distributions.

This article explains how htop is different from the top utility. You’ll see how to install htop on various Linux distributions or build it from the source. And you’ll find out how to more around htop’s interface and perform system monitoring using shortcut keys or your mouse.

htop vs. top

htop has many benefits over the default top program. Here are just a few of them:

htop Installation on Various Linux Distributions

If you just want a recent version of htop, you can find a package for all popular Linux distributions. You can quickly install it using your package manager with one of the following commands:

On Debian

On Ubuntu

On Manjaro/Arch

On CentOS Or RHEL8/7

On Fedora

On OpenSUSE

Alternative Ways to Install htop

Compile htop From the Source Code

htop is an open-source project, so you can get the code and build it yourself to get the latest version with all new features and updates.

htop uses the ncurses library which you’ll need to install, along with its development tools. You can do so for RHEL/CentOS/Fedora based distributions, as follows:

To build htop for a Debian/Ubuntu distribution:

Now download the latest version of htop from its GitHub repository and extract it with the tar command:

Then move into the htop directory and use configure followed by the make command to install/compile htop:

From Snap

Another way to install the latest version of htop is with the third-party package manager snap-store. This is a cross-distribution application management and development system.

For htop installation in Ubuntu via snap, you need to install/enable snapd:

You can find details about htop installation on other Linux Distributions from the official Snap Store website.

Understanding the htop Interface

After installation, run the htop command in a terminal to view the interface shown below:

The htop interface has three main panels. Let’s explore the information displayed in each panel.

The Header

The header splits the top of the interface into left and right sections. These display the CPU/memory usage, swap space, the machine uptime, tasks, and average load.

The top-left section shows one line for each CPU core. For instance, the above screenshot displays two CPU cores, with the percentage representing the load on each.

You can also see the color-coding provided by htop to identify what kind of processes are using the CPU:

Red: percentage occupied by system processes Blue: percentage occupied by low priority process Green: percentage occupied by user processes

The memory lines also use color-coding, this time to represent:

Yellow: percentage occupied by cache content Green: percentage occupied by the used memory Blue: percentage occupied by buffer content

The Mid-Panel

The center panel shows all the running processes with their associated stats based on CPU utilization. It displays the following information for each process:

process ID (PID) the owner (User) virtual memory consumption percentage of processor physical memory

You’ll be familiar with this part of the display if you’ve used the top command.

The last panel demonstrates just a few of htop’s interactive features. It contains all the necessary options to work around the htop graphical interface.

For instance, press F3, and you will notice a space to enter the program name to find its associated process. You can also use your mouse to click on F3 in the footer. Another way to perform a search is to type ‘/’ since htop supports vi-like editing.

Select F2 to enter the settings menu to set meters, change the display options, colors and add/remove columns from the mid-panel.

Here’s how you can move an element of the htop interface within the header. Start by selecting Swap [Bar] using cursor keys, then press Enter or click on Move in the footer:

Then, use the cursor keys to position the field and click on Done to complete the move:

You can also add a new meter to the htop interface. Select any from the Available meters column and click on Add to include it (or Done to cancel).

The F9 key opens an interface listing all options available in the kill -l command to send the kill signal to the selected process. Use the default SIGTERM signal if you are unsure which to use.

htop Keyboard Shortcuts

htop, the Interactive Tool for Linux System Monitoring

The main differences between htop and top are that htop provides a lot more functionality and is easier to use. System monitoring with a keyboard-only, monochromatic interface can be a daunting task. htop provides many features to ease the task of dealing with processes and their resource use.

htop is a great introduction to system monitoring, providing you know the basics of how a Linux system operates. But there are plenty of other tools which allow you to investigate how your system is running.