MemTotal shows
Total usable RAM (i.e., physical RAM minus a few reserved bits and the kernel binary code).
You can’t use that to determine the exact installed memory, except by using heuristics...
To determine the actual installed memory, you should use lshw or dmidecode which will show the size of the installed modules; e.g. from lshw:
*-memory description: System Memory physical id: 4c slot: System board or motherboard size: 32GiB capabilities: ecc configuration: errordetection=ecc
or in more compact form (lshw -class memory -short):
H/W path Device Class Description ========================================================= /0/0 memory 64KiB BIOS /0/47/48 memory 256KiB L1 cache /0/47/49 memory 1MiB L2 cache /0/47/4a memory 8MiB L3 cache /0/4c memory 32GiB System Memory /0/4c/0 memory 8GiB DIMM DDR3 Synchronous 1600 MHz (0.6 ns) /0/4c/1 memory 8GiB DIMM DDR3 Synchronous 1600 MHz (0.6 ns) /0/4c/2 memory 8GiB DIMM DDR3 Synchronous 1600 MHz (0.6 ns) /0/4c/3 memory 8GiB DIMM DDR3 Synchronous 1600 MHz (0.6 ns)
32:echo $((32767184/1000/1000)).free -goutputs gibibytes, all the values quoted from output in the question are gibibytes. That’s appropriate since RAM capacities are bought in gibibyte or tebibyte increments...cat,grep, andecho:awk '$1 == "MemTotal:" { print $2 / 1024 / 1024 }' /proc/meminfo