Install htop in Ubuntu, Debian, CentOS, Fedora

How to Install htop in Ubuntu, Debian, CentOS, Fedora

You can install htop from default repositories of most Linux distributions such as Ubuntu, Debian, CentOS, and Fedora simply through a Linux terminal and using Linux distribution specific package managers.

The htop is a powerful real-time system monitoring tool that offers a dynamic and interactive view of running processes and your server resource usage with detailed information for optimizing resource management.

Install htop on Linux using package managers (Quick way)

Installing htop, a user-friendly, powerful, customizable, and interactive process viewer tool, is an efficient way to manage and monitor your Linux VPS after buying.

Therefore any Linux system administrator needs htop to have essential insights into system performance and ensure optimal and smooth server operation.

Fortunately, most Linux distribution repositories include htop by default. You can install htop in Ubuntu, Debian, CentOS, and Fedora using common package managers. Access your Linux server, open the terminal (by pressing Ctrl+Alt+T ), and follow the below steps with Root or sudo access and a stable internet connection to install htop on Ubuntu, Debian, CentOS, Fedora:

1. Update your system package list:

Start the htop installation process in various Linux distributions by updating your system package list which is an essential step:

  • For Debian-based systems (Ubuntu, Debian, Linux Mint, etc) :

sudo apt update
  • For CentOS/RHEL :

sudo yum update
  • For Fedora:

sudo dnf update
sudo pacman -Sy
  • For openSUSE:

sudo zypper refresh

2. Install htop in different Linux Distros

  • Install htop in Debian-based systems (Ubuntu, Debian, Linux Mint, etc):

For Debian-based systems including Ubuntu and Debian, install htop tool using the apt package manager with the following commands:

sudo apt install htop
  • Install htop in CentOS/ RHEL:

For Red Hat-based systems including CentOS (on CentOS/RHEL 7), htop tool is available in the EPEL (Extra Packages for Enterprise Linux) repository, therefore first you must enable the EPEL repository using the following command:

sudo yum install epel-release

Then you can install htop on CentOS/ RHEL systems using yum package manager:

sudo yum install htop
  • Install htop in Fedora:

For Fedora systems, install htop using dnf package manager by running the following command:

sudo dnf install htop
  • Install htop in Arch Linux and Manjaro:

Use the pacman command to install htop in Arch Linux and Manjaro:

sudo pacman -S htop
  • Install htop in openSUSE:

Use Zypper package manager to install htop in openSUSE:

sudo zypper install htop

3. Verify the htop installation on Linux:

Verify htop installation on Linux distros such as Ubuntu, Debian, CentOS, Fedora, and Arch Linux, using the following commands:

htop --version

Or

htop -v

Returning the version number of htop in the terminal indicates that htop is installed on your Linux system successfully.

If you get an error or do not receive any outputs, it means there is a problem with htop installation.

4. Update htop on Linux:

After installing htop on Linux distributions, updating htop to the latest version is good practice to benefit most recent features and bug fixes. Therefore, update htop to the latest version with:

  • In Debian-based Distributions:

sudo apt update
sudo apt upgrade htop
  • In CentOS/ RHEL:

sudo yum update htop
  • In Fedora:

sudo dnf upgrade htop
  • In Arch Linux and Manjaro:

sudo pacman -Syu htop
  • In openSUSE:

sudo zypper refresh
sudo zypper update htop

The htop tool should be installed on your Linux system successfully to monitor your Linux system optimally.

Install htop on Linux Distributions from the source

If you require the latest version of htop to benefit from the latest features while it is not available in your distribution’s repositories, you can install htop from the source through the below steps:

1. Install necessary dependencies and build tools:

  • For Debian/ Ubuntu:
sudo apt install build-essential libncursesw5-dev libncurses5-dev
  • For Red Hat/CentOS:
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-devel

2. Download the latest release of htop from the official website or GitHub using wget command in Linux:

wget https://github.com/hishamhm/htop/archive/refs/tags/3.1.2.tar.gz

3. Extract the tarball and navigate to the directory using the following command:

tar -xvf 3.1.2.tar.gz
cd htop-3.1.2

4. Compile and install the latest version of htop with:

./configure
make
sudo make install

So you have successfully installed the latest version of htop on your Linux system.

Install a specific version of htop on Linux

Through previous methods you have installed the latest version, however, you can install a specific or older version of htop on different Linux distributions based on your requirements. But how?

Here are steps to install specific versions of htop on Ubuntu, Debian, CentOS, Fedora, Manjaro, and openSUSE:

  • Using package manager

In Debian-based systems, first, you must find the PPA that supports your specific version of htop by looking for community repositories and add the appropriate PPA to your Debian-based system by running the following command:

sudo add-apt-repository ppa:example/ppa-name

Then install your desired htop version in Debian-based using:

sudo apt install htop=<version>

For RPM-based systems including CentOS and Fedora, to install a specific version of htop, first check available versions in your package manager’s repositories with:

yum info htop

Now, you can install your desired version of htop using the following command:

sudo yum install htop-<version>
  • Installing htop from source code

If your desired version is not available in your package manager, alternatively you can install a specific version of htop from the source using the following command:

wget https://github.com/hishamhm/htop/archive/refs/tags/<version>.tar.gz

Replace your desired version with <version> in the previous command.

Then, configure, compile, and install your desired version of htop by running the following command:

./configure
make
sudo make install

You are done and successfully have installed your specific version of htop.  Using these methods depends on your specific requirements and the availability of the desired version in the archive.

However, using package managers for htop installation on a Linux server is the most straightforward method because installing htop from source requires more technical knowledge and might be more complex.

