Check Memory Usage in Linux

1, Free command –> The most effective tool for finding the memory usage and other details. The m option displays all data in MBs.

free -m
total used free shared buffers cached
Mem: 22528 14872 7655 1048 0 13497
-/+ buffers/cache: 1374 21153
Swap: 4096 1461 2634

2,/proc/meminfo –> Another way is to read the /proc/meminfo file. The important values can be find from this. Please check sample result.

cat /proc/meminfo
MemTotal: 23068672 kB
MemFree: 7839488 kB
Cached: 13890932 kB
SwapTotal: 4194304 kB
SwapFree: 2697752 kB
Shmem: 1143948 kB

3,vmstat –> The vmstat command with the s option, lays out the memory usage statistics much like the proc command.

vmstat -s
23068672 total memory
15195280 used memory
7472596 active memory
7478680 inactive memory
7873392 free memory
0 buffer memory
13855964 swap cache
4194304 total swap
1496552 used swap
2697752 free swap

4, Top command and htop command will also give all the information. The result from top command is given below.

Mem: 23068672k total, 15279760k used, 7788912k free, 0k buffers
Swap: 4194304k total, 1496184k used, 2698120k free, 13857660k cached

5, Ram information –> To find out hardware information about the installed RAM, use the demidecode command. It reports lots of information about the installed RAM memory.

dmidecode -t 17