Linux Comm Htop
[ Linux Command Manual](#)
* * *
## What is htop
htop is an interactive process viewer for Linux systems, providing richer functionality and a more user-friendly interface than the traditional top command.
### Main Features of htop
* **Color Display**: Different colors distinguish different types of processes and system statuses
* **Visual Layout**: Intuitive display of CPU, memory, and swap usage
* **Mouse Support**: Direct mouse click operations supported
* **Process Tree View**: View hierarchical relationships between processes
* **Custom Sorting**: Sort processes by various metrics
* **Process Operations**: Directly terminate, adjust priority, etc.
* * *
## Installing htop
### On Debian/Ubuntu-based Systems
sudo apt update sudo apt install htop
### On RHEL/CentOS-based Systems
sudo yum install epel-release # Install EPEL repository first sudo yum install htop
### On Arch Linux-based Systems
sudo pacman -S htop
* * *
## htop Basic Interface Analysis
To start htop, simply enter in the terminal:
htop
The interface is mainly divided into the following parts:
1. **Top Area**: System overview information
* CPU usage (displayed by core)
* Memory usage
* Swap space usage
* System uptime and average load
2. **Middle Area**: Process list
* PID: Process ID
* USER: Process owner
* PRI: Process priority
* NI: nice value
* VIRT: Virtual memory usage
* RES: Physical memory usage
* SHR: Shared memory size
* S: Process status (running, sleeping, etc.)
* CPU%: CPU usage rate
* MEM%: Memory usage rate
* TIME+: CPU time
* COMMAND: Command name
3. **Bottom Area**: Function key hints
* * *
## htop Common Shortcuts
| Shortcut | Function Description |
| --- | --- |
| F1 or h | Show help |
| F2 or S | Enter setup menu |
| F3 or / | Search for process |
| F4 or | Filter processes |
| F5 or t | Show process tree |
| F6 or < | Select sort field |
| F7 or [ | Decrease process priority |
| F8 or ] | Increase process priority |
| F9 or k | Kill process |
| F10 or q | Quit htop |
| Space | Tag/untag process |
| u | Show specific user's processes |
| H | Show/hide user threads |
| K | Show/hide kernel threads |
| P | Sort by CPU usage |
| M | Sort by memory usage |
| T | Sort by running time |
* * *
## htop Advanced Features
### 1. Process Tree View
Press `F5` or `t` to switch to process tree view, displaying parent-child relationships between processes.
### 2. Process Filtering
Press `F4` or `` to enter filter conditions, showing only processes that match the criteria.
### 3. Multi-select Operations
After marking multiple processes with the space key, you can perform batch operations (such as termination).
### 4. Custom Display
Press `F2` to enter the setup menu, where you can:
* Adjust displayed columns
* Change color themes
* Set refresh interval
* Configure other display options
### 5. System Monitoring
The top area of htop provides rich system monitoring information:
* CPU usage (by core)
* Memory and swap space usage
* System load averages
* * *
## htop vs top Command Comparison
| Feature | htop | top |
| --- | --- | --- |
| Interface | Color, intuitive | Monochrome, basic |
| Mouse Support | Yes | No |
| Process Tree View | Supported | Not supported |
| Sorting Methods | Multiple, dynamically adjustable | Limited |
| Process Operations | Richer | Basic |
| Customization | Highly configurable | Limited |
| Resource Usage | Slightly higher | Lower |
* * *
## Practical Application Examples
### Example 1: Find and Terminate High CPU Usage Process
1. Start htop
2. Press `P` to sort by CPU usage
3. Find the target process
4. Press `F9` to select termination signal (usually 15 SIGTERM)
5. Press Enter to confirm
### Example 2: Monitor Specific User's Processes
1. Start htop
2. Press `u` key
3. Select the username to monitor
4. Only that user's processes are displayed
### Example 3: Set Refresh Interval
1. Press `F2` to enter setup
2. Select "Display options"
3. Modify "Delay" value (seconds)
4. Press `F10` to save and exit
* * *
## Frequently Asked Questions
### Q1: Which is better, htop or top?
htop provides richer functionality and a friendlier interface, suitable for interactive use; top is lighter weight, suitable for use in scripts.
### Q2: Why do some processes appear green/red?
Green usually indicates normally running processes, red may indicate high resource usage or zombie processes.
### Q3: How to view the full command line?
Press `F2` to enter setup, and adjust the "Show program path" option in "Display options".
### Q4: What does the memory information in htop mean?
* **VIRT**: Total virtual memory used by the process
* **RES**: Physical memory used by the process
* **SHR**: Shared memory used by the process
[ Linux Command Manual](#)
YouTip