Introduction
htop is an interactive process viewer and system monitor for Unix-like systems. It improves on the classic top command with a colorful interface, mouse support, vertical and horizontal scrolling, and the ability to manage processes without typing PIDs.
What htop Does
- Displays real-time CPU, memory, and swap usage with color-coded meters
- Lists all running processes with sortable columns for CPU, memory, I/O, and more
- Allows interactive process management: kill, renice, and send signals with a keystroke
- Filters and searches processes by name, user, or command line
- Supports tree view to visualize parent-child process relationships
Architecture Overview
htop reads process information from /proc on Linux and equivalent interfaces on macOS and FreeBSD. It uses ncurses for terminal rendering. The display loop polls system stats at a configurable interval and redraws meters and the process table. Columns, meters, and layouts are customizable through the setup screen (F2) and persisted to ~/.config/htop/htoprc.
Self-Hosting & Configuration
- Install from your distribution package manager or Homebrew on macOS
- Press F2 to open the setup screen and configure visible columns and meters
- Customize header layout with CPU meters, memory bars, uptime, and load average
- Set update interval and color scheme in the interactive configuration
- Configuration is saved to ~/.config/htop/htoprc in a human-readable format
Key Features
- Full mouse support for clicking columns, scrolling, and selecting processes
- Tree view shows process hierarchy at a glance
- Per-core CPU meters and I/O wait visualization
- Filter processes interactively by name, user, or cgroup
- Cross-platform: runs on Linux, macOS, FreeBSD, OpenBSD, and Solaris
Comparison with Similar Tools
- top — pre-installed on all Unix systems; less interactive, no mouse support
- btop — newer alternative with richer visualizations; written in C++
- glances — Python-based with web UI and export plugins; heavier dependencies
- atop — records system activity for historical analysis; steeper learning curve
FAQ
Q: How is htop different from top? A: htop provides color-coded output, mouse interaction, horizontal scrolling for long command lines, tree view, and interactive filtering that top lacks.
Q: Can htop show per-container or per-cgroup usage? A: htop supports cgroup-based filtering and can display cgroup columns to distinguish container workloads.
Q: Does htop work over SSH? A: Yes. It runs in any terminal emulator over SSH, making it useful for remote server monitoring.
Q: How do I kill a process in htop? A: Select the process with arrow keys or mouse, press F9, choose a signal (default SIGTERM), and confirm.