Linux is one of the most popular open source operating system and comes with huge set of commands. The most important and single way of determining the total available space of the physical memory and swap memory is by using “free” command.

The Linux “free” command gives information about total used and available space of physical memory and swap memory with buffers used by kernel in Linux/Unix like operating systems.

Here are some examples, all done on RHEL7, the version of 'free' is:

# free -V
free from procps-ng 3.3.10

Display System Memory

Check used and available space of physical memory and swap memory in KB:

# free
              total        used        free      shared  buff/cache   available
Mem:       16268500     4625016      155212      683604    11488272    10645064
Swap:       2097148       86920     2010228

Display Memory in different units

By default, free command output unit is in kb, it also provides different units, -b bytes, -k, kilo bytes, -m, mega etc..

for example:

# free -b
              total        used        free      shared  buff/cache   available
Mem:    16658944000  4738256896   160829440   700018688 11759857664 10899349504
Swap:    2147479552    89092096  2058387456

More options for -k, -m,-g,-t

Display Memory in bytes

       -b, --bytes
              Display the amount of memory in bytes.

       -k, --kilo
              Display the amount of memory in kilobytes.  This is the default.

       -m, --mega
              Display the amount of memory in megabytes.

       -g, --giga
              Display the amount of memory in gigabytes.

       --tera Display the amount of memory in terabytes.

       -h, --human
              Show all output fields automatically scaled to shortest three digit unit and display the units of print out.  Following units are used.

                B = bytes
                K = kilos
                M = megas
                G = gigas
                T = teras

Display Total Line

Free command with -t option, will list the total line at the end.

# free -t
              total        used        free      shared  buff/cache   available
Mem:       16268500     4623516      183492      683612    11461492    10646404
Swap:       2097148       87064     2010084
Total:     18365648     4710580     2193576

Dispaly Memory Status for Regular Intervals

The -s option with number, used to update free command at regular intervals. For example, the below command will update free command every 10 seconds.

# free -s 10
              total        used        free      shared  buff/cache   available
Mem:       16268500     4621592      159248      683620    11487660    10648148
Swap:       2097148       87160     2009988

Show Low and High Memory Statistics

The -l switch displays detailed high and low memory size statistics.

# free -l
              total        used        free      shared  buff/cache   available
Mem:       16268500     4629652      163832      683628    11475016    10641108
Low:       16268500    16104668      163832
High:             0           0           0
Swap:       2097148       87216     200993

free command wide output

# free -w
              total        used        free      shared     buffers       cache   available
Mem:       16268500     4644480      155928      683636         444    11467648    10625152
Swap:       2097148       87272     2009876