top(1)
Display and update sorted information about the most CPU and memory intensive processes.
Synopsis
top [OPTIONS]Description
top provides a dynamic, real-time view of running processes and system resource usage including CPU, memory, and swap. It updates continuously (default every 3 seconds) and sorts processes by CPU usage by default, helping identify resource-hungry tasks quickly.
The display consists of a header showing system-wide metrics (uptime, load average, total tasks, memory/swap usage) and a table listing individual processes with their CPU%, MEM%, PID, user, command, and other details.
Common options
| Flag | What it does |
|---|---|
-b | Batch mode; non-interactive output (useful for logging or piping) |
-n NUM | Exit after NUM iterations instead of running indefinitely |
-d SECONDS | Set refresh interval to SECONDS (e.g., -d 2 for 2-second updates) |
-p PID | Monitor only process with specified PID |
-u USERNAME | Show only processes owned by USERNAME |
-H | Show individual threads instead of processes |
-i | Hide idle and zombie processes |
-1 | Show all logical CPUs (one per line) in header instead of summary |
Examples
Start top and continuously monitor processes, updating every 3 seconds; press 'q' to exit
topPrint a single snapshot in batch mode (non-interactive); useful for scripts
top -b -n 1Monitor only process 1234, refreshing every 1 second
top -d 1 -p 1234Show only processes running as the www-data user
top -u www-dataCapture 5 snapshots of top to a file for later analysis
top -b -n 5 > top_output.txtMonitor threads of process 5678 individually
top -H -p 5678Start top showing each CPU core's usage separately in the header
top -1