Install htop
On Ubuntu and Debian:
sudo apt update
sudo apt install htop
On AlmaLinux and Rocky Linux, htop comes from the EPEL repository:
sudo dnf install epel-release
sudo dnf install htop
Start it with htop, or sudo htop to manage processes of other users. Press q or F10 to quit.
The Screen at a Glance
- CPU meters: one bar per CPU, numbered from 0 or 1 depending on the settings.
- Mem and Swp: memory and swap in use.
- Tasks, Load average, Uptime: process and thread counts, the 1, 5, and 15 minute load, and time since boot.
- Process list: PID, user, priority, memory columns, state, CPU and memory percent, CPU time, and the command.
The columns mean the same as in top; the top command guide explains each one.
Function Keys
| Key | What it does |
|---|---|
| F1 | Help, with the color legend |
| F2 | Setup: meters, columns, colors |
| F3 | Search by name |
| F4 | Filter the list |
| F5 | Tree view |
| F6 | Choose the sort column |
| F7, F8 | Raise or lower priority |
| F9 | Send a signal |
| F10 | Quit |
If your terminal or SSH client catches the function keys, use the letter keys instead: / to search, \ to filter, t for tree view, k to send a signal. You can also click column headers and bottom labels with the mouse.
Sort, Filter, and Tree View
- Sort:
Pby CPU,Mby memory,Tby CPU time, or F6 for any column. - Filter: F4, then type part of a name such as
php; only matching lines stay. Press F4 and clear the text to undo. - One user:
uand pick the user from the list. - Tree: F5 shows which process started which, useful for web server and database workers.
- Threads:
Hhides or shows user threads,Kkernel threads.
Send a Signal Safely
- Select the process with the arrow keys, or tag several with the space bar.
- Press F9. A list of signals opens with 15 SIGTERM selected.
- Press Enter to send SIGTERM, which asks the program to stop cleanly.
- Wait and watch whether the line disappears. Choose 9 SIGKILL only if it does not, and never as the first step on a database.
A process that belongs to a service should be stopped with systemctl stop, or systemd may start it again. The full order is in how to kill a process in Linux.
What the Colors Mean
In the default color scheme, the CPU bar shows low-priority (niced) work in blue, normal user programs in green, kernel time in red, and steal time in cyan. The segments of the memory bar depend on the htop version and the system, and colors change with the scheme chosen in F2, so press F1: the help screen shows the legend for your version and settings.
Start Options
htop -u deploy
htop -p 1234,5678
htop -d 20
These show one user's processes, watch selected PIDs, and set the refresh delay in tenths of a second. Settings you change in F2 are saved in ~/.config/htop/htoprc when you quit. To find a PID first, see how to list processes.