htop [options]
htop -u alice
htop is an interactive process viewer: a friendlier, colorful replacement for top. It
shows CPU cores, memory, swap and every running process, and lets you sort, search,
filter and signal processes with the keyboard (and the mouse). Install it with:
sudo apt install htop | sudo dnf install htop | brew install htop
Start it
htop # start normally
htop -u alice # only alice's processes
htop -p 1234,5678 # only these PIDs
htop -d 20 # refresh every 2 seconds (units are tenths of a second)
htop -s PERCENT_MEM # start sorted by a column
htop -t # tree view
htop --readonly # cannot send signals or change priority
htop -C # no colors (monochrome)
htop --version
Reading the header
CPU bars One bar per core. Blue = low-priority, green = normal, red = kernel, cyan = virtual
Mem bar Green = used, blue = buffers, yellow/orange = cache. Cache is reclaimable, not "wasted"
Swp bar Swap in use. Lots of swap use with high memory means the machine is short on RAM
Tasks Number of processes, threads, and how many are running
Load average 1, 5 and 15 minute averages. Compare to your core count (load 4 on 4 cores = full)
Uptime How long since boot
Reading the process list
PID Process ID USER Owner
PRI/NI Priority and nice value VIRT Virtual memory (everything mapped)
RES Resident memory (real RAM) SHR Shared memory
S State: R running, S sleeping, D disk wait, Z zombie, T stopped
CPU% CPU use (100% = one full core) MEM% Percent of RAM used
TIME+ Total CPU time used Command The command line
RES and MEM% are the numbers to watch. VIRT is often huge and harmless.
Navigate
Up / Down, PgUp / PgDn Move through the list
Home / End Top and bottom
Left / Right Scroll the command column
Mouse click Select a process, click headers to sort
Function keys
F1 Help F2 Setup (choose columns, meters, colors)
F3 Search by name F4 Filter the list
F5 Tree view F6 Sort by a column
F7 Nice - (higher priority, needs root) F8 Nice + (lower priority)
F9 Kill (send a signal) F10 Quit
Search, filter and sort
/ or F3 Search: finds the next matching process (n / N for next and previous)
\ or F4 Filter: shows only matching processes (Esc clears)
P Sort by CPU%
M Sort by MEM%
T Sort by TIME
I Reverse the sort order
< or > Choose the sort column from a menu
F5 or t Toggle tree view
H Hide or show user threads
K Hide or show kernel threads
Tab Switch between the "Main" and "I/O" tabs (some builds)
Act on processes
k or F9 Kill: choose a signal, then Enter (15 SIGTERM is polite, 9 SIGKILL is forceful)
Space Tag a process (select several)
c Tag a process and all its children
U Untag everything
u Show only one user's processes
] Higher priority (lower nice value; needs root)
[ Lower priority (raise nice value)
a Set CPU affinity (pin to certain cores)
i Set I/O priority (Linux)
s Trace system calls with strace (if installed)
l List open files with lsof (if installed)
e Show the environment of the selected process
w Show the full command line wrapped
F Follow the selected process as it moves in the list
Try SIGTERM (15) first. Use SIGKILL (9) only when a process will not exit, since it cannot clean up.
Useful setups
htop -u www-data # watch a service account
htop -p $(pgrep -d, nginx) # only nginx processes
htop -t -u alice # tree view of one user
htop -d 5 # faster refresh for watching spikes
F2 > Display options Enable "Tree view", "Show custom thread names", "Detailed CPU time"
F2 > Columns Add IO_RATE, STARTTIME, or PERCENT_CPU columns
F2 > Meters Add Disk IO, Network IO, or Load average to the header
Settings are saved to ~/.config/htop/htoprc.
Practical workflows
# Find what is eating CPU
htop # press P (sort by CPU), look at the top, then F9 to send SIGTERM if it is safe
# Find what is eating memory
htop # press M (sort by MEM), check RES, not VIRT
# Who owns this process, and what started it?
htop # press F5 for the tree, find the parent, press e to see its environment
# Which files does it have open, and what is it doing?
htop # select it, press l (lsof) or s (strace)
# Slow down a heavy job without killing it
htop # select it, press [ to raise the nice value (lower priority)
# Kill several related processes
htop # press / to search, then Space to tag each, then F9
# Is the system swapping?
htop # look at the Swp bar and the Load average, then sort by MEM
# Watch one program for a while
htop -p $(pgrep -d, myapp) -d 10
htop vs the other tools
top Preinstalled everywhere, less friendly (press 1 for cores, M for memory, P for CPU)
htop Colorful, mouse support, tree view, easy kill and renice
btop Modern full dashboard with graphs (CPU, memory, disk, network)
atop Logs history, good for "what happened at 3 a.m."
ps aux Snapshot for scripts: ps aux --sort=-%mem | head
pidstat, vmstat, iostat Focused stats (sysstat package)
Common problems
"Command not found" Install it: sudo apt install htop
Cannot kill or renice The process belongs to another user: run htop with sudo
Memory looks full Cache counts as used. Watch the "available" number (free -h) and swap use instead
CPU above 100% Multi-threaded: 100% means one core, so 400% means four cores busy
D state (uninterruptible) Waiting on disk or NFS. It cannot be killed: fix the storage problem
Zombie (Z) processes Dead, waiting for the parent to collect them: restart or fix the parent
Colors look wrong Try htop -C, or set F2 > Colors
Column missing F2 > Columns, then add it
Tips
Sort by CPU (P) and memory (M) first. The top few lines answer most "why is this server slow" questions.
Use tree view (F5 or t) to see which parent started a process before you kill it.
Use F4 (filter) instead of F3 (search) when you want a short list you can act on.
Compare load average to your number of cores. Load above the core count means processes are waiting.
Try SIGTERM before SIGKILL, and never kill a process you do not recognize on a production server.
Run htop with sudo to see and control everything, or --readonly when you just want to look safely.
Save your favorite layout in F2 (setup). Add the meters you check every time, like Disk IO.
Tag several processes with Space and act on them all at once.