Operations 14 min read

Master Linux Top: Decode Real-Time Process Stats and Interactive Controls

This guide walks you through Linux’s top command, explaining its default output—including system uptime, load averages, task summary, CPU states, memory usage, and column fields—while detailing the full set of interactive keys and command‑line options for real‑time process monitoring and management.

21CTO
21CTO
21CTO
Master Linux Top: Decode Real-Time Process Stats and Interactive Controls

1. Top command output

The top command displays a wealth of information about the running system, making it an essential tool for administrators to monitor server load and process activity.

1.1 System uptime and load average

The top header shows data similar to the uptime command: current time, how long the system has been up, number of logged‑in users, and the load averages for the past 1, 5, and 15 minutes.

Current time

System uptime

Number of logged‑in users

Load averages for the last 1, 5, and 15 minutes

Press l to toggle the uptime display.

1.2 Tasks

The second line summarizes tasks (processes). It shows the total number of processes and how many are running, sleeping, stopped, or zombie.

Use t to toggle this task summary.

1.3 CPU states

The next line shows CPU usage percentages for various modes.

us

– user processes sy – kernel processes ni – niced user processes wa – I/O wait hi – hardware interrupts si – software interrupts st – stolen time (virtualized environments)

Press t to toggle the CPU view.

1.4 Memory usage

The following two lines resemble the output of free: the first line shows physical memory (total, used, free, buffers) and the second line shows swap memory.

Press m to toggle memory display.

1.5 Fields / Columns

Below the system summary, each process is listed in columns. The default columns are:

PID – process ID

USER – owning user

PR – priority (e.g., rt for real‑time)

NI – nice value

VIRT – virtual memory size

RES – resident (non‑swap) memory

SHR – shared memory

S – process state (D, R, S, T, Z)

%CPU – CPU usage since last update

%MEM – memory usage percentage

TIME+ – total CPU time used

COMMAND – command line

2. Interactive commands

2.1 h / ? : Help

Press h or ? to display the interactive help screen.

2.2 Space / Enter : Refresh display

Top refreshes automatically every few seconds (default 3 s). Press Space or Enter to force an immediate refresh.

2.3 A : Toggle alternate display mode

Switches between full‑screen and alternate mode, where four windows (Def, Job, Mem, Usr) are shown.

Use a and w to move forward/backward among the windows, g to jump to a specific window number.

2.4 B : Toggle bold display

Important information can be shown in bold; B toggles this mode.

2.5 d / s : Set refresh interval

Press d or s to specify a new refresh delay in seconds (e.g., entering 1 makes top refresh every second).

2.6 l / t / m : Toggle load, task, memory info

These keys turn on/off the display of load average, task/CPU summary, and memory summary respectively.

2.7 f : Field management

Enter f to select which columns are displayed; selected fields are marked with *. Navigate with arrow keys, toggle selection with left arrow, confirm with Enter or right arrow, and reorder with < and >.

2.8 R : Reverse sort

Toggle between normal and reverse sorting order.

2.9 c : Toggle command/path display

Switches between showing the full command line (including path) and just the program name.

2.10 i : Show idle tasks

Toggle the visibility of idle processes.

2.11 V : Tree view

Displays processes in a hierarchical tree.

2.12 Z : Change colors

Opens a palette to assign one of eight colors to each of the four task windows.

2.13 z : Toggle color display

Turns colored output on or off.

2.14 x / y : Highlight columns or rows

x

highlights the sorted column, y highlights the running process row (requires color mode).

2.15 u : Show processes of a specific user

Prompts for a username; leaving it blank shows all users.

2.16 n / # : Set maximum number of tasks displayed

Limits the number of tasks shown on screen.

2.17 k : Kill task

Sends a signal (default SIGTERM) to terminate a selected process.

2.18 r : Renice task

Changes the scheduling priority of a selected process.

3. Command‑line options

3.1 -b : Batch mode

Starts top in batch mode, suitable for redirecting output to a file.

3.2 -c : Toggle command/program name

Uses the last remembered setting to show either the full command line or just the program name.

3.3 -d : Set delay interval

Specifies the refresh delay in seconds.

$ top -d 1

This runs top with a one‑second refresh interval.

3.4 -i : Toggle idle process display

Inverts the previous i state.

3.5 -n : Set iteration count

Defines how many updates top will produce before exiting.

$ top -n 3

Top will quit after three refreshes.

3.6 -p : Monitor specific PID

Limits monitoring to the given PID (PID 0 refers to top itself).

3.7 -u / -U : Filter by user name or UID

Shows processes belonging to a specific user or UID. The options -p, -u and -U are mutually exclusive; combining them results in an error.

$ top -p 28453 -u raghu

Attempting to use both -p and -u yields a "conflicting process selections" error.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

process managementLinuxsystem-monitoringtop command
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.