Determining Total System RAM for Use in ZENworks Imaging Scripts


Someone in the Novell Support Forums was asking for some help on how to determine how much total system RAM was in a computer.

If the amount of RAM was greater than 512 megs, then he wanted to restore an add-on image for an application which required 512 megs of RAM to run properly.

I was able to use the following command to output the total amount of system RAM into the variable RAMTOAL:

RAMTOTAL=`free | awk '/Mem:/ {print $2}'`

You can verify this by typing:


On my test system I see the following output:

Note that my total RAM is listed as 516352.

Then type:


The value stored in the variable RAMTOTAL evaluates to 516352.

You could do something similar for "Used RAM" and "Free RAM", though it is probably not as useful:

RAMUSED=`free | awk '/Mem:/ {print $3}'`

RAMFREE=`free | awk '/Mem:/ {print $4}'`


How To-Best Practice
Comment List