If you’re logged in at some remote Linux system and need to quickly confirm the amount of available memory, there’s a few commands you will find quite useful.
free command is the most obvious choice for a first command when it comes to your RAM.
Simply run it without any parameters, and it will show you something like this:
For this exercise, you’re only interested in the “total” column of the first line. 4051792 confirms that my home PC seems to have around 4Gb of memory available for Ubuntu to use.
dmesg command shows you the last status messages reported by your OS kernel, and since every boot procedure includes scanning the hardware and confirming the devices and resources recognized by the kernel, you can see some basic information by using dmesg.
For our purpose, we need to filter out the memory stats:
Once again, the overall amount of memory confirms that 4Gb of RAM were still found during the last time my PC booted up.
/proc/meminfo is one of the special files managed by Linux kernel. It’s a clear text presentation of the most vital memory stats of your system (this means you can do something like cat /proc/meminfo to see all the parameters)
This is what you need to do to get the total size of your physical memory:
That’s it for today, enjoy!