Having sufficient physical memory (RAM) on your system is critical for processes to run efficiently.
Once the memory runs out, your system will start using the swap space and this will result to slower performances in input and output operations. Eventually your system will end up freezing should it utilize all the memory and swap space.
It is good practice to monitor the memory usage of your system to ensure that there is enough memory for processes to run optimally.
Memory usage can be monitored using GUI tools but we will be focusing on CLI tools which could be used over SSH.
This is one of the most used command to check memory usage in Linux and Unix-like operating systems. It provides a very accurate way of showing memory usage.
The following arguments can be passed to get more convenient results.
-h in human readble for, -b results in bytes -k results in KB -m results in MB
The free command gives information about the total memory used, available memory and swap memory with buffers.
Check out other arguments and options in the man page
The top command is well known for getting a broad overview of resource usage in Linux, dynamically and in real time.
However, it also reports the total memory available including used and free memory. It can be used to monitor RAM usage .
The /proc/meminfo file
For a more detailed breakdown of memory information in your system, check the /proc/meminfo file
$ cat /proc/meminfo