Install htop
# Ubuntu/Debian
sudo apt install htop
# macOS
brew install htop
Launch htop
htop
Navigation shortcuts
F1orh- HelpF2orS- SetupF3or/- SearchF4or\- FilterF5ort- Tree viewF6or<>- Sort by columnF9ork- Kill processF10orq- Quit
Sorting
M- Sort by memory usageP- Sort by CPU usageT- Sort by timeN- Sort by PID
Display options
H- Toggle user threadsK- Toggle kernel threadsu- Filter by userSpace- Tag processU- Untag allc- Tag all children
Tree view
t- Toggle tree view+- Expand tree-- Collapse tree
Process management
k- Kill process (sends SIGTERM)F9- Kill menu (choose signal)e- Show process environmentl- List open files (lsof)s- Trace syscalls (strace)
Common signals
1 - SIGHUP (Reload configuration)
2 - SIGINT (Interrupt, Ctrl+C)
9 - SIGKILL (Force kill)
15 - SIGTERM (Graceful termination)
18 - SIGCONT (Continue if stopped)
19 - SIGSTOP (Pause process)
Filtering
Press F4 then type:
nginx # Show only nginx processes
USER=www # Show processes by user
STATE=R # Show only running processes
Color schemes
Press F2 > Colors > Choose theme:
- Monochrome
- Black on White
- Light Terminal
- MC (Midnight Commander)
- Black Night
Display meters
Press F2 > Meters:
- Add/remove meters
- Customize layout
- CPU, Memory, Swap meters
- Load average, Uptime
Configuration file
Located at ~/.config/htop/htoprc
View specific user
htop -u username
Batch mode (non-interactive)
htop --no-color --no-mouse
CPU affinity
a- Set CPU affinity- Select which CPUs process can use
Process priority
F7- Decrease priority (nice)F8- Increase priority (nice)
Useful display modes
I- Invert sort orderp- Show full pathsg- Merge all branches
Monitor specific PID
htop -p 1234,5678
Show command line arguments
c- Show full command line