Quick take: The vmstat command reports CPU, memory, swap, and I/O statistics in a compact table. vmstat 2 samples every two seconds; watch the wa (I/O wait), si/so (swap), and r (run queue) columns to find bottlenecks.

Introduction

The vmstat command (virtual memory statistics) gives a one-line-per-sample overview of system performance — processes, memory, swap, block I/O, and CPU — in a single compact table. It is the quickest way to tell whether a slow system is bottlenecked on CPU, memory, swap, or disk.

Syntax

The basic syntax of the vmstat command is:

vmstat [OPTIONS] [INTERVAL [COUNT]]

Reading the Key Columns

vmstat's columns tell a performance story once you know where to look:

  • r (procs) — processes waiting for CPU. Consistently higher than your core count means CPU pressure.
  • si / so (swap) — memory swapped in/out. Non-zero values mean the system is swapping, a sign of memory pressure.
  • bi / bo (io) — blocks read from and written to disk.
  • wa (cpu) — percentage of time the CPU waited on disk I/O. High wa points to a storage bottleneck, not a CPU one.
  • us / sy / id — CPU time in user code, kernel, and idle.

The first line is an average since boot; ignore it and read the subsequent samples for current behaviour.

Common Options and Parameters

The most useful options and parameters for the vmstat command:

OptionDescription
INTERVALSeconds between samples (e.g. vmstat 2).
COUNTNumber of samples to take then stop.
-sShow a summary table of memory statistics.
-dShow per-disk I/O statistics.
-aShow active/inactive memory.
-wWide output for readability.
-S MDisplay values in megabytes.

Practical Examples

Real vmstat commands you can run today:

# One snapshot
vmstat
# Sample every 2 seconds
vmstat 2
# Five samples, one per second
vmstat 1 5
# Memory summary
vmstat -s
# Per-disk I/O
vmstat -d
# Wide output in megabytes
vmstat -w -S M 2

Tips and Best Practices

  • Ignore the first row — it is an average since boot. The real picture is in the rows that follow when you sample with an interval.
  • High wa means the CPU is waiting on disk; the fix is faster storage or less I/O, not a faster CPU.
  • Non-zero si/so indicates active swapping — confirm memory pressure with free -h.

Final Thoughts

vmstat condenses CPU, memory, swap, and I/O into one compact table, making it the fastest way to classify a performance problem. Sample with an interval, skip the first averaged row, and read the r, wa, and si/so columns to tell CPU, disk, and memory bottlenecks apart. Pair it with free, top, and iostat for the full picture.

FAQ: vmstat Command in Linux

What does vmstat show?+

vmstat reports system performance in one table: processes waiting, memory and swap usage, block I/O, and CPU breakdown. It is ideal for quickly seeing whether a system is limited by CPU, memory, or disk.

How do I sample vmstat over time?+

Add an interval in seconds: vmstat 2 prints a new line every two seconds. Add a count, like vmstat 2 10, to take ten samples then stop.

Why should I ignore the first line of vmstat?+

The first row shows averages since the system booted, which rarely reflects current behaviour. Read the subsequent rows produced by the sampling interval instead.

How do I tell if a system is disk-bound with vmstat?+

Watch the wa (I/O wait) column. A high wa percentage means the CPU is spending time waiting for disk, indicating a storage bottleneck rather than a CPU one.

How do I know if the system is swapping?+

Look at the si and so columns (swap in and out). Consistently non-zero values mean the system is swapping memory to disk, a clear sign of memory pressure — confirm with free -h.

Need help with Linux servers or infrastructure?

Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.

Hire Me for Support