Linux Tips: That’s All The Free Memory!?
From time to time, you might have to check the health status of a Linux server. One indicator of good or bad health is how much free memory is available on that server. So how does one check for free memory space in Linux? Well, you type the command free
. Easy, right? There is one catch though: by default, free
will display all memory sizes in kilo bytes. If you don’t know that and you jus type free
on the command line you get this:
$ free
total used free shared buff/cache available
Mem: 131785612 3685824 125870880 440 2228908 127308476
Swap: 4194300 150532 4043768
At first glance, you could look at this and think that the server only has 3.68 MB of free memory left. Don’t panic!! If you want a more accurate reading, just use the -h
option so the results are displayed in human readable format like this:
$ free -h
total used free shared buff/cache available
Mem: 125Gi 3.5Gi 120Gi 0.0Ki 2.1Gi 121Gi
Swap: 4.0Gi 147Mi 3.9Gi
Much better, huh? Looking at this you see that the server, in fact, has 3.5 GB of free memory left. That’s probably enough for it to keep running happily for a while. There is also the top
command which will show free memory in addition to all currently running processes but we can talk about that another time.
Conclusion
If you just need a quick way to see how much free memory is available on a Linux server, use the free
command but don’t forget to provide the -h
option which will display the results in a way that won’t give you a hear attack.