How to use htop

This article was converted by SimpRead; the original source is available at www.sysgeek.cn.

Comprehensive Guide to the htop Command: 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 z to toggle color mode;
  • Press t to display the CPU load graph;
  • Press 1 to list all CPU cores;
  • Press m to display the memory usage graph;
  • Press c to 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`
InterfaceText-based interfaceColorful, semi-graphical interface
InteractivityLimitedHighly interactive, supports mouse operations
Process SortingSortable by CPU, memory, etc.Sortable by multiple metrics—more flexible
Process SearchSupportedSupported—and easier to use
Process Tree ViewNot supportedSupported
Scrolling ViewNot supportedSupports both horizontal and vertical scrolling
Configuration OptionsLimitedRich and highly customizable
CPU Usage DisplayEach core shown separatelyEach core shown separately
Memory / Swap GraphsSupportedSupported
Keyboard ShortcutsFewerMore—and more intuitive
Resource ConsumptionLowerSlightly higher than `top`
Default InstallationBuilt-in by default on most Unix-like systemsUsually 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
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 MonitorMem MonitorSwp Monitor
BlueLow-priority processesMemory used by buffersUsed swap space
GreenRegular user processesUsed memory/
RedKernel processes//
Yellow / OrangeVirtual machine runtime (guest time)Memory used by cacheSwap space used for caching
Magenta/Shared memory
Gray/Compressed memoryPrior 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 NameFull NameDescription
PIDProcess IDProcess identifier number
USERUserOwner of the process
PRIPriorityProcess priority
NINiceThe “niceness” value of the process. Higher values indicate greater willingness to yield CPU time to other processes
VIRVirtual MemoryVirtual memory used by the process
RESResident MemoryPhysical memory used by the process
SHRShared MemoryShared memory used by the process
SStateCurrent process state
CPU%CPU PercentageCPU time percentage used by the process
MEM%Memory PercentageMemory percentage used by the process
TIME+CPU TimeTotal CPU time consumed since process start
CommandCommandCommand line used to start the process

Process state (column S) meanings:

State SymbolState NameDescription
RRunningCurrently executing
SSleepingInterruptible sleep (waiting for an event)
DDisk sleepUninterruptible sleep (typically due to pending disk I/O)
tTracedStopped by debugger
ZZombieTerminated 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 NameFull NameDescription
PIDProcess IDProcess identifier number
USERUserOwner of the process
IOI/O Scheduling ClassI/O scheduling class and priority:
R: Realtime
B: Best-effort
id: Idle
DISK R/WDisk Read/WriteCombined disk read/write throughput
DISK READDisk ReadDisk read speed (bytes/sec)
DISK WRITEDisk WriteDisk write speed (bytes/sec)
SWPD%Swapped PercentagePercentage of time pages were swapped out
IOD%I/O Delay PercentagePercentage of time waiting for synchronous block I/O completion
CommandCommandCommand 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/W value 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 high IOD% 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:
ShortcutDescription
F1Open help screen—explains meter colors, process states, and keyboard shortcuts
F3 or /Search processes by name (F3 finds next match; Shift+F3 finds previous)
F4Filter processes
F5Toggle tree view (show process hierarchy/parent-child relationships)
F10 or qQuit `htop`
UFilter processes by user
  • Shortcuts for the currently selected process:
ShortcutDescription
F7Decrease process priority (increase Nice value)
F8Increase process priority (decrease Nice value)
F9 or kKill (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 Del to remove a meter;
  • Press Enter to move a meter;
  • Press Space to 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.