How to use htop on Linux VPS?

Now you have equipped your Linux system with a powerful process monitoring tool, it is time to benefit from htop features by starting the htop tool by running the below command and pressing Enter:

htop

Sample output:

# 1  [||||||||||||||||||||||||||||100.0%]     Tasks: 31, 59 thr; 1 running
# 2  [||||||||||||||||||||||||||||100.0%]     Load average: 0.02 0.04 0.05
# Mem[|||||||||||||||||||387M/1.94G]     Uptime: 00:03:46
# Swp[|0K/2.00G]

#  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
# 2955 root       20   0  1269M  387M 26916 S  0.0 19.4  0:02.90 /usr/lib/packagekit/packagekitd
# 3016 root       20   0  185M  111M  8432 S  0.0  5.5  0:01.10 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
# 1447 root       20   0  404M  101M  6068 S  0.0  5.0  0:00.73 /usr/sbin/NetworkManager --no-daemon

As you see htop shows the key information in two main sections. The top section returns a summary of overall system resources such as CPU, memory, swap usage, and load average (as a percentage and a bar graph). The bottom section lists total running processes with their PID, user, CPU usage, memory usage, virtual memory, resident memory, shared memory, status, and command.

As a result, htop provides you with overall real-time insights into your Linux system performance.

The htop provides an interactive interface, allowing easy navigation of the process list and killing or managing processes using function keys. To get a better understanding of htop function take a look at the htop keyboard shortcut keys and discover htop features:

Keyboard Shortcut KeysFunction
Arrow KeysScroll up, down, right and left through the list of processes.
HomeNavigates to the top of the processes list and highlights the first process.
EndNavigates to the bottom of the processes list and highlights the last process.
Ctrl+LReloads the screen.
/[name of the process]Searchs for a specific process by name.
SpacebarForces process to run or stop.
F1Opens the help menu and gives more details about htop features.
F2Allows to customize htop's output (columns, colors, etc).
F3Filters processes using the name.
F4Sorts the processes based on specific criteria like CPU or memory usage.
F5Displays or hides tree default view of processes.
F6Sorts columns by default.
F8Changes process priority.
F9Kills a chosen process.
F10 or QQuit htop.
MSorts process only based on memory usage.
PSorts process only based on Processor usage.
TSorts process only based on time.
uLists processes belonging to a specific user.
pDisplays path to running program.

Basic syntax of htop command

The  main syntax of htop is as follows:

htop [options]

htop command options

The htop does not have vast options, here are some common :

  • –no-color, -C: Disables highlighting output with color./ Disables color-coded output.
  • –tree,-t: Shows tree view of processes.
  • –user =USERNAME,-u: Shows the processes owned by the specific user.
  • –pid=PID, -p: Lists processes for only specific PIDs.
  • –help: Provides more information about htop.

 What is the Importance of htop for process management?

The htop is a valuable tool for Linux process management by offering a user-friendly interface and a real-time, interactive view of system processes.

Every running program or service on the system is a system process that has a unique process ID (PID). Optimally managing system processes is one of the important administration tasks that affect Linux system performance, stability, and security.

the user-friendly interface of htop provides you dynamic and understandable format to monitor and track CPU, memory, and swap usage, allowing you to identify resource-intensive processes or suspicious activity, kill problematic processes, analyze every process resource consumption, optimally allocate resources to different applications or services, and monitor system health and troubleshoot potential issues.

Using htop you can maintain a healthy and efficient Linux server by managing processes behavior and resource utilization.

How to troubleshoot htop common errors on Linux?

You might encounter some errors related to htop when using it on a Linux system, here are the solutions to fix these potential htop problems:

‘htop’ Command Not Found Error: this error indicates that htop is not installed on your Linux system and to solve it you must check whether htop is installed on your Linux system or not by running “htop –version” command; if it is not installed yet, install htop on your Linux system through htop installation steps that are provided in this article.

Permission Denied Error: this error indicates you do not have sufficient permissions to install htop on your Linux system and to fix this error, you must run the htop installation command with the “sudo” privilege. (e.g. use the sudo apt install htop command to install htop on a Debian-based system. )

Unable to Locate Package Error: This error means your system can not locate htop packages in your distribution’s repositories which will be resolved by updating the list of packages and the Linux system.

How to uninstall htop on Linux?

Whenever you no longer need htop on your Linux server, you can uninstall it on various Linux distributions using common package managers.  Use the below commands to uninstall htop on Linux distros:

sudo apt remove htop                            # Debian/Ubuntu
sudo yum remove htop                          # CentOS
sudo dnf remove htop                            # Fedora
sudo pacman -R htop                              # Arch Linux
sudo zypper remove htop                      # openSUSE

If you have installed htop from the source, you can manually remove the htop files and packages to uninstall htop.

What is the difference between top and htop in Linux?

htop is a more modern and feature-rich alternative to top as a system processes monitoring tool. The htop provides a user-friendly and interactive interface and more details such as the user who owned the process, the command used to run the process, and the start time of the process.

Overall, htop offers a more comprehensive and straightforward process management experience compared to the traditional top command.

Conclusion

Real-time monitoring and managing system processes on your Linux server is crucial for troubleshooting and optimizing performance. Installing htop in Linux popular distributions provides detailed insight into your Linux system performance and allows you interactive controls over your Linux system processes.

Although there are various monitoring tools for Linux systems such as top and ps commands, however, if you are looking for an efficient and powerful monitoring tool, htop is the best option.

we hope by mastering htop and understanding its function, you can manage your Linux server effectively and optimize your Linux VPS performance.

Leave a Reply

Your email address will not be published. Required fields are marked.