5 UNIX / Linux free Command Examples

What is free?
5 free examples
Syntax and Options
Related Commands

What is free?

Free displays the total amount of used and free space of physical memory and swap memory in the system.

5 free Examples

1. Display the Current Usage Status of Memory

By default without any options, free command shows the used and free space of physical and swap memory in KB units as shown below,

$ free 
             total       used       free     shared    buffers     cached
Mem:        509336     462216      47120          0      71408     215684
-/+ buffers/cache:     175124     334212
Swap:       915664      11928     903736

2. Switch the free Output in KB, or MB, or GB

Free allows you to display the size of memory space in bytes or KB or MB or GB as shown below,

$ free -b
             total       used       free     shared    buffers     cached
Mem:     521560064  474198016   47362048          0   73826304  220983296
-/+ buffers/cache:  179388416  342171648
Swap:    937639936   12210176  925429760

$ free -k
             total       used       free     shared    buffers     cached
Mem:        509336     463084      46252          0      72104     215804
-/+ buffers/cache:     175176     334160
Swap:       915664      11924     903740

$ free -m
             total       used       free     shared    buffers     cached
Mem:           497        452         45          0         70        210
-/+ buffers/cache:        171        326
Swap:          894         11        882

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

3. Display the Totals Line

To display the totals line at the end, execute free command with -t option as shown below.

$ free -t
             total       used       free     shared    buffers     cached
Mem:        509336     463332      46004          0      72256     215804
-/+ buffers/cache:     175272     334064
Swap:       915664      11924     903740
Total:     1425000     475256     949744

4. Disable Buffer Adjusted Line Display

Free command displays the output with buffer line normally. You can disable that line in the display by using -o option as shown below

$ free -o
             total       used       free     shared    buffers     cached
Mem:        509336     463588      45748          0      72376     215856
Swap:       915664      11924     903740

5. Display the Usage Status Continuously for Regular Intervals

With -s optoin, you can activate the display of free to show it in every regular intervals as shown below.

$ free -s 3
             total       used       free     shared    buffers     cached
Mem:        509336     469604      39732          0      73260     216068
-/+ buffers/cache:     180276     329060
Swap:       915664      11924     903740

             total       used       free     shared    buffers     cached
Mem:        509336     468968      40368          0      73268     216060
-/+ buffers/cache:     179640     329696
Swap:       915664      11924     903740

             total       used       free     shared    buffers     cached
Mem:        509336     469092      40244          0      73272     216068
-/+ buffers/cache:     179752     329584
Swap:       915664      11924     903740

This will show it continously until you stop it.

Syntax and Options

free [-b | -k | -m | -g] [-o] [-s delay ] [-t] [-V]

Short Option Long Option Option Description
-b to show the amount of memory in bytes
-k to show the amount of memory in kilo bytes
-m to show the amount of memory in mega bytes
-g to show the amount of memory in giga bytes
-t to additionally display the line containing the totals
-o to disable the display of buffer adjusted line
-s to display free output in regular intervals.By default the given input intervals considered as seconds.You may also specify floating number for interval in microseconds
-V to display version information


Related Commands

df
du