free command in Linux with examples

Today we will learn the free command, which is mainly used in Linux and Unix OS to check the usage of memory on Server and Desktop.

So, today we will learn how we can use the free command in Linux with example and check the current usage, swap space, total available memory, cache memory, and many more parameters guys.

Kindly refer the link so you can practice with us while learning the POST, it will take 40 to 50 seconds to boot the image.

$ free 
output:
     total     used    free    shared  buff/cache available
Mem: 20234892 3535924 13113088 647624  3585880    15688300
Swap:3999740     0    3999740

-k option to check in kibibytes.

$ free -k
output:
     total    used    free      shared  buff/cache available
Mem: 20234892 3487516 13135104  662132  3612272    15722108
Swap:3999740    0     3999740

This is the default value set in the free command, If you just use the free command you get the same output.

Now If you want the Output in kilobytes, So how you will use free command.

$ free --kilo
output:
     total    used    free     shared  buff/cache available
Mem: 20720529 2603667 15539732 466477  2577129    17312907
Swap:4095733    0     4095733

You knew that there is a difference between kibibytes and kilobytes, the same applies to the MiB and MB, GiB and GB… so on.

1. The kiB, MiB, GiB, and so on are the Binary System.

2. The KB, MB, GB, and so on are the Decimal System.

-m option to check in mebibytes.

$ free -m 
output:
     total used free  shared  buff/cache  available
Mem: 19760 2503 14051   430      3205      16467
Swap:3905   0   3905

We got the output in mebibytes, Now check out with megabytes.

$ free --mega  
output:
     total used free   shared  buff/cache  available
Mem: 20234 2598 12830   445       4806       16823
Swap:3999   0   3999

-g option to check in mebibytes and –giga to check in gigabytes.

$ free -g 
output:
     total used free shared buff/cache available
Mem: 19     2    12    0        4          15
Swap: 3     0     3

$ free --giga
output:
     total used free shared buff/cache available
Mem:  20    2    12     0       4        16
Swap: 3     0    3

So, you can see the difference clearly now, there is something know as human-readable.

-h option for human readable
$ free -h
output:
     total  used  free  shared  buff/cache available
Mem:  19G   2.6G   12G   454M     4.5G       15G
Swap: 3.8G   0B    3.8G

With this option, we can clearly see the output in the human-readable format.

-c option to display the result in count

So, count is used to print the free command output as many time we want.

Now, in our case, it displays output three times, because we have used -c 3 and it has displayed in 3 seconds.

-s option to display the result in given time

Suppose we want to check the usage of Memory in every two seconds.

So, we have used with -h option for the human readable.

Now we will learn the output parameters of the free command.
total: The total RAM or Memory there in our Server.
used: The RAM or Memory used by your Applications.
free: The RAM or Memory that is not used by our Server.
shared: The RAM or Memory that is used by tmpfs. tmpfs is a file system that keeps the files in the virtual Memory.
buff/cache: This is the sum of buffer memory and cache memory.
available: How much RAM or Memory is available to start the new application.

So, Guys Now Time for Fun Play So Quiz

[wp_quiz id=”1257″]

free command cheat sheet
1. How to check RAM size in kibibytes.

Example:
#free -k
2. How to check RAM size in kilobytes.

Example:
#free --kilo
3. How to check RAM size in mebibytes.

Example:
#free -m
4. How to check RAM size in megabytes.

Example:
#free --mega
5. How to check RAM size in gibibytes.

Example:
#free -g
6. How to check RAM size in gigabytes.

Example:
#free --giga
7. How to check RAM size in human readable format.

Example:
#free -h
8. How to check RAM size in terabytes and petabytes.

Example:
#free --tera  //for terabytes
#free --peta //for petabytes
9. How to check RAM utlization in every seconds

Example:
#free -s
10. How to check RAM utlization in every 5 seconds till 10 count

Example:
#free -s 5 -c 10

Thank you so much to read this article, you can refer to more basic commands.

2 Replies to “free command in Linux with examples

Give your valuable time