Master Linux top: Decode Real-Time Process Monitoring and Interactive Commands
This article provides a comprehensive guide to the Linux top command, explaining its default output, system uptime, load averages, task summary, CPU and memory usage, field columns, interactive shortcuts, and command‑line options for customizing real‑time process monitoring.
1. Top command output
Linux's top command displays the processes currently running on the system and is one of the most important tools for system administrators, widely used to monitor server load. It is an interactive command with many sub‑commands.
Note: Different distributions may have slight variations; consult the manual pages for your system.
1.1 System uptime and load average
The top header shows information similar to the uptime command, including current time, system uptime, number of logged‑in users, and the average load over the last 5, 10, and 15 minutes. Press l to toggle this display.
1.2 Tasks
The second line summarizes tasks (processes) and their states, showing total processes, running, sleeping, stopped, and zombie counts. Press t to toggle this view.
1.3 CPU states
The next line shows CPU usage percentages for various modes: us (user), sy (system), ni (nice), wa (IO wait), hi (hardware interrupt), si (software interrupt), and st (stolen time in virtualized environments). Press t to toggle.
1.4 Memory usage
Two lines display memory statistics similar to the free command. The first line shows physical memory (total, used, free, buffers) and the second line shows swap space (total, used, free, buffers). Press m to toggle.
1.5 Fields/Columns
Below the system summary, processes are listed in columns. Default columns include:
PID – process identifier
USER – owning user name
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 – memory usage percentage
TIME+ – total CPU time used
COMMAND – command name or full path
2. Interactive commands
Top supports many interactive shortcuts: h or ? – show help menu
Enter or space – refresh display immediately A – toggle alternate display mode (four windows: Def, Job, Mem, Usr) a / w – move between windows; g – jump to a specific window B – toggle bold highlighting d / s – set refresh interval (seconds) l, t, m – toggle load, task, or memory summary f – field management (select columns to display) R – reverse/normal sort order c – toggle full command line display i – toggle idle tasks V – tree view Z – change color scheme for the eight task regions z – toggle color on/off x / y – highlight sorted column or running process u – show processes for a specific user n or # – set maximum number of tasks displayed k – kill a task (send signal) r – renice a task (change priority)
3. Command‑line options
Top can also be started with options that correspond to the interactive commands: -b – batch mode (useful for saving output to a file) -c – start with full command line display -d <seconds> – set delay interval between updates -i – toggle idle process display (inverse of i) -n <iterations> – number of iterations before exiting -p <PID> – monitor a specific PID (0 = top itself) -u <user> or -U <UID> – show processes for a given user; these options are mutually exclusive with -p Using these options allows you to script top for automated monitoring or logging.
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.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
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.
