System and processes
The vmstat command
Table of memory, swap, I/O and CPU. With an interval, it repeats every N seconds.
Most useful options
-s, --statsEvent counters and memory statistics since boot. Shown only once-w, --wideWide format, for machines with a lot of memory that break the columns-a, --activeAdds active and inactive memory-S, --unit k|K|m|MMemory units: k = 1000 bytes, K = 1024, m = 1000000, M = 1048576-t, --timestampAppends the time to each line-n, --one-headerPrints the header once, not on each repetitionCopy-ready examples
$ vmstata snapshot of the system. The first row is averages since the last boot, not the current moment.$ vmstat 1 2two reports, one per second. The second one is the current state.$ vmstat -w 2 5five reports two seconds apart, with wide columns.$ vmstat -S M 1memory in M units, one report per second. It repeats until you press Ctrl+C.$ vmstat -sevent and memory counters accumulated since boot.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| vmstat: delay must be positive integer | The interval is 0 or negative. The interval must be a positive whole number of seconds. | Use an interval of 1 or more, for example vmstat 1. |
Typical mistakes
- The r column counts runnable processes or ones waiting for CPU: if it stays high, the CPU is short.
- The first row is always averages since boot, even with an interval. Use vmstat 1 2 and read the second row.
- In si and so, memory is measured per second: a sustained non-zero value means heavy swapping.
Differences from similar commands
FAQ
When is vmstat better than top?
When you want to see activity over time in lines you can save. top is interactive and focuses on processes.
What does wa mean?
The percentage of CPU time spent waiting for disk I/O. If it climbs a lot, the bottleneck is the disk.
Why does the first row look odd?
It is the average since the last boot, not what is happening now. The following rows cover each interval.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course