htop (Interactive Process Viewer)
htop is an interactive system-monitor process-viewer and manager. It is designed as a more modern and user-friendly alternative to the classic top command, providing a colorized, real-time overview of your system's CPU, Memory, and Swap usage.
1. How to Run
htop
- If not installed, you can typically get it via
sudo apt install htop(Debian/Ubuntu) orsudo yum install htop(RHEL/CentOS).
2. Understanding the Interface
- Header Section: Displays usage bars for each CPU core, Memory (RAM), and Swap space.
- Main Section: Lists active processes with columns like PID (Process ID), USER, CPU%, MEM%, and Command.
- Footer Section: Shows a menu of available function key shortcuts (F1 through F10).
3. Essential Shortcuts
| Shortcut | Function | Description |
|---|---|---|
| F2 (S) | Setup | Customize display options, colors, and columns. |
| F3 (/) | Search | Search for a specific process by name. |
| F4 () | Filter | Filter the list to show only matching process names. |
| F5 (t) | Tree View | Shows the parent-child relationship between processes. |
| F6 (<, >) | Sort By | Sort the process list by columns like CPU% or MEM%. |
| F9 (k) | Kill | Send a signal (like SIGKILL) to terminate a process. |
| F10 (q) | Quit | Exit htop and return to the terminal. |
4. [Tip] Handling System Lag
When your system slows down, open htop and press F6 to sort by PERCENT_CPU. Identify the process consuming the most resources, select it, and press F9 to kill it. This is the fastest way to regain control of a hanging system.