Can anyone let me know whether there is a command to know the RAM capacity in GB?
I have tried cat /proc/meminfo and free.But its not in GB. I need to use it in script.
Thanks and Regards
Can anyone let me know whether there is a command to know the RAM capacity in GB?
I have tried cat /proc/meminfo and free.But its not in GB. I need to use it in script.
Thanks and Regards
Assuming cat /proc/meminfo prints
root: total: used: free: shared: buffers: cached:
Mem: 1055760384 1041887232 13873152 0 100417536 711233536
Swap: 1077501952 8540160 1068961792
MemTotal: 1031016 kB
MemFree: 13548 kB
MemShared: 0 kB
Buffers: 98064 kB
Cached: 692320 kB
SwapCached: 2244 kB
Active: 563112 kB
Inact_dirty: 309584 kB
Inact_clean: 79508 kB
Inact_target: 190440 kB
HighTotal: 130992 kB
HighFree: 1876 kB
LowTotal: 900024 kB
LowFree: 11672 kB
SwapTotal: 1052248 kB
SwapFree: 1043908 kB
Committed_AS: 332340 kB
The values in the second and the third line of the above output are in Bytes.
If you want to calculate GB out from Bytes, the formula is like this: Bytes/1024/1024/1024
cat /proc/meminfo | awk '/^Mem:/ {print $2/1024/1024/1024"GB", $3/1024/1024/1024"GB", $4/1024/1024/1024"GB"}'
0,983253GB 0,970333GB 0,0129204GB
$
Also note that:
MemTotal: 1031016 kB
is the result of Bytes/1024
try this
# free -g
personally, I am partial to this command and I alias it to meminfo on all my machines:
vmstat -s -S M | egrep 'mem|swap'
#free -g
this command can list the RAM size and swap size in GB