HxHippy

top

Display Linux processes (dynamic)

Overview

Provides a dynamic real-time view of a running system, displaying a list of the most CPU-intensive tasks and system summary information.

Syntax

top [OPTION]...

Common Options

-d delay, --delay=delay

Specify the delay between screen updates (e.g., -d 5 for 5 seconds).

-n iterations, --iterations=iterations

Specify the maximum number of iterations top should produce before ending.

-p pidlist, --pid=pidlist

Monitor only processes with specified process IDs (e.g., -p 123,456).

-u username, --user=username

Monitor only processes owned by the specified user.

-b, --batch

Batch mode operation. Useful for sending output from top to other programs or to a file.

-i, --ignore-idle

Idle process toggle. If Off, tasks that haven't used CPU since the last update aren't displayed.

-c, --command-line

Command line/Program name toggle. Toggles between showing the command line and the program name when invoking top.

Interactive Commands

KeyAction
h or ?Display help screen.
qQuit top.
kKill a process (prompts for PID and signal).
rRenice a process (prompts for PID and nice value).
P (Shift+p)Sort by CPU usage (default).
M (Shift+m)Sort by Memory usage.
T (Shift+t)Sort by Time/Cumulative time.
N (Shift+n)Sort by PID.
uFilter by user (prompts for username).
1Toggle display of individual CPU states (for multi-core systems).
cToggle display of command name or full command line (interactive).
zToggle color/mono display.
W (Shift+w)Write current configuration to ~/.toprc.
d or sChange update delay (prompts for new delay).

Examples

$ top

Starts top with default settings, interactive mode.

$ top -d 2

Starts top, refreshing every 2 seconds.

$ top -n 5 -b > top_output.txt

Runs top for 5 iterations in batch mode, saving output to top_output.txt.

$ top -u myuser

Shows only processes owned by myuser.

$ top -p 1234,5678

Monitors only PIDs 1234 and 5678.

$ top -F

Starts top, showing full command lines.

$ Inside top, press M

Sorts processes by memory usage.

$ Inside top, press k, then enter PID and signal

Kills a specified process.

processmonitorreal-timecpumemorytaskssystemperformancetop