top Cheatsheet
Quick reference for monitoring processes, CPU, and memory usage with top in Linux
The `top` command displays a real-time view of running processes, CPU load, and memory usage. This cheatsheet covers startup options, interactive key commands, sorting, filtering, and display customization.
Startup Options
Common command-line flags for launching top.
| Command | Description |
|---|---|
top | Start top with default settings |
top -d 5 | Set refresh interval to 5 seconds |
top -n 3 | Exit after 3 screen updates |
top -u username | Show only processes owned by a user |
top -p 1234,5678 | Monitor specific PIDs |
top -b | Batch mode (non-interactive, for scripts and logging) |
top -b -n 1 | Print a single snapshot and exit |
top -H | Show individual threads instead of processes |
Interactive Navigation
Key commands available while top is running.
| Key | Description |
|---|---|
q | Quit top |
h or ? | Show help screen |
Space | Refresh the display immediately |
d or s | Change the refresh interval |
k | Kill a process (prompts for PID and signal) |
r | Renice a process (change priority) |
u | Filter by user |
n or # | Set the number of displayed processes |
W | Save current settings to ~/.toprc |
Sorting
Change the sort column interactively.
| Key | Description |
|---|---|
P | Sort by CPU usage (default) |
M | Sort by memory usage |
N | Sort by PID |
T | Sort by cumulative CPU time |
R | Reverse the current sort order |
< / > | Move the sort column left / right |
F or O | Open the field management screen to pick a sort column |
Display Toggles
Show or hide parts of the summary and task list.
| Key | Description |
|---|---|
l | Toggle the load average line |
t | Cycle through CPU summary modes (bar, text, off) |
m | Cycle through memory summary modes (bar, text, off) |
1 | Toggle per-CPU breakdown (one line per core) |
H | Toggle thread view (show individual threads) |
c | Toggle between command name and full command line |
V | Toggle forest (tree) view |
x | Highlight the current sort column |
z | Toggle color output |
Filtering and Searching
Narrow the process list while top is running.
| Key | Description |
|---|---|
u | Show only processes for a specific user |
U | Show processes by effective or real user |
o / O | Add a filter (e.g., COMMAND=nginx or %CPU>5.0) |
Ctrl+O | Show active filters |
= | Clear all filters for the current window |
L | Search for a string in the display |
& | Find next occurrence of the search string |
Summary Area Fields
Key metrics in the header area.
| Field | Description |
|---|---|
load average | System load over 1, 5, and 15 minutes |
us | CPU time in user space |
sy | CPU time in kernel space |
ni | CPU time for niced (reprioritized) processes |
id | CPU idle time |
wa | CPU time waiting for I/O |
hi / si | Hardware / software interrupt time |
st | CPU time stolen by hypervisor (VMs) |
MiB Mem | Total, free, used, and buffer/cache memory |
MiB Swap | Total, free, used swap, and available memory |
Batch Mode and Logging
Use top in scripts or for capturing snapshots.
| Command | Description |
|---|---|
top -b -n 1 | Print one snapshot to stdout |
top -b -n 5 -d 2 > top.log | Log 5 snapshots at 2-second intervals |
top -b -n 1 -o %MEM | Single snapshot sorted by memory |
top -b -n 1 -u www-data | Snapshot of one user’s processes |
top -b -n 1 -p 1234 | Snapshot of a specific PID |
Related Guides
Full guides for process monitoring and management.
| Guide | Description |
|---|---|
top Command in Linux | Full top guide with examples |
ps Command in Linux | List and filter processes |
Kill Command in Linux | Send signals to processes by PID |
Linux Uptime Command | Check system uptime and load average |
Check Memory in Linux | Inspect RAM and swap usage |