Code Yarns β€πŸ‘¨β€πŸ’»
Tech Blog ❖ Personal Blog

Free command in Linux

πŸ“… 2016-Jun-15 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ free, memory ⬩ πŸ“š Archive

A common question that occurs to any user of an operating system is how much memory is being used and how much is free. The command to check this in Linux is free.

You run it and it throws up some head-scratching output:

$ free
             total       used       free     shared    buffers     cached
Mem:       5971016    4376120    1594896     210616     237260    2398084
-/+ buffers/cache:    1740776    4230240
Swap:      7885820        304    7885516

Right off the bat you can see that it is showing values in bytes. While this might have been fine back when Unix was invented, it is utterly unreadable with the GBs of RAM we have in today’s computers.

We first fix that by asking it to show human readable output:

$ free --human
             total       used       free     shared    buffers     cached
Mem:          5.7G       4.2G       1.5G       206M       231M       2.3G
-/+ buffers/cache:       1.7G       4.0G
Swap:         7.5G       304K       7.5G

Now we can read the value in GBs and MBs easily.

Some notes about interpreting the output:

Tried with: Ubuntu 15.10


Β© 2022 Ashwin Nanjappa β€’ All writing under CC BY-SA license β€’ 🐘 @codeyarns@hachyderm.io β€’ πŸ“§