[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedApril 15, 2023

How to use Free Command.

How To Use Free Command.

The free command provides information about the total amount of the physical and swap memory, as well as the free and used memory.

In Linux systems, you can use the free command to get a detailed report on the system’s memory usage.

How much free RAM memory do I have available on my Linux system? Is there enough free memory to install and run new applications?

How to Use the free Command

The syntax for the free command is as follows:

free [OPTIONS]

When used without any option, the free command will display information about the memory and swap in kibibyte. 1 kibibyte (KiB) is 1024 bytes.

free

The output will include three lines, a header, one line for the memory and one for the swap:

             total        used        free      shared  buff/cache   available
Mem:        5943436      249356     4913988       82424      780092     5295168
Swap:       2046972           0     2046972

In older Linux versions, the output may be slightly different.

Here’s what each column mean:

  • total – This number represents the total amount of memory that can be used by the applications.

  • used – Used memory. It is calculated as: used = total – free – buffers – cache

  • free – Free / Unused memory.

  • shared – This column can be ignored as it has no meaning. It is here only for backward compatibility.

  • buff/cache – The combined memory used by the kernel buffers and page cache and slabs. This memory can be reclaimed at any time if needed by the applications. If you want buffers and cache to be displayed in two separate columns, use the -w option.

  • available – An estimate of the amount of memory that is available for starting new applications, without swapping.

Showing Memory Usage in Human Readable Format

By default, the free command shows the memory information in kibibyte. To view the information in human-readable format (usually megabytes and gigabytes), use the -h option:

free -h
       total        used        free      shared  buff/cache   available
Mem:           5.7G        240M        4.7G         80M        761M        5.1G
Swap:          2.0G          0B        2.0G

Showing Memory Usage in Other Metrics

The free command also allows you to specify the unit in which the memory is measured. Valid options are:

  • -b, –bytes – Display output in bytes.

  • –kilo – Display output in kilobytes (1KB = 1000bytes).

  • –mega – Display output in megabytes.

  • –giga – Display output in gigabytes.

  • –tera – Display output in terabytes.

  • -k, –kibi – Display output in kibibytes. (1KiB = 1024bytes). This is the default unit.

  • -m, –mebi – Display output in mebibytes.

  • -g, –gibi – Display output in gibytes.

  • –tebi – Display output in tebibytes.

  • –peti – Display output in pebibytes.

  • –si – Instead of 1024, use powers of 1000. For example –mebi –si is equal to –mega.

For example, to show the output in megabytes, you would type:

free --mega
               total        used        free      shared  buff/cache   available
Mem:           5804         240        4802          80         761        5174
Swap:          1998           0        1998
             

Showing the Column Totals

To display a line showing the column totals, use the -t option. This gives you a sum of the memory and swap in the total, used and free columns.

free -h -t
             total        used        free      shared  buff/cache   available
Mem:           5.7G        240M        4.7G         80M        761M        5.1G
Swap:          2.0G          0B        2.0G
Total:         7.6G        240M        6.6G

Continuously Print the Output

To continuously display the memory information on the screen, invoke free with the -s (–seconds) option followed by a number that specifies the delay.

For example, to print the memory information every five seconds you would run:

free -s 5

The free command will continue to display the result until you press CTRL+C. This is similar to the behavior of the watch command .

To display the result for a specific number of times, use the -c (–count) option. In the example below the command will print the result ten times:

free -s 5 -c 10

Conclusion

We have shown you how to use the free command to check the system’s memory usage and interpret the command output. To view all available options type man free in your terminal.

Keep reading
How To Use And Understand Linux Screen.
July 8, 2023

How To Use And Understand Linux Screen.

How To Use Linux Screen. Screen or GNU Screen is a terminal multiplexer. In other words, it means that you can start a screen session and then open any number of windows (virtual terminals) inside that session. Processes running in Screen will continue to run when their window is not visible even…

Read article
How to use and understand  wget command.
July 8, 2023

How to use and understand wget command.

How To Use Wget Command. This article shows how to use the wget command through practical examples and detailed explanations of the most common options. How to install wget: Installing Wget on Ubuntu and Debian sudo apt install wget Installing Wget on CentOS and Fedora sudo yum install wget Wget…

Read article
How to Add User to Group in Linux.
July 8, 2023

How to Add User to Group in Linux.

How To Add User To Group. In this tutorial, we will explain how to add a user to a group in Linux systems. We will also show you how to remove a user from a group and how to create, delete, and list groups. How to Add an Existing User to a Group To…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00