vmstat command in Linux: memory, swap and CPU

Updated November 1, 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

Sample output

$ ( sleep 2; dd if=/dev/zero of=/tmp/w.bin bs=1M count=500 oflag=direct 2>/dev/null ) &
$ vmstat 1 8
procs -----------memory---------- ---swap-- -----io---- -system-- -------cpu-------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st gu
 1  1      0 10348020    160 1073620    0    0  2981   321  941    1  2  0 98  0  0  0
 0  0      0 10352720    160 1074728    0    0     0  1356 1569 3467  1  0 98  0  0  0
 1  0      0 10234860    160 1181660    0    0 106804 34816 2413 4162  1  1 98  0  0  0
 0  0      0 10234460    160 1181776    0    0     0 477184  823 1111  0  1 99  0  0  0
 0  0      0 10234460    160 1181776    0    0     0     0  115  141  0  0 100  0  0  0
...

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.

Common mistakes

bi and bo count kibibytes per second, not 'blocks' as the column name suggests. Writing 500 mebibytes with dd gave bo of 34816 and then 477184; together that is 512000, exactly 500 times 1024. So the row with bo 477184 means about 466 mebibytes went to disk in that one second.

The memory columns are kibibytes too, and the narrow layout hides it: free 10462004 is roughly 10 gibibytes, not 10 mebibytes. vmstat -S M switches them to mebibytes and prints free 10216; vmstat -w widens the columns so long numbers stop running into their neighbours.

The column set changes between versions, so parsing by the last field of a row breaks on a system upgrade. In procps-ng 3.3.17 (Ubuntu 22.04) the cpu block ends at us sy id wa st; in procps-ng 4.0.4 (Ubuntu 24.04) a gu column was appended after st for guest time. A script that read $NF as steal time now reads gu. Parse by the header, or take the numbers from /proc/stat.

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.