How to use free command on Linux

Photo of author

By rasho

The free command provides information about unused and used memory and swap space on any computer running Linux or another Unix-like operating system.
In this article we will show you useful examples of free commands.
The basic syntax of free command is:

free [options]

Show system memory

If you want to see available space of physical memory and swap memory in KB type free on your terminal:

# free
             total       used       free     shared    buffers     cached
Mem:       1020224     909720     110504      22736      26916     134908
-/+ buffers/cache:     747896     272328
Swap:            0          0          0

Display memory in bytes, kilobytes, megabytes and gigabytes

To show all of the data in bytes type free in your terminal with -b options:

# free -b
             total       used       free     shared    buffers     cached
Mem:    1044709376  867233792  177475584   23498752   17244160  109359104
-/+ buffers/cache:  740630528  304078848
Swap:            0          0          0

[ads]
To show all of the data megabytes type free in your terminal with -m options:

# free -m
             total       used       free     shared    buffers     cached
Mem:           996        826        169         22         25        106
-/+ buffers/cache:        694        301
Swap:            0          0          0

To show all of the data gigabytes type free in your terminal with -g options:

# free -g
             total       used       free     shared    buffers     cached
Mem:             0          0          0          0          0          0
-/+ buffers/cache:          0          0
Swap:            0          0          0

Other free command options

If you want to see a total memory ( including the swap), use the -t option, which will display a total line as shown below.

# free -t
             total       used       free     shared    buffers     cached
Mem:       1020224     872744     147480      23888      27376     114620
-/+ buffers/cache:     730748     289476
Swap:            0          0          0
Total:     1020224     872744     147480

The -s options activates continuous polling delay seconds apart. For example, the following would provide new data every five seconds and display the output in megabits:

# free -ms 5

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

# free -mt
             total       used       free     shared    buffers     cached
Mem:           996        782        213         23         27        116
-/+ buffers/cache:        638        357
Swap:            0          0          0
Total:         996        782        213

For more information about free command type man free in your terminal.

1 thought on “How to use free command on Linux”

Leave a Comment