How to Install and Use Htop on a Linux Server
htop is a monitoring tool that shows, in real time, the processes running on your server and how much CPU and memory they use. When your server slows down, it is one of the easiest ways to find which process is using the resources.
Installation
Debian and Ubuntu
htop is in the Debian and Ubuntu package repositories:
apt update && apt install htop
AlmaLinux and Rocky Linux
On these systems htop is installed from the EPEL repository. Some EPEL packages need the CRB repository (PowerTools on version 8), so that repository is enabled first. Run the lines for your version.
Version 10:
dnf config-manager --set-enabled crb
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm
Version 9:
dnf config-manager --set-enabled crb
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Version 8:
dnf config-manager --set-enabled powertools
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Then install htop:
dnf install htop
Usage
htop
The top of the screen shows the usage of CPU cores, memory and swap, the load average and the uptime. Running processes are listed below.
| Key | What it does |
|---|---|
| F1 | Help screen |
| F3 | Search processes |
| F4 | Filter by the name you type |
| F5 | Tree view (which process started which) |
| F6 | Choose the sort column (for example CPU or memory usage) |
| F9 | Send a signal to the selected process (end the process) |
| F10 | Quit |
Before ending a process with F9, make sure you know what it is; ending a service such as the database or web server can take your websites down.
The information in this guide is taken from official documentation: htop(1), EPEL: Getting started, Fedora Packages: htop.