How do you use the Linux htop command?
This article provides a comprehensive guide to understanding and using htop, an interactive system-monitor process-viewer for Linux systems. We will explore what makes this tool essential for system administrators, how to install it across different distributions, the layout of its colorful interface, and the basic keyboard shortcuts needed to effectively manage system resources.
Understanding the htop Utility
The htop command is a popular alternative to the classic
top utility. It provides a dynamic, real-time view of a
running system, displaying vital metrics such as CPU usage, memory
consumption, swap usage, and a detailed list of active processes. Unlike
its predecessor, htop features a colorful, visually
intuitive interface that supports mouse interaction and allows users to
scroll vertically and horizontally to view all running processes
alongside their full command lines. For a deeper dive and additional
documentation, you can explore this htop resource to expand your
knowledge.
Installing the Software
Because it is so widely used, htop is available in the
default repositories of almost all major Linux distributions. You can
install it using your system’s package manager. For Debian or
Ubuntu-based systems, use sudo apt install htop. On Fedora
or RHEL-based systems, the command is
sudo dnf install htop. Arch Linux users can install it via
sudo pacman -S htop. Once the installation is complete,
simply type htop in your terminal and press Enter to launch
the program.
Navigating the Interface
When you open htop, the screen is divided into three
main sections:
- Header: Features color-coded bar graphs that display CPU, memory (RAM), and swap space utilization, along with system uptime, tasks, and load averages.
- Process List: Takes up the bulk of the screen and lists the running processes, including their Process ID (PID), the user who owns them, CPU and memory usage percentages, and the exact execution command.
- Footer: Serves as a helpful legend at the very bottom of your terminal window, displaying common function keys used to interact with the tool.
Essential Keyboard Shortcuts
Navigating the environment is straightforward once you know a few fundamental shortcuts:
- Arrow Keys: Scroll up and down through the process list, or left and right to view lengthy command paths.
- F3 (Search): Search for a specific process by its name.
- F4 (Filter): Filter the process list to only show items matching a specific keyword.
- F5 (Tree View): Toggle a hierarchical view that shows the parent-child relationships between running processes.
- F9 (Kill): Send a termination signal to a misbehaving application. Select the process, press F9, and press Enter to confirm.
- F10 or Q (Quit): Exit the interface and return to your standard command-line prompt.