Monitoring CPU Load with top
A guide to using top to monitor processes and CPU load.
For monitoring your server and quickly identifying processes that consume excessive resources, the top utility is very useful on VPS and dedicated servers. It shows CPU, RAM, and swap usage in real time.
Top displays a list of running processes in a table, showing how much resources each process consumes, including disk activity. This information helps optimize server performance and take action before resource usage becomes critical.
To get started, connect to your server via SSH and run the command top
. Press Enter, and you’ll see a table of processes initially sorted by CPU usage.
Running top and understanding the table
The first two columns show the process ID (PID) and the user who started it (USER).
The next two columns show the process priority (PR) and the nice value (NI) assigned to it.
The remaining columns indicate the resources used by each process:
- VIRT — virtual memory used
- RES — resident (physical) memory used
- SHR — shared memory with other processes
- S — process status: R — running, S — sleeping, Z — zombie
- %CPU — CPU usage percentage
- %MEM — RAM usage percentage
- TIME+ — total CPU time the process has used
- COMMAND — the command or program that started the process
Understanding the summary lines above the table
Useful information isn’t only in the table—look at the first five lines above it for system-wide statistics.
Line 1 — general system load (top)
- current time
- up — system uptime
- users — number of logged-in users
- load average — system load averages over 1, 5, and 15 minutes
A load average below 1 is considered normal for a single-core CPU. A value equal to the number of cores is the upper limit.
Line 2 — process statistics (tasks)
- total — total number of processes
- running — actively running processes
- sleeping — processes waiting for events
- stopped — paused processes
- zombie — processes waiting for their parent to acknowledge termination
Line 3 — CPU usage breakdown (cpu)
- us — CPU usage by user processes
- sy — CPU usage by system processes
- ni — CPU usage by processes with a modified priority (nice)
- id — CPU idle percentage
- wa — CPU waiting for I/O
- hi — hardware interrupts
- si — software interrupts
- st — steal time (CPU time taken by the hypervisor for other tasks; 0 on physical servers)
Lines 4 and 5 — memory and swap usage, showing total (total), used (used), free (free), and buffers/cache (buffers).
Adding columns and sorting in top
By default, the table is sorted by CPU usage (%CPU).
- To sort by memory (%MEM) — press Shift+M
- To sort by process runtime (TIME+) — Shift+T
- To sort by PID — Shift+N
- To return to CPU sorting — Shift+P
Not all columns can be sorted via hotkeys. For example, to see processes using the most SWAP, use the field selection menu (Shift+F).
Use the navigation keys to select SWAP (or another field), press d to add it to the table (an asterisk “*” will appear), then press s to sort by it and exit the menu (ESC). Press x to highlight the sorted column.
Note
A more advanced and convenient tool is atop. You can learn more about it here.
Help
If you run into issues or have questions, contact support through the ticket system.