Table of Contents

free - How to use free command in Linux



Help

man free

#man free

NAME
       free - Display amount of free and used memory in the system

OPTIONS
       -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

free -h

[root@localhost ~]# free -h
free: invalid option -- h
usage: free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c count] [-V]
  -b,-k,-m,-g show output in bytes, KB, MB, or GB
  -l show detailed low and high memory statistics
  -o use old format (no -/+buffers/cache line)
  -t display total for RAM + swap
  -s update every [delay] seconds
  -c update [count] times
  -V display version information and exit
[root@localhost ~]#


Example

RHEL7/CentOS7

# free -m
              total        used        free      shared  buff/cache   available
Mem:            992         381          87          53         524         357
Swap:          2047           7        2040

Total : 992MB
Used Memory : 635MB = 992MB - 357MB
Free Memory : 357MB

RHEL6/CentOS6

[root@localhost ~]# free
             total       used       free     shared    buffers     cached
Mem:        515488     169284     346204          0       9040     127436
-/+ buffers/cache:      32808     482680
Swap:      1048568          0    1048568

Total : 515488Kbyte
Used Memory: 32808Kbyte = 169284Kbyte - 9040Kbyte - 127436Kbyte
Free Memory: 482680Kbyte = 346204Kbyte + 9040Kbyte + 127436Kbyte

[root@localhost ~]# free -m
             total       used       free     shared    buffers     cached
Mem:           503        165        338          0          8        124
-/+ buffers/cache:         32        471
Swap:         1023          0       1023

Total : 503MB
Used Memory:32MB = 165MB - 8MB - 124MB
Free Memory:471MB = 338MB + 8MB + 124MB


Explanation

RHEL7/CentOS7

Used Memory  = Total - Available
Free Memory = Available

RHEL6/CentOS6

Used Memory  =used - buffers - cached
Free Memory = free + buffers + cached