Skip to main content

top Cheatsheet

By Dejan Panovski Updated on Download PDF

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.

CommandDescription
topStart top with default settings
top -d 5Set refresh interval to 5 seconds
top -n 3Exit after 3 screen updates
top -u usernameShow only processes owned by a user
top -p 1234,5678Monitor specific PIDs
top -bBatch mode (non-interactive, for scripts and logging)
top -b -n 1Print a single snapshot and exit
top -HShow individual threads instead of processes

Interactive Navigation

Key commands available while top is running.

KeyDescription
qQuit top
h or ?Show help screen
SpaceRefresh the display immediately
d or sChange the refresh interval
kKill a process (prompts for PID and signal)
rRenice a process (change priority)
uFilter by user
n or #Set the number of displayed processes
WSave current settings to ~/.toprc

Sorting

Change the sort column interactively.

KeyDescription
PSort by CPU usage (default)
MSort by memory usage
NSort by PID
TSort by cumulative CPU time
RReverse the current sort order
< / >Move the sort column left / right
F or OOpen the field management screen to pick a sort column

Display Toggles

Show or hide parts of the summary and task list.

KeyDescription
lToggle the load average line
tCycle through CPU summary modes (bar, text, off)
mCycle through memory summary modes (bar, text, off)
1Toggle per-CPU breakdown (one line per core)
HToggle thread view (show individual threads)
cToggle between command name and full command line
VToggle forest (tree) view
xHighlight the current sort column
zToggle color output

Filtering and Searching

Narrow the process list while top is running.

KeyDescription
uShow only processes for a specific user
UShow processes by effective or real user
o / OAdd a filter (e.g., COMMAND=nginx or %CPU>5.0)
Ctrl+OShow active filters
=Clear all filters for the current window
LSearch for a string in the display
&Find next occurrence of the search string

Summary Area Fields

Key metrics in the header area.

FieldDescription
load averageSystem load over 1, 5, and 15 minutes
usCPU time in user space
syCPU time in kernel space
niCPU time for niced (reprioritized) processes
idCPU idle time
waCPU time waiting for I/O
hi / siHardware / software interrupt time
stCPU time stolen by hypervisor (VMs)
MiB MemTotal, free, used, and buffer/cache memory
MiB SwapTotal, free, used swap, and available memory

Batch Mode and Logging

Use top in scripts or for capturing snapshots.

CommandDescription
top -b -n 1Print one snapshot to stdout
top -b -n 5 -d 2 > top.logLog 5 snapshots at 2-second intervals
top -b -n 1 -o %MEMSingle snapshot sorted by memory
top -b -n 1 -u www-dataSnapshot of one user’s processes
top -b -n 1 -p 1234Snapshot of a specific PID

Full guides for process monitoring and management.

GuideDescription
top Command in LinuxFull top guide with examples
ps Command in LinuxList and filter processes
Kill Command in LinuxSend signals to processes by PID
Linux Uptime CommandCheck system uptime and load average
Check Memory in LinuxInspect RAM and swap usage