What is htop and How to Use It
This article provides an overview of htop, an interactive, real-time
system monitor and process viewer designed for Unix-like operating
systems. You will learn what htop is, how it improves upon the
traditional top command, its key features, and how to use
it to monitor and manage system resources like CPU, memory, and running
processes.
Understanding htop
Historically, Unix and Linux systems have used the top
command-line utility to monitor system resources. While functional,
top provides a basic, text-heavy interface that can be
difficult to navigate.
Developed as an advanced alternative, htop is an
interactive, text-mode process viewer. It displays a frequently updated
list of the processes running on a computer, normally ordered by the
amount of CPU usage. Unlike top, htop provides a full list
of processes running, instead of just the top resource-consuming ones.
For detailed configuration options and advanced usage, you can consult
the htop command line tool
documentation.
Key Features of htop
- Visual Resource Bars: At the top of the htop interface, you get a color-coded, graphical representation of CPU usage (for individual cores), memory usage, and swap space. This makes it easy to diagnose resource bottlenecks at a glance.
- Interactive Controls: Users can scroll vertically to view the complete process list and horizontally to see full command lines.
- Easy Process Management: You can kill, stop, or change the priority (renice) of processes directly from the interface using keyboard shortcuts, without needing to manually type the Process ID (PID).
- Mouse Support: htop supports mouse clicks, allowing you to select processes, sort columns, and click menu buttons at the bottom of the screen.
- Tree View: By pressing
F5, you can view processes in a parent-child hierarchical tree, making it easy to see which application spawned a specific background process.
How to Install and Run htop
htop is not always pre-installed by default, but it is available in the official repositories of almost all Linux distributions.
To install htop on Debian/Ubuntu-based systems, run:
sudo apt update && sudo apt install htopTo install htop on RHEL/CentOS/Fedora systems, run:
sudo dnf install htopOnce installed, simply type htop in your terminal to
launch the interface.
Essential Keyboard Shortcuts
Once htop is running, you can navigate and control your system using these primary shortcuts:
- F3 or /: Search for a specific process by name.
- F4: Filter the process list to show only matching processes.
- F5: Toggle between the sorted list view and the hierarchical tree view.
- F6: Sort processes by columns such as CPU%, MEM%, PID, or User.
- F9: Kill a selected process by sending a signal (like SIGKILL or SIGTERM).
- F10 or q: Quit the htop interface.