Linux Commands

Linux Free Command Examples

While installing a new software package on a Linux system, we need to check the available system’s memory or RAM. To verify that either enough memory is available on our system or not to install and run new software. For this purpose, Linux free command is used to display the complete summary or a report of memory usage. Using the free command, you can get information about the total amount of swap and physical memory, as well as it provides details about the used and free memory.

We will explain the Linux free command with examples in this article.

Syntax of Linux Free Command

The following syntax is used for free command:

$ free [options]

When the free command run without any option, it only displays the information about memory and swap in kibibytes.

When the free command executes on the terminal, it shows the following details about the memory:

$ free

The following screenshot shows different fields, which are explained below:

Total:  This field shows the total amount of memory and how much is installed on your system.

Used: This column tells how much memory is used currently by running processes. The used memory can be calculated using this formula = total – free – buffer/cache.

Free: This field represents how much memory is free or is not being used by any process.

Shared: This field represents the memory that is being shared by multiple processes.

Buffers: This field shows the amount of memory reserved by the OS kernel. The memory could be allocated further if any application needed memory,

Cached: This field tells the amount of memory that is used to store recent data and files in RAM

Available: This field represents the amount of memory available for starting a new process without memory swapping.

By default, the free command shows the memory usage details on kibibytes. But, if you want to show it in a human-readable format, such as megabytes and gigabytes, then use the option “-h” along with the free command as follows:

$ free –h

If you want to measure the memory usage in other metrics or unit then, using the options, you can change the memory usage measured units such as -b, –bytes (bytes), –kilo (kilobytes), –mega (megabytes), –giga (gigabytes) and more.

For example, to display the memory usage information in megabytes, use the following command:

$ free --mega

Display Total Memory Column

To print the column totals, use the option “-t” along with the free command that gives you memory sum and swap in the total. By using the following command, you can display the total column details in the output:

$ free -h –t

Display Memory Usage Information Continuously

To display the information about the memory usage of a Linux system, use the option “-s” used for seconds and then specify a number or delay as follows:

$ free -s 4

The above command will display the memory usage details after every four seconds. Then, press “Ctrl+c” to exit from the continuous display.

To display the memory usage information for a specified limit, use the following command:

$ free -s 4 -c 6

To get more information about memory usage through the free command, use the following command:

$ man free


We have explained the use of Linux free command with examples in this article. We have also discussed how to check memory usage details and interpret various options. Feel free to ask questions via comments in case of any problems.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.