$linuxjunkies
>

vmstat(8)

vmstat reports virtual memory statistics and system activity including processes, memory, paging, block I/O, interrupts, and CPU usage.

UbuntuDebianFedoraArch

Synopsis

vmstat [options] [delay [count]]

Description

vmstat displays one-line summaries of key system statistics including processes, memory usage (real and virtual), page swaps, block I/O operations, interrupts, and CPU time allocation. It's useful for identifying performance bottlenecks related to memory, I/O, and CPU contention.

When invoked with a delay parameter, vmstat reports statistics continuously at the specified interval in seconds. The optional count parameter limits the number of reports; without it, vmstat runs indefinitely. The first report shows averages since system boot; subsequent reports show activity during the interval.

Common options

FlagWhat it does
-adisplay active and inactive memory instead of buffer and cache
-fdisplay the number of forks since boot
-mdisplay memory statistics in megabytes
-ndisplay only one header line (useful with repeated sampling)
-p partitiondisplay partition statistics (disk I/O for specific partition)
-sdisplay a summary of memory and fork statistics since boot
-ddisplay disk statistics instead of default output
-wwiden output (wider column format for better readability)
-tadd timestamp to each report
--helpdisplay help message and exit

Examples

show system statistics every 1 second for 5 iterations (good for quick snapshots)

vmstat 1 5

continuously report statistics every 2 seconds until interrupted

vmstat 2

show 10 reports at 1-second intervals with a single header line for cleaner output

vmstat -n 1 10 | head -20

display summary statistics since last boot including total memory, forks, and disk I/O

vmstat -s

report memory statistics in megabytes at 3-second intervals, 5 times

vmstat -m 3 5

show disk I/O statistics every 1 second for 3 iterations

vmstat -d 1 3

monitor active/inactive memory and process queue lengths every second

vmstat -a 1 | grep -E 'procs|r b'

log system statistics every 5 seconds for 500 seconds to a file in the background

vmstat 5 100 > /tmp/vmstat.log &

Related commands