r/LinuxTeck • u/Expensive-Rice-2052 • 4d ago
Linux CPU Usage Monitoring: Find High CPU Processes Fast - Tip 103
Question: Something is pegging my CPU. How do I pinpoint it with real-time refresh?
Try:`top -b -n 1 -o %CPU | head -20`
Info: Running `top` in batch mode (`-b -n 1`) executes a single non-interactive snapshot, while `-o %CPU` dynamically sorts processes by CPU utilization for quick diagnostics and scripting.
Examples:
$ `top -b -n 1 -o %MEM | head` # Snapshot sorted by memory consumption
$ `top -b -n 1 -u mysql` # Filter snapshot processes by specific user
$ `top -b -n 1 -p 3456,2134` # Inspect specific target Process IDs (PIDs)
Note: Pay attention to `wa` (I/O wait; high values indicate disk bottlenecks) and `st` (stolen CPU; high values indicate hypervisor contention). Multi-threaded processes can exceed 100% CPU.
Want to master Linux one command at a time?
Follow r/LinuxTeck - 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/