Looking to find how much primary memory (RAM) a Linux box has got? I have two ways of doing this. The first is using the free command.

[testuser@testbox ~]$ free
total used free shared buffers cached
Mem: 1921908 432344 1489564 168 47820 254852
-/+ buffers/cache: 129672 1792236
Swap: 2097148 0 2097148

The second is to use the /proc virtual file system. This displays the values in Kilobytes which might be more user-friendly to some

[test@testbox ~]$ more /proc/meminfo | grep ^Mem
MemTotal: 1921908 kB
MemFree: 1489548 kB

I prefer the first when I want to just look at the info and move on. And I tend to go for the second when I need to have this info available for shell scripts, etc. I am sure there are loads of other ways to do this. Have one you prefer? Please share it — along with why you think it works better for you.

Also, the commands above provide loads more information than just free and used memory. Do take a minute to look through their man pages below for future reference.

More Info: manual pages for free and proc(5)

Originally published on Blogger