Linux - How to calculate total memory in terminal, Covert Kilobytes to Megabytes or gigabytes through terminal
How to calculate total memory in terminal
When I tried to run size of my memory, I executed below command and found the result in KB# grep 'MemTotal' /proc/meminfo
I can also run free -m or free -g to read the output in MB or GB. But when I have list of values in a text file and convert
those values from KB to GB, then below calculation was very hand for getting the value and perfor calculation.
# free -m # free -g
# grep 'MemTotal' /proc/meminfo | echo "scale=2; $(awk '{print $2}') / 1024^2" | bc
# grep 'MemTotal' /proc/meminfo | awk '{$1=$2/(1024^2); printf("%.2f\n", $1) ;}'
You can check the size and current usage of swap space by running the command
# grep SwapTotal /proc/meminfo
The topic on Linux - How to calculate total memory in terminal is posted by - Ramya
Hope you have enjoyed, Linux - How to calculate total memory in terminalThanks for your time