The free in Linux command

We continue with more Linux commands. This time we are going to explore the free in Linux command. This command is also basic to use, but it can get us out of an important predicament.

The free command in Linux

The free command belongs to a family of commands for Unix operating systems that allows us to know the memory usage of the system.

By memory, we always mean RAM or main system memory. Thanks to free, we can quickly know what is the use we are giving it. That is to say, we will be able to know how much is used, and how much is available.

Although the free command does not have many options and learning to use it is simple and fast, it is one of those commands that is always good to have on hand to know how the system works.

Being a basic command of the Unix family, it is available in all Linux distributions. This means that we don’t have to install anything or do any additional steps.

So let’s go for it.

Using the free command in Linux

As we said, the free command is available from your favorite Linux distribution. All we have to do is open our terminal and start using it.

If you use the free command without any parameters defined, then you will get an output similar to this.

free
The free command
The free command

In this output, we can see that there are several columns like total, used, free, shared, buffers/ cached. Each of these specifies the memory usage.

  • total: The amount of memory the computer has.
  • used: the amount of memory used.
  • free: this column shows the amount of free memory in the system.
  • shared which is the memory used by the tmpfs file system. This feature is no longer used.
  • buffers: This is the memory reserved for buffers.
  • cached: Amount of memory dedicated to the cache.
  • Available: A system estimate of the amount of memory available.

The last row shows information about the swap.

More uses

As we can notice, it is a simple command to use, but it expresses the amounts in a not very understandable format. To improve it, you can use the -h option.

free -h
Using the free command
Using the free command

As we can notice, now the units are expressed in a better and more understandable format for humans.

Using the -t option, you can add a row called total at the end of the output to totalize. It’s like a summary of the totals of the main and swap memory.

free -h -t

If you want to do more continuous monitoring, you can specify the number of times to run the command. All this thanks to the -c option.

free -h -t -c [N]

Remember, you have to replace [N] by an integer that specifies the repetitions.

free -h -t -c 3

Or if you want to make it continuous but set an interval of seconds, you can use the -s option

free -h -s [N]

For example,

free -h -s 2

And to end the execution of the command, you can press the CTRL + C keys.

So, as you can see, it is easy to use the free command in Linux.

Conclusion

The free command although it is one of the simplest that you can find, the truth is that it can help us a lot in the memory management of our computer.

I hope you liked this post and help us to grow by sharing it with your friends.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top