Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Htop - An Interactive Process Viewer for Linux
Htop is an interactive process viewer and system monitor for Linux that provides a superior alternative to the traditional top command. It offers real-time, color-coded visualization of system resources and running processes with an intuitive interface that allows users to manage processes interactively.
Unlike the static output of top, Htop displays CPU, memory, and swap usage in colorful progress bars at the top of the screen, followed by a scrollable list of processes. This enhanced interface makes system monitoring more efficient and user-friendly for both beginners and experienced administrators.
Installation
Install Htop using your distribution's package manager:
Ubuntu/Debian:
sudo apt install htop
Red Hat/CentOS:
sudo yum install htop
Fedora:
sudo dnf install htop
Launch Htop by typing htop in the terminal.
Interface Overview
The interface displays key process information including:
| Column | Description |
|---|---|
| PID | Process ID |
| USER | Process owner |
| PRI | Process priority |
| NI | Nice value |
| VIRT | Virtual memory usage |
| RES | Resident memory usage |
| SHR | Shared memory |
| S | Process status |
| CPU% | CPU usage percentage |
| MEM% | Memory usage percentage |
| TIME+ | Total runtime |
| Command | Command that started the process |
Key Features and Operations
Process Management
Navigate using arrow keys to select processes. Key operations include:
Kill Process Press
F9orkto send signals (SIGTERM, SIGKILL, etc.)Change Priority Press
F7(increase nice value) orF8(decrease nice value)Tree View Press
F5ortto show parent-child relationships
Filtering and Searching
Htop provides powerful filtering capabilities:
Filter Press
F4or\to filter processes by textSearch Press
F3or/for incremental searchUser Filter Press
uto show processes for specific users
Example filtering for bash processes:
[htop 3.2.1] Tasks: 64, 174 thr; 1 running CPU[||||||||||| 45.2%] Mem[||||||||||| 1880/7976MB] Swp[ 0/0MB] PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command 3091 root 20 0 5488 1660 1280 S 0.0 0.1 0:00.02 bash 3095 root 20 0 5488 1664 1284 S 0.0 0.1 0:00.01 bash 3101 user 20 0 5488 1668 1288 S 0.0 0.1 0:00.01 bash
Sorting Options
Press F6 or < to access the sort menu. Available sort criteria include PID, USER, CPU%, MEM%, TIME+, and COMMAND. This helps identify resource-intensive processes quickly.
Tree View Display
The tree view (F5) shows process hierarchies:
[htop 3.2.1] Tasks: 64, 174 thr; 1 running
CPU[||||||||||| 45.2%]
Mem[||||||||||| 1880/7976MB]
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
1 root 20 0 10.6M 6080 3984 S 0.0 0.0 0:01.94 /sbin/init
?? 123 root 20 0 15.2M 8192 5432 S 0.5 0.1 0:02.15 systemd
?? 456 user 20 0 25.4M 12288 8765 S 1.2 0.2 0:05.43 gnome-session
Advanced Features
Customization
Press F2 to access the setup menu for customizing:
Meter layout and colors
Column visibility and order
Display options (detailed CPU time, show program path)
Multi-CPU Display
On multi-core systems, enable detailed CPU view to see per-core usage:
[htop 3.2.1] Tasks: 64, 174 thr; 1 running CPU0[||||| 11.7%] CPU1[||| 7.4%] CPU2[||||| 12.6%] CPU3[|| 4.6%] Mem[||||||||||| 1880/7976MB] Swp[ 0/0MB]
System Call Tracing
Press s on a selected process to launch strace for debugging system calls. This feature requires root privileges and the strace utility to be installed.
Conclusion
Htop is an essential tool for Linux system monitoring that surpasses the traditional top command with its interactive interface, real-time updates, and comprehensive process management capabilities. Its ability to filter, sort, and visualize system resources makes it indispensable for troubleshooting performance issues and managing system processes effectively.
