LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

top

Real-time system process monitor

TLDR

Start top
$ top
copy
Do not show any idle or zombie processes
$ top -i
copy
Show only processes owned by a specific user
$ top -u [username]
copy
Sort processes by a field
$ top -o %MEM
copy
Show individual threads of a process
$ top -Hp [process_id]
copy
Monitor specific PIDs
$ top -p [1234],[5678]
copy
Run in batch mode for scripting (single snapshot)
$ top -b -n 1
copy
Set update interval to 5 seconds
$ top -d 5
copy
Show full command lines instead of program names
$ top -c
copy

SYNOPSIS

top [-b] [-c] [-d delay] [-H] [-i] [-n iterations] [-o field] [-p pid] [-S] [-u user] [-w width]

DESCRIPTION

top provides a dynamic real-time view of a running system. It displays system summary information and a list of processes or threads currently being managed by the Linux kernel. The display is updated periodically and can be customized interactively.

PARAMETERS

-b, --batch

Run in batch mode (non-interactive), useful for piping output.
-c, --cmdline-toggle
Toggle between command line and program name display.
-d SECS, --delay=SECS
Set the delay between screen updates (default: 3.0 seconds).
-e, --scale-task-mem
Scale task memory values (k/m/g/t/p).
-E, --scale-summary-mem
Scale summary memory values (k/m/g/t/p/e).
-H, --threads-show
Display individual threads instead of processes.
-i, --idle-toggle
Hide idle and zombie processes.
-n NUMBER, --iterations=NUMBER
Set maximum number of iterations before exit.
-o FIELD, --sort-override=FIELD
Override the default sort field. Prefix with + or - for ascending/descending.
-p PIDLIST, --pid=PIDLIST
Monitor only specified process IDs (comma-separated).
-S, --accum-time-toggle
Toggle cumulative time mode, showing CPU time used by each process and its dead children.
-s, --secure-mode
Start top in secure mode, disabling potentially dangerous interactive commands.
-u USER, --filter-only-euser=USER
Show only processes for specified effective user.
-U USER, --filter-any-user=USER
Show processes for specified user (real, effective, saved, filesystem).
-w WIDTH, --width=WIDTH
Override screen width in batch mode (minimum 80 characters).

INTERACTIVE COMMANDS

h or ?: Display help screenq: Quit topd or s: Change delay between updatesk: Kill a process (prompts for PID and signal)r: Renice a process (prompts for PID and nice value)f: Manage displayed fieldso: Add filter expressionc: Toggle command line/program nameV: Toggle forest view mode1: Toggle single/separate CPU statesm: Cycle memory display modest: Cycle CPU states display modesR: Reverse sort orderP: Sort by CPU usageM: Sort by memory usageT: Sort by cumulative time< or >: Move sort column left/rightW: Write configuration file

PROCESS STATUS CODES

D: Uninterruptible sleepI: Idle kernel threadR: RunningS: Sleeping (interruptible)T: Stopped by job control signalt: Stopped by debuggerZ: Zombie

CAVEATS

The configuration file is saved to ~/.config/procps/toprc. Running in batch mode (-b) is recommended for scripting as it disables interactive features and produces parseable output. The default delay between updates is 3.0 seconds.

HISTORY

top was originally written by Roger Binns and has been part of the procps (now procps-ng) package. It has been a standard system monitoring tool on Unix-like systems since the 1980s.

SEE ALSO

htop(1), atop(1), ps(1), free(1), uptime(1), vmstat(1), kill(1)

Copied to clipboard
Kai