This article was converted by SimpRead; the original source is available at www.sysgeek.cn.
Comprehensive Guide to the
htopCommand: From Installation and Interface Breakdown to Advanced Customization—plus extensive operational tips and keyboard shortcuts—to help you effortlessly manage Linux processes and system resources.
For years, the top command has been the go-to tool for Linux users monitoring system resource usage. Although top remains widely used today, this article introduces its upgraded successor—htop. Compared to the traditional top, htop features a more aesthetically pleasing interface, better-organized information layout, and near-universal compatibility across Linux distributions.
The htop system monitoring tool presents Linux processes more clearly and offers a robust suite of process management capabilities. Let’s now explore how to use this colorful, feature-rich Linux system administration utility.
Differences Between htop and top
The top Command
The top command is a classic Unix-like operating system utility supported on virtually all Unix-like systems. It displays rich real-time system operation and resource utilization data via a minimalist text-based interface. top also supports color display, highlighting, and basic graphical representations.
When using top, you can:
- Press
zto toggle color mode; - Press
tto display the CPU load graph; - Press
1to list all CPU cores; - Press
mto display the memory usage graph; - Press
cto view the full command line of each process.
top command
The htop Command
htop aims to be a more user-friendly alternative to top. Like top, htop includes a dashboard above the process list that displays a colorized, semi-graphical interface with dynamic bar graphs and the complete command line for each process.
htop command
Comparison of top vs. htop
| Feature | `top` | `htop` |
|---|---|---|
| Interface | Text-based interface | Colorful, semi-graphical interface |
| Interactivity | Limited | Highly interactive, supports mouse operations |
| Process Sorting | Sortable by CPU, memory, etc. | Sortable by multiple metrics—more flexible |
| Process Search | Supported | Supported—and easier to use |
| Process Tree View | Not supported | Supported |
| Scrolling View | Not supported | Supports both horizontal and vertical scrolling |
| Configuration Options | Limited | Rich and highly customizable |
| CPU Usage Display | Each core shown separately | Each core shown separately |
| Memory / Swap Graphs | Supported | Supported |
| Keyboard Shortcuts | Fewer | More—and more intuitive |
| Resource Consumption | Lower | Slightly higher than `top` |
| Default Installation | Built-in by default on most Unix-like systems | Usually requires separate installation |
So, does this mean top can perform every function offered by htop? The answer is no. htop’s advantages extend far beyond aesthetics, intuitive colors, and charts—it delivers many additional powerful features waiting for you to discover.
Installing htop
In most cases, htop is available directly from your Linux distribution’s default software repository under the package name htop. Below are installation instructions for various systems:
- Debian, Ubuntu, and derivatives:
sudo apt install htop
- Red Hat–based distributions (e.g., Fedora, CentOS):
sudo dnf install htop
- Arch Linux and Manjaro:
sudo pacman -S htop
- openSUSE:
sudo zypper install htop
- macOS (using Homebrew):
brew install htop
Introduction to the htop Interface
htop is a CLI (command-line interface) application ideal for monitoring remote servers. You can connect to a remote machine via SSH and launch it in your terminal with:
htop
Upon launching htop, you’ll see a clean, intuitive user interface displaying key system metrics by default—including CPU, memory, and SWAP usage—as well as a live list of running processes.
Top Dashboard
htop command: Top dashboard
The top dashboard shows usage percentages for each CPU core, memory, and SWAP space. The table below explains the meaning of each color:
| CPU Monitor | Mem Monitor | Swp Monitor | |
|---|---|---|---|
| Blue | Low-priority processes | Memory used by buffers | Used swap space |
| Green | Regular user processes | Used memory | / |
| Red | Kernel processes | / | / |
| Yellow / Orange | Virtual machine runtime (guest time) | Memory used by cache | Swap space used for caching |
| Magenta | / | Shared memory | |
| Gray | / | Compressed memory | Prior swap (Zswap) |
Beyond graphical resource usage, the top region also contains three essential numeric monitors providing critical insights into system health:
- Tasks: Displays the total number of tasks and threads, plus kernel threads—helping you quickly assess overall system load.
- Load average: Shows the average CPU load over the past 1, 5, and 15 minutes. This metric reflects average workload over varying intervals, helping identify load trends.
- Uptime: Indicates system uptime—valuable for assessing stability, especially on long-running servers.
Main Process Interface
The main process interface lists running processes in a dynamically sorted, scrollable list. By default, processes are ordered descending by CPU usage—immediately revealing the most resource-intensive ones.
htop command: Main process interface
The process list includes the following columns:
| Column Name | Full Name | Description |
|---|---|---|
| PID | Process ID | Process identifier number |
| USER | User | Owner of the process |
| PRI | Priority | Process priority |
| NI | Nice | The “niceness” value of the process. Higher values indicate greater willingness to yield CPU time to other processes |
| VIR | Virtual Memory | Virtual memory used by the process |
| RES | Resident Memory | Physical memory used by the process |
| SHR | Shared Memory | Shared memory used by the process |
| S | State | Current process state |
| CPU% | CPU Percentage | CPU time percentage used by the process |
| MEM% | Memory Percentage | Memory percentage used by the process |
| TIME+ | CPU Time | Total CPU time consumed since process start |
| Command | Command | Command line used to start the process |
Process state (column S) meanings:
| State Symbol | State Name | Description |
|---|---|---|
| R | Running | Currently executing |
| S | Sleeping | Interruptible sleep (waiting for an event) |
| D | Disk sleep | Uninterruptible sleep (typically due to pending disk I/O) |
| t | Traced | Stopped by debugger |
| Z | Zombie | Terminated but not yet reaped by parent process |
With this detailed information, system administrators can rapidly identify abnormally resource-hungry processes for targeted optimization or troubleshooting.
I/O Interface
htop not only monitors CPU and memory usage but also helps track system I/O activity. Toggle to the I/O interface by pressing Tab or clicking the “I/O” tab.
htop command: I/O interface
The I/O interface provides these key metrics:
| Column Name | Full Name | Description |
|---|---|---|
| PID | Process ID | Process identifier number |
| USER | User | Owner of the process |
| IO | I/O Scheduling Class | I/O scheduling class and priority: R: Realtime B: Best-effort id: Idle |
| DISK R/W | Disk Read/Write | Combined disk read/write throughput |
| DISK READ | Disk Read | Disk read speed (bytes/sec) |
| DISK WRITE | Disk Write | Disk write speed (bytes/sec) |
| SWPD% | Swapped Percentage | Percentage of time pages were swapped out |
| IOD% | I/O Delay Percentage | Percentage of time waiting for synchronous block I/O completion |
| Command | Command | Command line used to start the process |
Here you can quickly spot processes performing heavy disk I/O, helping detect potential I/O bottlenecks. For example:
- An unusually high
DISK R/Wvalue may indicate intensive file operations that degrade overall system performance. - A high
SWPD%suggests insufficient RAM and frequent swapping—often leading to performance degradation. Similarly, a highIOD%signals I/O contention, where processes wait for disk I/O to complete.
Careful analysis of these metrics empowers administrators to understand I/O behavior and apply precise optimizations to improve overall system performance.
Basic htop Operations and Common Keyboard Shortcuts
Mouse Operations
htop supports both keyboard and mouse interaction. Clicking a column header sorts the process list by that column; the selected header turns blue and displays an arrow indicator.
htop command: Sorting processes
- An upward-pointing arrow indicates ascending order; downward means descending—each click toggles direction.
- You can also click on a process or use
Home,End,PageUp,PageDown, and arrow keys to highlight/select a specific process.
Function Keys
Common function keys and shortcuts appear at the bottom of the htop interface—useful when a mouse isn’t available. Press the corresponding key or click the blue label to execute the action.
htop command: Common shortcuts
- Frequently used shortcuts include:
| Shortcut | Description |
|---|---|
F1 | Open help screen—explains meter colors, process states, and keyboard shortcuts |
F3 or / | Search processes by name (F3 finds next match; Shift+F3 finds previous) |
F4 | Filter processes |
F5 | Toggle tree view (show process hierarchy/parent-child relationships) |
F10 or q | Quit `htop` |
U | Filter processes by user |
- Shortcuts for the currently selected process:
| Shortcut | Description |
|---|---|
F7 | Decrease process priority (increase Nice value) |
F8 | Increase process priority (decrease Nice value) |
F9 or k | Kill (terminate) the selected process |
Some terminals reserve F10 for their own menus. If F10 doesn’t work, disable “Enable menu accelerator keys” in your terminal settings to allow F10 to pass through to htop; however, we recommend using q instead.
Customizing htop Configuration and Advanced Tips
Press F2 to enter the setup menu, where you can flexibly configure display options, header layout, meters, screens, and colors.
Display Options
In the Display Options panel, enable or disable features by checking/unchecking boxes.
htop command: Customizing display options
By default, the top dashboard uses a two-column layout, each occupying half the terminal width. Here you can adjust the number of columns and their relative widths.
htop command: Customizing header layout
Meters
Under Meters, select which meters to display in the top region. The number of columns matches your Header Layout setting.
htop command: Customizing meters
While configuring Meters, you can:
- Press
Delto remove a meter; - Press
Enterto move a meter; - Press
Spaceto cycle through display styles (graph, numeric, or LED-style).
Screens
Screen configuration works similarly to Meters—you can choose between the main process screen and the I/O screen, and customize displayed columns. Adding new columns follows the same method used for adding Meters. You can even press F5 to create an entirely new custom screen.
htop command: Customizing screens
Colors
In the Colors section, choose among different color themes to personalize htop’s appearance.
htop command: Selecting a color theme
Through these customization options, you can tailor htop precisely to your needs. Spend some time exploring these settings—you’ll find htop delivers increasingly accurate and efficient system monitoring.












