I\'m typing a shell script to find out the total physical memory in some RHEL linux boxes.
First of all I want to stress that I\'m interested in the total ph
dmidecode -t 17 | grep Size:
Adding all above values displayed after "Size: " will give exact total physical size of all RAM sticks in server.
I find htop
a useful tool.
sudo apt-get install htop
and then
free -m
will give the information you need.
free -h | awk '/Mem\:/ { print $2 }'
This will provide you with the total memory in your system in human readable format and automatically scale to the appropriate unit ( e.g. bytes, KB, MB, or GB).
If you're interested in the physical RAM, use the command dmidecode
. It gives you a lot more information than just that, but depending on your use case, you might also want to know if the 8G in the system come from 2x4GB sticks or 4x2GB sticks.
Add the last 2 entries of /proc/meminfo
, they give you the exact memory present on the host.
Example:
DirectMap4k: 10240 kB
DirectMap2M: 4184064 kB
10240 + 4184064 = 4194304 kB = 4096 MB.
One more useful command:
vmstat -s | grep memory
sample output on my machine is:
2050060 K total memory
1092992 K used memory
743072 K active memory
177084 K inactive memory
957068 K free memory
385388 K buffer memory
another useful command to get memory information is:
free
sample output is:
total used free shared buffers cached
Mem: 2050060 1093324 956736 108 385392 386812
-/+ buffers/cache: 321120 1728940
Swap: 2095100 2732 2092368
One observation here is that, the command free
gives information about swap space also.
The following link may be useful for you:
http://www.linuxnix.com/find-ram-details-in-linuxunix/