vmstat

Report virtual memory, CPU, and I/O statistics.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

vmstat provides a snapshot or continuous stream of system resource statistics: processes, memory, swap, block I/O, and CPU time. Ideal for diagnosing high CPU wait (wa column) indicating I/O bottlenecks, or high swap usage.

Common flags
FlagMeaning
-a --activeShow active/inactive memory
-s --statsPrint memory event statistics table
-d --diskShow disk statistics
Examples
vmstat 1 5Sample every 1 second, 5 times · explain & risk-check →
vmstat -sShow comprehensive memory statistics table · explain & risk-check →
vmstat -dShow disk read/write statistics · explain & risk-check →
vmstat 2 | awk 'NR>2 {print $15}' | awk '{sum+=$1} END {print sum/NR"%"}'Calculate average CPU idle over time · explain & risk-check →
Pro tip

Watch the 'wa' (I/O wait) column in `vmstat 1` — consistently above 10-15% indicates disk is the bottleneck, not CPU. This is often misread as a CPU problem.

Related
iostat free top
Open the full explainer →More in System & Processes

Reference text is hand-written and may be incomplete — check man vmstat for your version. Test destructive commands on a non-production system first.