How to Check Swap Space/Memory/Size on Linux VPS Server

Linux uses swap space as a back up to its physical memory with an overflow area. Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the swap space will gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache. All these four commands will show the allocated swap disk or disks, if any and have been tested on linux CentOS 6, CentOS 7, RHEL 6 and RHEL 7. Your output should look like the followings :

READ  How to Change the Hostname on CentOS 5.5 Server

1. Check Swap Space/Memory/Size using “swapon -s

[root@centos63 ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       2064376 0       -1

2. Check Swap Space/Memory/Size using “cat /proc/swaps

[root@centos63 ~]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       2064376 0       -1

3. Check Swap Space/Memory/Size using “free -m

[root@centos63 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1006        121        885          0          7         71
-/+ buffers/cache:         41        964
Swap:         2015          0       2015

4. Check Swap Space/Memory/Size using “cat /proc/meminfo | grep Swap

[root@centos63 ~]# cat /proc/meminfo | grep Swap
SwapCached:            0 kB
SwapTotal:       2064376 kB
SwapFree:        2064376 kB

Leave a Reply

Your email address will not be published. Required fields are marked *