Linux – Get information about installed memory

OnĀ Ubuntu you’ll get the all memory (RAM) information with:

$> cat /proc/meminfo

Example output:

MemTotal:       32829172 kB
MemFree:        27614092 kB
Buffers:          350460 kB
Cached:          2232256 kB
SwapCached:            0 kB
Active:          2629788 kB
Inactive:        1925788 kB
Active(anon):    1989372 kB
Inactive(anon):   443036 kB
Active(file):     640416 kB
Inactive(file):  1482752 kB
Unevictable:        6056 kB
Mlocked:            6056 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:               132 kB
Writeback:             0 kB
AnonPages:       1978976 kB
Mapped:           415752 kB
Shmem:            456036 kB
Slab:             312908 kB
SReclaimable:     222648 kB
SUnreclaim:        90260 kB
KernelStack:        6280 kB
PageTables:        69272 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    16414584 kB
Committed_AS:    8421580 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      456724 kB
VmallocChunk:   34359244120 kB
HardwareCorrupted:     0 kB
AnonHugePages:    636928 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       93824 kB
DirectMap2M:    33341440 kB

If you only want to get the amount of installed memory, you can use grepĀ to filter the output:

$> grep MemTotal /proc/meminfo

Example output:

MemTotal:       32829172 kB

To get the the amount of free memory you can simply use:

$> free

Example output:

             total       used       free     shared    buffers     cached
Mem:      32829172    5208016   27621156     467832     351376    2247940
-/+ buffers/cache:    2608700   30220472
Swap:            0          0          0

It also gives you information about cache and swap (@see http://wiki.ubuntuusers.de/Swap) usage.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.