How can I find out the total physical memory (RAM) of my linux box suitable to be parsed by a shell script?

前端 未结 13 1812
梦如初夏
梦如初夏 2020-12-07 09:52

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

13条回答
  •  再見小時候
    2020-12-07 10:15

    In Linux Kernel, present pages are physical pages of RAM which kernel can see. Literally, present pages is total size of RAM in 4KB unit.

    grep present /proc/zoneinfo | awk '{sum+=$2}END{print sum*4,"KB"}'
    

    The 'MemTotal' form /proc/meminfo is the total size of memory managed by buddy system.And we can also compute it like this:

    grep managed /proc/zoneinfo | awk '{sum+=$2}END{print sum*4,"KB"}'
    

提交回复
热议问题