top Command Cheat Sheet
top displays Linux processes. It provides a dynamic real-time view of a running system.
Synopsis
top
Interactive Commands
While top is running, press these keys:
| Key | Action |
|---|---|
h |
Help (Show all commands) |
space |
Update display immediately |
q |
Quit |
k |
Kill a process (asks for PID) |
r |
Renice a process (change priority) |
P |
Sort by Processor (CPU) usage (Default) |
M |
Sort by Memory usage |
T |
Sort by Time (Cumulative CPU time) |
1 |
Toggle viewing individual CPUs |
c |
Toggle Command line path (full vs short) |
u |
Filter by User |
f |
Fields manager (Add/Remove columns) |
z |
Toggle color/mono |
x |
Highlight sorting column |
Command Line Options
Filter by User (-u)
top -u www-data
Filter by PID (-p)
Watch specific processes.
top -p 1234,5678
Batch Mode (-b)
Print output to stdout (useful for logging/files) instead of interactive screen.
# Run once and exit
top -b -n 1 > top-output.txt
Set Update Interval (-d)
Refresh every 1 second (default is usually 3s).
top -d 1
Saving Configuration
If you like your setup (columns, sorting, colors), press W (Shift+w) while running top.
It saves detailed config to ~/.toprc.
Notes
- htop: A more modern, colorful, and user-friendly alternative.
- Load Average: The three numbers at the top right (1min, 5min, 15min average). If > number of CPU cores, system is overloaded.