Linux free Command: Monitor RAM and Swap Usage
The free command in Linux displays the total amount of memory in use and available, as well as cache and swap information.
The "-b", "-k" and "-m" options display the amount in bytes, kilobytes and megabytes, respectively:
$ free total used free shared buff/cache availableMem: 2039524 189396 178424 131684 1671704 1503316Swap: 0 0 0
The -h option displays the amounts in a more human-readable format:
$ free -h total used free shared buff/cache availableMem: 1,9G 153M 205M 128M 1,6G 1,5GSwap: 0B 0B 0B
Below is the meaning of each field:
- total: Total RAM memory installed in the system;
- used: Memory in use (total - free - buffers - cache);
- free: Available memory;
- shared: Memory shared between processes using tmpfs. Processes can allocate memory that they share, for example, with their child processes;
- buffers: Memory used as a transfer area by the kernel;
- cache: Memory used by the memory page cache;
- available Memory available without taking into account the memory used in buffers and cache
In older versions of the free command, the buffer and cache information were displayed in two separate columns, because Linux divided the buffer cache into two categories. The buffer was the memory used by the Kernel, and the cache was the memory used by processes for caching. This information was later combined into a single column.
The free command also displays the amount of memory available and used in swap.
Swap is a disk area that can be used as a swap space for memory pages between RAM and disk, allowing the system to virtually increase memory through paging between memory and disk. It is a feature that can be used to prevent RAM exhaustion.
If the system makes extensive use of swap, it is a strong indication that there is a need to increase the amount of RAM due to system usage.
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, simply log in or create your user here.
Like it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.