Master Linux’s top Command: Real‑Time Process Monitoring Made Easy
This guide introduces the Linux top command, explains its syntax and common options, details interactive key commands, and provides practical examples for monitoring processes, CPU, memory, threads, and specific users, helping users efficiently diagnose system performance issues.
The top command is a powerful command‑line tool for real‑time monitoring of system processes and resource usage on Linux, displaying a continuously updated list of running processes with CPU, memory, I/O, and other metrics.
Syntax
Run top --help to see usage information; the basic form is:
top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]For detailed documentation, use man top.
Common Options
-d seconds: Set the refresh interval (default 3 seconds). -n iterations: Limit the number of updates; default is infinite. -p pid: Show information for specific process IDs (comma‑separated). -u user: Show only processes owned by the given user. -H: Display processes in a hierarchical (parent/child) view. -i: Hide idle processes. -b: Run in batch mode, suitable for redirecting output to a file.
Interactive Commands
Press k : Kill the selected process.
Press t : Toggle display of CPU, memory, and other fields.
Press m : Sort by memory usage.
Press P : Sort by CPU usage.
Press h : Show the help screen.
Press q : Quit top.
Examples
1. Display the default top view:
top2. Update every 5 seconds and exit after 10 iterations:
top -d 5 -n 103. Show information for a specific PID (e.g., 11):
top -p 114. Show all threads of a specific PID:
top -H -p 115. Display CPU usage for all cores (press 1 after starting top):
6. Show the command‑line arguments of each process:
top -H -c -p 122107. Show processes owned by a specific user (e.g., root):
top -u rootIn summary, the top command provides a real‑time view of system processes and resource consumption, enabling users to quickly identify bottlenecks and performance issues, making it an essential tool for Linux system administration.
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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
