Real-Time System Monitor
The top command provides a real-time, dynamic view of your Linux system, showing live updates of running processes, CPU usage, memory consumption, and system load—refreshing automatically every few seconds.
Think of top like Windows Task Manager, but running in your terminal. It's essential for system administrators because it updates live, letting you watch what's happening right now. You can see which process is suddenly eating all your CPU, monitor memory usage over time, identify runaway processes before they crash your server, track system load averages, and even kill problematic processes directly from the interface. Unlike ps which shows a snapshot, top keeps you informed continuously.
Advertisement
[ Insert Google AdSense Banner Code Here ]
Quickly identify which process is hogging resources.
Watch CPU and memory usage change in real-time.
Track processes that keep consuming more memory over time.
Press 'k' in top to terminate a problematic process by PID.
top Start monitoring system in real-time (default sorted by CPU usage).
top -u username Show processes only for a specific user (replace "username" with: root, mysql, www-data, postgres, or user).
top -p 1234 Monitor specific process ID (PID 1234).
top -d 5 Set refresh delay to 5 seconds (default is 3 seconds).
Shows system load over 1, 5, and 15 minutes. On a single CPU, 1.0 = 100% busy. Higher numbers mean processes are waiting.
Percentage of CPU time used by each process. Can exceed 100% on multi-core systems.
Percentage of physical RAM used by the process.
VIRT = total virtual memory, RES = physical RAM actually used, SHR = shared memory with other processes.
R = Running, S = Sleeping (waiting), D = Uninterruptible sleep, Z = Zombie, T = Stopped.
Exit with 'q': Don't try Ctrl+C to quit top - press q to exit cleanly.
top vs htop: htop is a more user-friendly alternative with colors, mouse support, and easier navigation. Install it with sudo apt install htop.
Don't panic at high CPU: Brief spikes to 100% CPU are normal. Only worry if it stays high constantly or if load average exceeds your CPU count for extended periods.
Experience the live top command simulator below. Click "Start top" to begin monitoring, and use the buttons to sort and control the display: