Skip to content

Free Linux command (memory usage)

Free Linux command shows the amount of total memory in use and available, as well as cache and swap information.

The “-b”, “-k” and “-m” options show the amount in bytes, kbytes, and megabytes respectively:

$ free
total used free shared buff/cache available
Mem: 2039524 189396 178424 131684 1671704 1503316
Swap: 0 0 0

The -h option shows the quantities in an easier to read way:

$ free -h
total used free shared buff/cache available
Mem: 1.9G 153M 205M 128M 1.6G 1.5G
Swap: 0B 0B 0B

Below is the meaning of each field:

  • total: Total RAM installed in the system;
  • used: Memory used (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 clipboard by the kernel;
  • cache: Memory used by the cache of memory pages;
  • available memory regardless of the memory used in buffers and caching

In old versions of the free command, buffer and cache information were separated into two 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. It was decided to combine this information in a single column.

The free command also shows the amount of memory available and used in swap.

Swap is a disk area that can be used as a space for exchanging memory pages between RAM and disk, making it possible to virtually increase system memory through pagination between memory and disk. It is a feature that can be used to avoid running out of RAM memory.

If the system makes extensive use of Swap, it is a strong indication that there is a need to increase the amount of RAM depending on the use of the system.