Linux Free Command Tutorial
In the Linux Operating System, some users wish to install applications to check how much is used, and free RAM is available. The installation of those applications might take a large memory size.
Linux provides a “free” built-in command utility. It is a useful command that provides detailed information about the total amount of used memory and free space, swap memory, and buffer used by the kernel.
When you run a “free” command on the terminal, it will show memory in kilobytes by default.
The “free” Command Syntax
“free” command syntax is:
free command
Type “free” command in terminal to get detailed information about RAM:
As you can see, the output is displaying the complete picture of the total, used, free, buffer/cache, shared, and available memory along with swap memory.
free Command Options
Now, let’s explore free command with multiple options:
Unit bytes
-b option is used to show data in bytes. To get it, type the below-mentioned command in the terminal:
Kilobytes
-k option is used to display data in kilobytes (Kbs). Type it in terminal to get result:
Megabytes
-m option is used to display memory information in megabytes (Mbs). Use it in terminal:
Gigabytes
Use -g in command-line to get the result in gigabytes (Gbs). Use the given command:
Total
-t option is used to give an additional “total” column along with total, used, and free space memory information:
Time gap with Counter loop
The “free” command allows you to set a time gap to display output in the command-line, and you can also set the number of counts.
For this, the -s option is used to set a time gap. It will display output with the specific interval of time and use the -c option to set counter loop.
Use the mentioned command in the terminal:
(as you can see, the output is displayed 4 times with a time gap of 4 seconds).
Conclusion
Free command in Linux operating system allows users to get a complete picture of total Ram, how much it is used, and free space. It also shows swap memory and used cache as well. In this tutorial, we have learned how to use the free command with different options to get desired results.