AMP AMP

Free Command in Linux with Examples

free Command

The free command provides information about unused and used memory and swap space on any computer running Linux or another Unix-like operating system.

Syntax

free (option)

OPTIONS

free -b = bytes
free -k = kilo bytes
free -m = mega bytes
free -g = giga bytes
free -tera = tera bytes
free -h = human readable
free -o = old model (it means not shows buffers)
free -t = total (it shows total in last line)
free -c = count time (it require S option)
free -s = seconds (you can set delay seconds using S)
free -V = check the version

Display the physical memory in KB

Free command used to check the used and available space of physical memory and swap memory in (KB).

[root@linuxhelp ~]# free
                       total            used           free           shared        buffers     cached
Mem:                   7958716          7243892        714824         455924        760448      2126940
-/+ buffers/cache:     4356504          3602212
Swap:                  16383996         121776         16262220

Display the physical memory in bytes

If you want to display the size of memory in Bytes, use free command with option -b

[root@linuxhelp ~]# free -b
                      total         used         free           shared      buffers     cached
Mem:                  8149725184    7409377280   740347904      475836416   778936320   2182283264
-/+ buffers/cache:    4448157696    3701567488
Swap:                 16777211904   125743104    16651468800

Display the physical memory in Mega bytes

If you want to see the size of the memory in (MB) Megabytes use option as -m.

[root@linuxhelp ~]# free -m 
                     total       used         free     shared    buffers    cached
Mem:                 7772        7053         719      424       743        2051
-/+ buffers/cache:   4258        3513
Swap:                15999       119          15880

Display the physical memory in Giga bytes

With help of using option &ndash g in free command the result will became size of the memory in GB.

[root@linuxhelp ~]# free -g 
                               total      used       free     shared    buffers     cached
Mem:                           7           6          0       0         0           2
-/+ buffers/cache:             4           3
Swap:                          15          0          15

Display the physical memory in total KB with last line

Free command with -t option, will list the total memory in (KB)

[root@linuxhelp ~]# free -t 
                       total           used        free       shared     buffers   cached
Mem:                   7958716         7194132     764584     425560     762100    2090692
-/+ buffers/cache:     4341340         3617376
Swap:                  16383996        122796      16261200
Total:                 24342712        7316928     17025784

Display the physical memory in total MB with last line

Free command with -mt option, will list the total memory in (MB)

[root@linuxhelp ~]# free -mt   
                      total       used        free      shared     buffers     cached
Mem:                  7772        7054        717       440        744         2065
-/+ buffers/cache:    4244        3527
Swap:                 15999       119         15880
Total:                23772       7174        16597

Display the physical memory in total GB with last line

Free command with -gt option, will list the total memory in (GB) at the end of the output

[root@linuxhelp ~]# free -gt   
                           total          used       free     shared    buffers     cached
Mem:                       7              6          0        0         0            2
-/+ buffers/cache:         4              3
Swap:                      15             0          15
Total:                     23             7          16

Display the physical memory in old model

Using option -o with free would display only the PHYSICAL MEMORY and SWAP, it will disabled showing buffer and cache.

[root@linuxhelp ~]# free -o              
                      total         used         free          shared       buffers    cached
Mem:                  7958716       7214032      744684        432888       762968     2097284
Swap:                 16383996      122784       16261212

Display the physical memory in old model in MB

Free command with -mt option, will list the total memory in (MB) at the end of the output

[root@linuxhelp ~]# free -om  
                      total         used        free        shared   buffers  cached
Mem:                  7772          7004        768         415      745      2040
Swap:                 15999         119         15880

Display the physical memory in old model in GB

Free command with using -og option,would display PHYSICAL MEMORY and SWAP only in GB type.

[root@linuxhelp ~]# free -og 
                      total       used       free     shared    buffers     cached
Mem:                   7           6          0        0         0           2
Swap:                  15          0          15

Display the physical memory in old model in GB with total memory

