How can I check if swap is active from the command line?
in linux, you can use
cat /proc/meminfo
to see total swap, and free swap (all linux)cat /proc/swaps
to see which swap devices are being used (all linux)swapon -s
to see swap devices and sizes (where swapon is installed)vmstat
for current virtual memory statistics
in Mac OS X, you can use
vm_stat
to see information about virtual memory (swap)ls -lh /private/var/vm/swapfile*
to see how many swap files are being used.
in Solaris, you can use
swap -l
to see swap devices/files, and their sizesswap -s
to see total swap size, used & freevmstat
to see virtual memory statistics
On some systems, "virtual memory" refers only to disk-backed memory devices, and on other systems, like Solaris, Virtual Memory can refer to any user process address space, including tmpfs filesystems (like /tmp) and shared memory space.
Try swapon -s
for a list of current swap devices and other relevant information.
swapon --show
This is a bit better than swapon -s
as it provides human friendly size units such as:
NAME TYPE SIZE USED PRIO
/dev/dm-1 partition 7.5G 563.8M -2
man swap
says:
-s, --summary
Display swap usage summary by device. Equivalent to "cat /proc/swaps". This output format is DEPRECATED in favour of --show that provides better control on output data.
--show[=column...]
Display a definable table of swap areas. See the --help > output for a list of available columns.
Tested in Ubuntu 18.04, util-linux 2.31.1.