The Linux system supports a special file system called PROC in which you can find various file describing the state of the current operating system. There is a file /proc/meminfo which contains information about the size of RAM currently installed on the system and how much of it is being currently used by the Linux kernel.

[neo@techpulp ~]# cat /proc/meminfo
MemTotal:      2009328 kB
MemFree:        385204 kB
Buffers:         58328 kB
Cached:        1251596 kB
SwapCached:          0 kB
Active:         778772 kB
Inactive:       763172 kB
HighTotal:     1113152 kB
HighFree:         1604 kB
LowTotal:       896176 kB
LowFree:        383600 kB
SwapTotal:      883532 kB
SwapFree:       883532 kB
Dirty:             136 kB
Writeback:           0 kB
AnonPages:      231992 kB
Mapped:         591780 kB
Slab:            34480 kB
SReclaimable:    21800 kB
SUnreclaim:      12680 kB
PageTables:       5352 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   1888196 kB
Committed_AS:   715520 kB
VmallocTotal:   114680 kB
VmallocUsed:     49948 kB
VmallocChunk:    63476 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     4096 kB
[neo@techpulp ~]#

The value of MemTotal is the size of RAM you have in the system and MemFree tells you how much memory is free. The value of SwapTotal is the collective size of all swap partitions used by Linux kernel.

Alternately you can use “free” command to get the same information.

[neo@techpulp ~]# free
total       used       free     shared    buffers     cached
Mem:       2009328    1625664     383664          0      58888    1252000
-/+ buffers/cache:     314776    1694552
Swap:       883532          0     883532
[neo@techpulp ~]#