Free command with using -ogt option,would display PHYSICAL MEMORY in GB type with total memory.

[root@linuxhelp ~]# free -ogt  
                    total       used       free     shared    buffers     cached
Mem:                7           6          0        0         0           2
Swap:               15          0          15
Total:              23          7          16

Display the physical memory usage in some regular time interval period

Using option &ndash s with numbers to update free command in regular intervals.

[root@linuxhelp ~]# free -s 5   
                    total          used           free           shared      buffers     cached
Mem:                7958716        7174232        784484         437272      764240      2099472
-/+ buffers/cache:  4310520        3648196
Swap:               16383996       122784         16261212

                    total          used             free        shared       buffers     cached
Mem:                7958716        7175664          783052      437912       764240      2100112
-/+ buffers/cache:  4311312        3647404
Swap:               16383996       122784           16261212

                    total            used        free       shared      buffers   cached
Mem:                7958716          7162100     796616     423060      764244    2085260
-/+ buffers/cache:  4312596          3646120
Swap:               16383996         122784      16261212

Display the physical memory usage in some regular time interval period in MB

[root@linuxhelp ~]# free -ms 5   
                     total         used       free       shared   buffers     cached
Mem:                 7772          7011       760        422      746         2045
-/+ buffers/cache:   4218          3553
Swap:                15999         119        15880

                     total         used        free      shared     buffers     cached
Mem:                 7772          7012        759       421        746         2045
-/+ buffers/cache:   4220          3552
Swap:                15999         119         15880
 
                    total       used       free     shared    buffers     cached
Mem:                7772        7013       759      422       746         2045
-/+ buffers/cache:  4220        3551
Swap:               15999       119        15880

Display the physical memory usage in some regular time interval period in MB with counts

To display the physical memory usage for every 5 seconds in MB with count as 3 execute the below command.

[root@linuxhelp ~]# free -ms 5 -c 3  
                    total       used       free     shared    buffers     cached
Mem:                7772        7030       741      431       747         2055
-/+ buffers/cache:  4228        3544
Swap:               15999       119        15880

                    total       used       free     shared    buffers     cached
Mem:                7772        7013       758      413       747         2037
-/+ buffers/cache:  4229        3542
Swap:               15999       119        15880

                    total       used       free     shared    buffers     cached
Mem:                7772        7022       749      422       747         2045
-/+ buffers/cache:  4229        3542
Swap:               15999       119        15880

To check the free version

Free using option -V, will display free command version

[root@linuxhelp ~]# free -V 
procps version 3.2.8

Display the physical memory in current running process in KB size with total memory

To display the physical memory usage in current running process with total memory in KB execute the below command.

[root@linuxhelp ~]# watch free -t 
Every 2.0s: free -t                            Sat Feb 20 17:19:24 2016
                     total         used          free              shared       buffers     cached
Mem:                 16363608        3645152       12718456          107404       103348      757088
-/+ buffers/cache:   2784716         13578892
Swap:                32767996        0             32767996
Total:               49131604        3645152       45486452

Tag : free command
FAQ
Q
How to know the entire information and option to be available for "free" command?
A
You can use the "--help" (or) man page of "free" command to know the entire information and option to be available for "free" command. Syntax: "free --help" (or) "man free".
Q
How to check the low and high memory statustics using the "free" command?
A
You can use the option of "-l" or "--lohi" with "free" command to check the low and high memory statustics using the "free" command. For Ex: "free -l" (or) "free --lohi".
Q
How to check the version of "free" command in linux?
A
Use the "--version" with "free" command to check the verion in Linux. Syntax: "free --version".
Q
How to Disable Display of Buffer Adjusted Line?
A
You need to specify the option of "-o" with "free" command to disable the Display of Buffer Adjusted Line. For Ex: "free -o".
Q
How to use the free command for Display System Memory in bytes?
A
You can use the option of "-b" with free command to use the free command for Display System Memory in bytes. For Ex: "free -b"