top & htop Commands Cheatsheet
top and htop are powerful command-line utilities that provide a real-time, dynamic view of running processes and system resource usage. They are essential for monitoring system performance and troubleshooting.
top: The Classic Monitor
top comes pre-installed on most Linux distributions. It gives you a continuous, interactive view of the most CPU-intensive tasks.
top| Header | Description |
|---|---|
PID | Process ID. |
USER | The user who owns the process. |
%CPU | The percentage of CPU time the process is using. |
%MEM | The percentage of physical memory the process is using. |
TIME+ | Total CPU time used by the process since it started. |
COMMAND | The name of the command or process. |
htop: The Modern & Interactive Alternative
htop is a more user-friendly and feature-rich alternative to top. It is not pre-installed but is available in most package repositories (e.g., `sudo apt install htop`).
htopKey features of htop:
- **User-friendly Interface:** Color-coded output and a more visual, organized layout.
- **Mouse Support:** You can use your mouse to select processes and interact with the menu.
- **Process Management:** Easily kill processes by selecting them and pressing `F9`.
- **Filtering:** Quickly search for and filter processes.
Common Keys in `top` and `htop`
| Key | Action |
|---|---|
q | Quit the application. |
k | (in `top`) Send a kill signal to a selected process. |
F9 | (in `htop`) Send a kill signal to a selected process. |
F6 | (in `htop`) Sort processes by a different column. |
F4 | (in `htop`) Search for a process by name. |