Conducting continuous monitoring of RAM usage is important to optimize performance and identify potential problems. In this article, we will look at various commands and tools in Linux that will help you check your RAM consumption.


Checking with the free command

free is one of the main commands for monitoring RAM usage. It provides total, used, free and used memory space, as well as swap information. Just type free command on your server


Checking with the top command

top provides dynamically updated statistics on system resource usage. To display memory statistics, just run the followinf word:


Checking with the htop command

The next way to check is with the htop command. It is a graphical interface for the top command. Type htop and you will get this:

Checking with the ps command

A very interesting team – ps. It is designed to display all the current processes running on your server. Using the –sort=-%mem flag you will see the processes in descending order of memory usage:

ps aux --sort=-%mem

You will be aware of the details as the command will show the following options: USER; PID; %CPU; %MEM; VSZ; RSS; TTY; STAT; START; TIME; COMMAND

Checking with smem ps command

The next command is called smem and it provides a report of the memory consumption of processes. Before you can use it successfully, you need to install the necessary packages. Use the following command

apt-get install smem

yum install smem