Master Linux ‘top’: Decode Real-Time Process Stats & Interactive Commands
This guide walks you through Linux’s top command, explaining its real‑time output—including system load, tasks, CPU and memory usage—and details every interactive key (h, d, f, k, etc.) and command‑line option for customizing displays, sorting, and managing processes.
1. Top Command Output
Top displays a wealth of system information in real time. The default view includes a header with system parameters followed by a list of processes and their attributes.
1.1 System Uptime and Load Average
The top header mirrors the output of the uptime command, showing the current time, how long the system has been up, the number of logged‑in users, and the 1‑, 5‑, and 15‑minute load averages.
You can toggle the uptime display with the l command.
1.2 Tasks
The second line summarizes tasks (processes), indicating the total number of processes and how many are running, sleeping, stopped, or zombie.
Press t to toggle this summary.
1.3 CPU States
The next line shows CPU usage percentages for various modes:
us (user): CPU time spent on un‑nice user processes
sy (system): CPU time spent on kernel processes
ni (nice): CPU time spent on nice‑d user processes
wa (IO wait): Time waiting for I/O completion
hi: Time handling hardware interrupts
si: Time handling software interrupts
st: Time stolen by the hypervisor (when running inside a VM)
Press t to toggle this display.
1.4 Memory Usage
Two lines show memory statistics similar to the free command. The first line reports physical memory (total, used, free, buffers), and the second line reports swap space (total, used, free, buffers).
Press m to toggle memory information.
1.5 Fields/Columns
Below the header, each process is listed in columns. The default columns are:
PID : Process ID
USER : Owner username
PR : Scheduling priority (e.g., rt for real‑time)
NI : Nice value (lower = higher priority)
VIRT : Virtual memory size
RES : Resident (non‑swap) memory size
SHR : Shared memory size
S : Process state (D, R, S, T, Z)
%CPU : CPU usage since last update
%MEM : Physical memory usage percentage
TIME+ : Total CPU time consumed
COMMAND : Command name or full path
Additional columns can be displayed for page faults, group IDs, etc.
2. Interactive Commands
Top is interactive; the following keys modify the display while it runs.
2.1 h / ? : Help
Shows the interactive help menu.
2.2 Enter / Space : Refresh
Manually refreshes the screen (default refresh interval is 3 seconds).
2.3 A : Alternate Display Mode
Switches between full‑screen and an alternate mode that shows four windows (Def, Job, Mem, Usr). Use a and w to cycle windows, or g to jump to a specific window number.
2.4 B : Bold Highlight
Toggles bold display for important information.
2.5 d / s : Set Refresh Interval
Prompts for a new delay in seconds; entering 1 makes top refresh every second.
2.6 l , t , m : Toggle Load, Tasks, Memory
Individually hide or show the load average, task summary, or memory usage sections.
2.7 f : Field Management
Enter the field‑selection screen; use * to mark fields, arrow keys to navigate, and < / > to move selected fields left or right.
2.8 R : Reverse Sort
Toggle between normal and reverse sorting order.
2.9 c : Command/Program Name
Toggle between showing just the command name and the full command line (including path).
2.10 i : Idle Tasks
Show or hide idle (sleeping) tasks.
2.11 V : Tree View
Switches to a hierarchical tree view of processes.
2.12 Z : Color Scheme
Opens a palette to assign colors to the eight task windows.
2.13 z : Toggle Color
Enable or disable colored output.
2.14 x / y : Highlight Columns / Rows
xhighlights the sorted column; y highlights the running process row. Color must be enabled to see the effect.
2.15 u : Filter by User
Prompts for a username; leaving it blank shows all users.
2.16 n / # : Set Max Tasks
Limits the number of displayed tasks.
2.17 k : Kill Task
Sends a signal (default SIGTERM) to a selected process; you can specify a different signal.
2.18 r : Renice
Changes the scheduling priority (nice value) of a selected process.
3. Command‑Line Options
Most interactive commands have equivalent command‑line switches, allowing you to start top with a predefined configuration.
3.1 -b : Batch Mode
Runs top in non‑interactive batch mode, useful for redirecting output to a file.
3.2 -c : Show Full Command Line
Starts top with the full command line displayed (same as pressing c).
3.3 -d seconds
Sets the delay between screen updates. Example: $ top -d 1 This starts top with a 1‑second refresh interval.
3.4 -i : Toggle Idle Processes
Starts top with the opposite of the current idle‑process display state.
3.5 -n iterations
Limits the number of refresh cycles before exiting. Example: $ top -n 3 Top will exit after three updates.
3.6 -p PID
Monitor a specific process ID; 0 refers to the top process itself.
3.7 -u user / -U UID
Show processes belonging to a particular user or UID. These options are mutually exclusive with -p.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
