Linuxlab

vmstat command in Linux: memory, swap and CPU

Updated July 3, 2026

The vmstat command summarizes processes, memory, swap, disk and CPU on one line.

Syntax

vmstat [interval] [count]

Common cases

vmstat             # a single snapshot
vmstat 2           # refresh every 2 seconds
vmstat 2 5         # five snapshots, 2 seconds apart
vmstat -s          # memory and event counters since boot

How it works: which columns to read

The first vmstat line is an average since boot, so you read from the second. The key columns: r is how many processes are queued for the CPU (more than the core count means a CPU bottleneck), si and so are swap-in and swap-out (any steady non-zero value means you are running low on memory), wa is the share of time the CPU waits on disk. vmstat is a good quick first look: it shows at once where the bottleneck is.

Used in

You need this in the lesson Monitoring. The theory is the chapter Monitoring and bottlenecks.

See also

Memory: free, Load average.

Try it

Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.