# How To Check Swap Usage Size and Utilization in Linux

## [https://www.cyberciti.biz/faq/linux-check-swap-usage-command/](https://www.cyberciti.biz/faq/linux-check-swap-usage-command/)

## Check swap usage size and utilization in Linux

The procedure to check swap space usage and size in Linux is as follows:

1. Open a terminal application.
2. To see swap size in Linux, type the command: <kbd>**swapon -s**</kbd>.
3. You can also refer to the <kbd>**/proc/swaps**</kbd> file to see swap areas in use on Linux.
4. Type <kbd>**free -m**</kbd> to see both your ram and your swap space usage in Linux.
5. Finally, one can use the <kbd>**top**</kbd> or <kbd>**htop**</kbd> command to look for swap space Utilization on Linux too.

## How to Check Swap Space in Linux using <kbd>/proc/swaps</kbd> file

Type the following [cat command](https://www.cyberciti.biz/faq/linux-unix-appleosx-bsd-cat-command-examples/ "cat Command in Linux / Unix with examples") to see total and used swap size:

`cat /proc/swaps `  
Sample outputs:

```
Filename				Type		Size	Used	Priority
/dev/sda3                               partition	6291448	65680	0
```

Another option is to type the [grep command](https://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/ "How to use grep command In Linux / UNIX with examples") or [egrep command](https://www.cyberciti.biz/faq/grep-regular-expressions/ "Regular expressions in grep ( regex ) with examples") as follows:

`grep '^Swap' /proc/meminfo`  
Here is what I see:

```
SwapCached:            0 kB
SwapTotal:        524284 kB
SwapFree:         524284 kB
```

## Look for swap space in Linux using <kbd>swapon</kbd> command

Type the following command to show swap usage summary by device

`swapon -s`  
Sample outputs (you may see a filename such as /swap1 instead of a partition such as /dev/sda3):

```
Filename				Type		Size	Used	Priority
/dev/sda3                               partition	6291448	65680	0
```

## Use <kbd>free</kbd> command to monitor swap space usage

Use the free command as follows:

`free -g``free -k`

`free -m`  
Sample outputs (look for swap line):

```
             total       used       free     shared    buffers     cached
Mem:         11909      11645        264          0        324       8980
-/+ buffers/cache:       2341       9568
<strong>Swap:         6143         64       6079</strong>
```

See [Linux Check Memory Usage Using the CLI and GUI](https://www.cyberciti.biz/faq/linux-check-memory-usage/ "Linux Check Memory Usage Using the CLI and GUI") tutorial page for more info.

## See swap size in Linux using <kbd>vmstat</kbd> command

Type the following vmstat command:

`vmstat`

`vmstat 1 5`  
Sample outputs:

```
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 1  9 1209512 101352   1504 127980    0    3    11    20   60   55  3  1 95  1
 2 11 1209640 101292   1508 134132  844  424  5608   964 23280 15012  2  8 20 70
 0 10 1210052 108132   1532 125764  648  660 10548   916 22237 18103  3 10 11 77
 1 13 1209892 106484   1500 128052  796  240 10484   980 24024 12692  2  8 24 67
 1  9 1209332 113412   1500 124028 1608  168  2472   620 28854 13761  2  8 20 70
```

Note down the following output from swap field:

1. si: Amount of memory swapped in from disk (/s).
2. so: Amount of memory swapped to disk (/s).

## <tt>top/atop/htop/glances</tt> Linux commands

<div class="box " id="bkmrk-prerequisiteby-defau"><span style="color: #339966;" title="You need to install an additional package to complete the tutorial">**Prerequisite**</span>  
By default, <tt>htop, atop, and glances</tt> command may not be installed on your system. Hence, use the [apk command](https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ "10 Alpine Linux apk Command Examples") on Alpine Linux, dnf command/[yum command](https://www.cyberciti.biz/faq/rhel-centos-fedora-linux-yum-command-howto/ "How to use the yum command on Linux (CentOS/RHEL)") on RHEL &amp; co, [apt command](https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ "apt Command Examples for Ubuntu/Debian Linux")/[apt-get command](https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html "Ubuntu/Debian Linux apt-get package management cheat sheet") on Debian, Ubuntu &amp; co, zypper command on SUSE/OpenSUSE, pacman command on Arch Linux to install the <tt>htop, atop, and glances</tt>.</div>Type any one of the following command at the CLI:  
`atop``htop``top``glances`  
Sample outputs from top command:

```
top - 02:54:24 up 15:24,  4 users,  load average: 0.45, 4.84, 6.75
Tasks: 266 total,   1 running, 264 sleeping,   0 stopped,   1 zombie
Cpu(s):  3.2%us,  1.4%sy,  0.0%ni, 94.4%id,  1.0%wa,  0.0%hi,  0.1%si,  0.0%st
Mem:   8120568k total,  7673584k used,   446984k free,     4516k buffers
Swap: 15859708k total,  1167408k used, 14692300k free,  1151972k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
13491 vivek     20   0 1137m 279m 6692 S   10  3.5  19:17.47 firefox            
 5663 vivek     10 -10 1564m 1.1g  59m S    8 14.5   5:10.94 vmware-vmx         
 2661 root      20   0  352m 185m 8604 S    6  2.3  65:40.17 Xorg               
 3752 vivek     20   0 3566m 2.6g  12m S    6 33.6  63:44.35 compiz             
 4798 vivek     20   0  900m  50m 4992 S    2  0.6   0:11.04 chrome             
 5539 vivek     20   0 1388m 838m 780m S    2 10.6   1:45.78 VirtualBox         
 6297 root      20   0     0    0    0 S    2  0.0   0:00.15 kworker/2:0        
 6646 root      20   0 19252 1404  936 R    2  0.0   0:00.01 top                
    1 root      20   0  8404  644  608 S    0  0.0   0:03.32 init               
    2 root      20   0     0    0    0 S    0  0.0   0:00.03 kthreadd           
    3 root      20   0     0    0    0 S    0  0.0   0:02.30 ksoftirqd/0        
    6 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/0        
    7 root      RT   0     0    0    0 S    0  0.0   0:00.24 watchdog/0         
   37 root       0 -20     0    0    0 S    0  0.0   0:00.00 cpuset             
   38 root       0 -20     0    0    0 S    0  0.0   0:00.00 khelper            
   39 root      20   0     0    0    0 S    0  0.0   0:00.00 kdevtmpfs          
   40 root       0 -20     0    0    0 S    0  0.0   0:00.00 netns     
```

Sample outputs from htop command:

<div class="wp-caption aligncenter" id="bkmrk-" style="width: 603px;">[![Linux: Swap Memory Usage Command](https://www.cyberciti.biz/media/new/faq/2012/10/swap-htop-output.png "Linux: Swap Memory Usage Command")](https://www.cyberciti.biz/faq/linux-check-swap-usage-command/swap-htop-output/)</div>Fig.01: Linux: Swap Memory Usage Command

<div class="wp-caption aligncenter" id="bkmrk--1" style="width: 603px;"></div>Sample outputs from glances command:  
![Linux Check Swap Usage Size Using glances command](https://www.cyberciti.biz/media/new/faq/2012/10/Linux-Check-Swap-Usage-Size-Using-glances-command.png)  
See [how to keep an eye on your Linux system with glances monitor](https://www.cyberciti.biz/faq/linux-install-glances-monitoring-tool/ "Linux: Keep An Eye On Your System With Glances Monitor") for more info.

## [Linux Find Out What Process Are Using Swap Space](https://www.cyberciti.biz/faq/linux-which-process-is-using-swap/)

Try the smem command:

`smem`  
OR

`top`

## Linux GUI tool to monitor swap space size and usage

Try Gnome or KDE system monitor tool. For example, the **GNOME System Monitor** shows you what programs are running and how much processor time, memory (including paging/swap space size), and disk space are being used.  
![Swap space on Linux displayed using System Monitor](https://www.cyberciti.biz/media/new/faq/2012/10/Swap-space-on-Linux-displayed-using-System-Monitor.png)

##   