Introduction
Monitoring system performance is essential for ensuring the stability and efficiency of a Linux server. htop
is a powerful interactive process viewer and system monitor for Linux, offering an enhanced alternative to the traditional top
command.
In this guide, you will learn how to install and use htop
on YUM-based Linux distributions like CentOS, AlmaLinux, CloudLinux, and RHEL. We will also explore its key features, commands, and best practices for system monitoring.
Why Use htop
Instead of top
?
While the top
command is commonly used for monitoring processes, htop
offers several advantages:
User-Friendly Interface – Provides a color-coded, graphical representation of CPU and memory usage.
Scrolling Support – Unlike
top
, htop
allows users to scroll horizontally and vertically. Process Tree View – Displays parent-child process relationships.
Easy Process Management – Allows killing or renicing processes directly from the interface.
Sort Processes Quickly – Supports sorting by CPU, memory, user, or process ID (PID).
Step 1: Install htop
on YUM-Based Systems
Check if htop
is Available in the Repository
Most CentOS, AlmaLinux, and RHEL systems have htop
in their default repositories. To check, run:
yum list available | grep htop
If htop
is listed, proceed with the installation.
Install htop
To install htop
, use the following command:
sudo yum install htop -y
This command will:
- Download and install the latest version of
htop
. - Automatically resolve and install any required dependencies.
After installation, verify that htop
is successfully installed:
htop --version
Step 2: Launch htop
Once installed, start htop
by running:
htop
This will launch an interactive interface displaying real-time system metrics.
Understanding the htop
Interface
When you open htop
, you will see a dashboard similar to this:
CPU[||| 12.3%] Mem[|||| 45.6%] Swap[ 0.0%]
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
1234 root 20 0 400M 50M 5M S 0.5 1.2 00:00:01 nginx
Key Features of htop
CPU & Memory Usage – Graphical bars showing real-time CPU and memory consumption.
Process List – Displays a detailed list of active processes, including:
- PID (Process ID)
- User (Who owns the process)
- CPU & Memory Usage
- Process Status (
S
for sleeping,R
for running, etc.) - Uptime (How long the process has been running)
Sorting & Filtering – Easily sort and filter processes by different criteria.
Tree View – Shows parent-child relationships between processes.
Search Feature – Locate a specific process quickly.
Common htop
Commands
Key | Function |
---|---|
Arrow Keys |
Navigate through processes |
F6 |
Sort processes (CPU, Memory, User, etc.) |
F9 |
Kill a selected process |
F10 |
Exit htop |
q |
Quit htop |
F5 |
Switch to tree view |
F3 |
Search for a process |
F4 |
Filter processes |
F2 |
Open setup/configuration menu |
F7 |
Decrease priority (renice) |
F8 |
Increase priority (renice) |
Step 3: Sorting and Filtering Processes in htop
To sort processes, press F6
and choose from:
- CPU Usage (Shows high CPU-consuming processes at the top)
- Memory Usage
- Process ID (PID)
- User (Owner of the process)
To search for a process, press F3
, type the process name, and press ENTER
.
To filter processes, press F4
, enter a keyword, and filter processes accordingly.
Step 4: Managing Processes in htop
Kill a Process
To terminate a process directly from htop
:
- Use arrow keys to select the process.
- Press
F9
to bring up the kill menu. - Choose a signal number (e.g.,
15
for a graceful stop,9
for force kill). - Press ENTER to confirm.
Change Process Priority (Renice a Process)
To increase or decrease process priority:
- Press
F7
to lower the priority (increase niceness). - Press
F8
to raise the priority (reduce niceness).
This is useful when prioritizing important tasks over background processes.
Step 5: Exiting htop
To exit htop
, press:
F10
orq
to quit.- Alternatively, close the terminal window.
Uninstalling htop
(If Needed)
If you no longer need htop
, remove it with:
sudo yum remove htop -y
This will free up system resources by uninstalling htop
and related dependencies.
Conclusion
The htop
command is an indispensable tool for monitoring and managing system performance interactively. Whether you are a system administrator, developer, or Linux enthusiast, htop
offers real-time insights into system resource usage and process management.
By following this guide, you have learned how to: Install
htop
on YUM-based Linux systems. Launch and navigate the
htop
interface. Sort, filter, and manage processes efficiently.
Kill or adjust process priority when needed.
Uninstall
htop
if no longer required.
For advanced system monitoring, consider exploring htop customization options in the setup menu (F2) or integrating it with system monitoring scripts.
Start using
htop
today to optimize your Linux system’s performance!