How do you use htop in Linux?
This article provides a quick overview of the htop
command-line utility for Linux. We will explore what this interactive
process viewer does, why many system administrators prefer it over the
traditional top command, how to install it, and the basic
keyboard shortcuts needed to monitor your system’s resources
effectively.
Understanding the htop Command
htop is a popular, interactive text-mode process viewer
for Linux systems. While most Linux distributions come pre-packaged with
the standard top utility, htop offers a more
user-friendly, colorful, and highly readable interface. It allows users
to monitor vital system metrics—such as CPU usage, memory consumption,
swap space, and active processes—in real time.
One of the primary advantages of htop is its ability to
let you scroll both vertically to view the full process list and
horizontally to see complete command lines. Furthermore, you do not need
to type process numbers to kill a process or change its priority; you
can simply use the arrow keys to navigate and interact with the list.
For further reading and advanced configurations, you can explore this
excellent htop
resource.
Installing htop
Because htop is not always installed by default, you may
need to add it using your distribution’s package manager.
- Debian/Ubuntu-based systems: Open your terminal and
run
sudo apt install htop. - Red Hat/CentOS/Fedora-based systems: Use
sudo dnf install htoporsudo yum install htop. - Arch Linux: Run
sudo pacman -S htop.
Once the installation is complete, you can launch the tool simply by
typing htop in your terminal and pressing Enter.
Navigating the Interface
When you open htop, the interface is divided into three
main sections:
- Header: Displays graphical meters for CPU, Memory (RAM), and Swap usage. It also shows general system information like load average, uptime, and the total number of running tasks.
- Body: Contains the detailed, sortable list of all running processes.
- Footer: Shows a menu of
htopcommands and their corresponding function keys.
Essential Keyboard Shortcuts
htop is entirely keyboard-driven, making it highly
efficient. Here are some of the most important keys to know:
- Arrows: Scroll through the process list.
- F3 (Search): Type a process name to quickly locate it.
- F4 (Filter): Show only processes that match a specific keyword.
- F5 (Tree View): Toggle between a standard list and a hierarchical tree view, showing parent and child processes.
- F6 (Sort): Change the column used to sort the processes (e.g., by CPU% or MEM%).
- F9 (Kill): Send a termination signal to the currently highlighted process.
- F10 or q: Quit the application and return to the standard command prompt.
By mastering these basic commands, you can easily troubleshoot performance bottlenecks and manage system resources straight from the terminal.