$linuxjunkies
>

top(1)

Display and update sorted information about the most CPU and memory intensive processes.

UbuntuDebianFedoraArch

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

FlagWhat it does
-bBatch mode; non-interactive output (useful for logging or piping)
-n NUMExit after NUM iterations instead of running indefinitely
-d SECONDSSet refresh interval to SECONDS (e.g., -d 2 for 2-second updates)
-p PIDMonitor only process with specified PID
-u USERNAMEShow only processes owned by USERNAME
-HShow individual threads instead of processes
-iHide idle and zombie processes
-1Show 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

top

Print a single snapshot in batch mode (non-interactive); useful for scripts

top -b -n 1

Monitor only process 1234, refreshing every 1 second

top -d 1 -p 1234

Show only processes running as the www-data user

top -u www-data

Capture 5 snapshots of top to a file for later analysis

top -b -n 5 > top_output.txt

Monitor threads of process 5678 individually

top -H -p 5678

Start top showing each CPU core's usage separately in the header

top -1

Related commands