dotlinux blog

Htop – An Interactive Process Viewer for Linux

For anyone working with Linux systems—whether you’re a system administrator, developer, or power user—monitoring and managing processes is a daily task. While the traditional top command has long been a staple for process monitoring, it has limitations: a static interface, limited interactivity, and a steep learning curve for new users. Enter Htop—a modern, interactive, and user-friendly alternative to top.

Htop (short for “Hisham’s top,” named after its original developer Hisham Muhammad) is an open-source process viewer that offers real-time insights into system resource usage, process management, and system health. Unlike top, Htop provides a scrollable, color-coded interface, supports mouse interactions, and lets you filter, sort, and manage processes with ease. Whether you need to identify resource hogs, kill unresponsive processes, or analyze system bottlenecks, Htop simplifies these tasks with its intuitive design.

In this blog, we’ll dive deep into Htop: how to install it, navigate its interface, leverage its key features, customize it to your needs, and use it effectively in real-world scenarios.

2026-03

Table of Contents#

  1. Installation
  2. Interface Overview
  3. Key Features of Htop
  4. Navigation and Shortcuts
  5. Customizing Htop
  6. Advanced Usage
  7. Practical Examples
  8. Conclusion
  9. References

Installation#

Htop is pre-installed on many Linux distributions, but if it’s not on your system, installing it is straightforward. Below are commands for popular Linux distros:

Debian/Ubuntu/Linux Mint#

sudo apt update && sudo apt install htop -y  

RHEL/CentOS/Rocky Linux#

On RHEL-based systems, Htop is available in the EPEL (Extra Packages for Enterprise Linux) repository. First, enable EPEL, then install:

sudo dnf install epel-release -y  
sudo dnf install htop -y  

Fedora#

Fedora includes Htop in its default repositories:

sudo dnf install htop -y  

Arch Linux/Manjaro#

sudo pacman -S htop  

macOS (via Homebrew)#

While Htop is Linux-focused, macOS users can install it via Homebrew:

brew install htop  

Once installed, launch Htop by simply typing htop in the terminal:

htop  

Interface Overview#

When you first launch Htop, you’ll see a dynamic, color-coded interface divided into three main sections:

1. Header (System Summary)#

The top portion of the screen displays real-time system metrics:

  • CPU Usage: A horizontal bar graph showing usage per CPU core (or total CPU). Colors indicate usage types:
    • Blue: Low-priority (nice) processes.
    • Green: Normal user processes.
    • Red: Kernel processes.
    • Yellow: I/O wait (disk/network bottlenecks).
  • Memory Usage: Two bars for physical memory (RAM) and swap space.
    • Green: Used memory.
    • Blue: Buffers (temporary data for I/O).
    • Yellow: Cache (frequently accessed data).
  • Load Average: Three numbers (e.g., 0.85 0.92 0.78) representing system load over 1, 5, and 15 minutes.
  • Uptime: How long the system has been running (e.g., 1d 2h 30m).

2. Process List#

The middle section lists all running processes in a tabular format. Key columns include:

  • PID: Process ID (unique identifier).
  • USER: User running the process.
  • PR: Priority (higher = more CPU time; rt = real-time priority).
  • NI: “Nice” value (adjusts priority; ranges from -20 (highest) to 19 (lowest)).
  • VIRT: Total virtual memory used (includes swapped memory).
  • RES: Resident set size (physical memory used, not swapped).
  • SHR: Shared memory (memory shared with other processes).
  • S: Process status (e.g., R = running, S = sleeping, D = disk sleep, Z = zombie, T = stopped).
  • %CPU: CPU usage percentage.
  • %MEM: Memory usage percentage.
  • TIME+: Total CPU time consumed (e.g., 0:05.23 = 5 seconds).
  • COMMAND: The command that started the process.

The bottom bar displays keyboard shortcuts for common actions (e.g., F1 for help, F9 to kill a process).

Key Features of Htop#

Htop’s popularity stems from its rich feature set, which addresses many limitations of top:

1. Interactive Interface#

Unlike top, Htop supports mouse interactions (click to select processes, resize columns, or use buttons). You can also scroll horizontally/vertically to view all processes or columns, even on small terminals.

2. Color-Coding#

Colors make it easy to distinguish between process types, resource usage, and statuses. For example:

  • Red %CPU indicates a process consuming significant CPU.
  • Zombie processes (Z status) are highlighted in red.

3. Tree View#

Press F5 to toggle tree view, which shows parent-child process relationships (e.g., how a service like systemd spawns child processes). This is invaluable for understanding process hierarchies.

  • Search: Press F3 to search for a process by name (e.g., nginx).
  • Filter: Press F4 to filter processes by a keyword (e.g., show only python processes).

5. One-Click Process Management#

Kill or send signals to processes without memorizing PIDs:

  • Select a process with arrow keys.
  • Press F9 to send a signal (e.g., SIGTERM (15) to terminate gracefully, SIGKILL (9) to force kill).

6. Customizable Columns#

Add/remove columns (e.g., PPID for parent PID, CPU for core ID) via the setup menu (F2).

7. Real-Time Updates#

By default, Htop refreshes every 1 second, but you can adjust this interval in the setup menu.

Htop’s power lies in its keyboard shortcuts. Here’s a cheat sheet of the most useful ones:

ShortcutActionDescription
F1 or hHelpShow all shortcuts.
F2 or SSetupCustomize interface (columns, colors, meters).
F3 or /SearchSearch for a process by name (case-insensitive).
F4 or \FilterFilter processes by a keyword (e.g., java).
F5 or tTree ViewToggle parent-child process tree.
F6 or >Sort ByChoose a column to sort processes (e.g., %CPU, %MEM).
F7 or -Decrease Nice ValueIncrease process priority (lower NI = higher priority).
F8 or +Increase Nice ValueDecrease process priority (higher NI = lower priority).
F9 or kKill ProcessSend a signal to terminate a process (e.g., SIGKILL).
F10 or qQuitExit Htop.
SpaceTag ProcessTag multiple processes (e.g., to kill them all at once).
uFilter by UserShow processes for a specific user.
pFilter by PIDShow processes with specific PIDs.
Shift + HHide ThreadsToggle visibility of threads (default: shown).
Shift + PSort by CPU UsageQuickly sort processes by %CPU (descending).
Shift + MSort by Memory UsageQuickly sort processes by %MEM (descending).

Customizing Htop#

Htop is highly customizable via the Setup menu (F2). Here’s how to tailor it to your workflow:

1. Meters (Header Customization)#

In the Setup menu, navigate to Meters to adjust the system summary in the header:

  • Add/remove meters (e.g., CPU cores, memory, swap, load average).
  • Change meter style (bar, text, histogram).
  • Adjust colors for CPU/memory usage.

2. Columns (Process List Customization)#

Go to Columns to modify the process table:

  • Add columns (e.g., PPID (parent PID), WCHAN (wait channel), STIME (start time)).
  • Remove unnecessary columns (e.g., SHR if not needed).
  • Reorder columns by selecting and using arrow keys.

3. Display Options#

Tweak how Htop looks:

  • Update Interval: Change how often Htop refreshes (default: 1 second).
  • Delay Time: Adjust the refresh delay (in tenths of a second).
  • Hide Idle Processes: Toggle visibility of processes with 0% CPU/memory usage.

4. Colors#

Customize color schemes for different elements (e.g., CPU usage, process statuses). Choose from predefined themes or create your own.

Advanced Usage#

Beyond basic navigation, Htop offers advanced features for power users:

Command-Line Options#

Launch Htop with flags to customize its behavior on startup:

  • -d <seconds>: Set refresh interval (e.g., htop -d 2 for 2-second updates).
  • -u <user>: Show only processes for a user (e.g., htop -u john).
  • -p <pid1,pid2>: Monitor specific PIDs (e.g., htop -p 1234,5678).
  • -s <column>: Sort by a column on startup (e.g., htop -s PERCENT_CPU).
  • --no-color: Disable color (useful for monochrome terminals).

Batch Mode#

For scripting or logging, use Htop in non-interactive (batch) mode with -b:

htop -b -n 1 > htop_snapshot.txt  # Capture 1 snapshot and save to file  

Integrating with Other Tools#

Pipe Htop output to tools like grep for advanced filtering:

htop | grep python  # Show only Python processes (alternative to F4 filter)  

Practical Examples#

Let’s walk through common scenarios where Htop shines:

Example 1: Identify a High-CPU Process#

  1. Launch Htop: htop.
  2. Press Shift + P to sort processes by %CPU (descending).
  3. The top process is the CPU hog. Note its PID (e.g., 1234).
  4. To kill it: Select the process with arrow keys, press F9, choose SIGKILL (9), and press Enter.

Example 2: Find Memory-Intensive Processes#

  1. Launch Htop: htop.
  2. Press Shift + M to sort by %MEM.
  3. Identify processes using the most RAM (e.g., a misbehaving chrome tab).
  4. Tag multiple processes with Space, then press F9 to kill them all.

Example 3: Analyze Process Hierarchies#

  1. Press F5 to enable tree view.
  2. Expand/collapse process trees with Enter to see parent-child relationships (e.g., which service spawned a problematic process).

Example 4: Filter Processes by User#

  1. Press u, then type a username (e.g., root), and press Enter.
  2. Htop will show only processes owned by root.

Conclusion#

Htop is more than just a process viewer—it’s a powerful tool that simplifies system monitoring and process management for Linux users. With its interactive interface, color-coded metrics, and extensive customization options, it outperforms the traditional top command in usability and functionality. Whether you’re troubleshooting a slow system, managing resources, or simply keeping an eye on processes, Htop is an essential addition to your Linux toolkit.

Give it a try today—you’ll wonder how you ever managed without it!

References#