Learn About the Linux Command 'free'

Get up-to-date memory information fast

The free command is a simple utility that checks the amount of free memory on a Linux or Unix system. It's a command-line tool that shows how much of your system's physical memory and how much swap space is used and how much is currently free.

How to Use free

There isn't too much to the free command, and it's easy to get started with it. Open a terminal on your Linux system, type free, then press Enter. The free command displays a table of information about the memory on your system, much like the image below.

Linux Free command

Those numbers are less than ideal. That's because these numbers are listed in kilobytes (KB). For an easy-to-read version, use the -h flag.

free -h

This results in a clearer table.

Linux free human readable

To display the results in a different size unit, use the -b flag to set the output to bytes, -k for kilobytes, -m for megabytes, or -g for gigabytes. Since the default output is in kilobytes and bytes are small, you may only need the megabytes flag and possibly the gigabytes flag.

free -m
Linux free command megabytes

Since a system ultimately lumps swap space in with physical memory, it's useful to see a complete total. That's where the -t flag comes in.

free -t

The individual output displays along with a line for the total.

Linux free command with total

Memory use on a computer continually changes. That's why it's helpful to get a readout over time. You can accomplish this with both the -c flag and the -s flag. Start with -c, which lets you specify a count of how many times you want to get a read.

free -c 5
Linux free command count

The -s flag repeats continually every few seconds, based on the number you provide.

free -s 3

This displays a table of data every three seconds. You can combine it with another flag, like -h.

free -s 3 -h

This displays a more readable output every three seconds.

Linux free command timed

You're now ready to get running with the free command. For a more detailed breakdown of what the command can do, check out the manual below.

Free Command Manual

Name

free — display information about free and used memory on the system

Synopsis

free [-b|-k|-m|-g][-h] [-l] [-t] [-s delay ] [-c count ]

Description

free(1) displays the total amount of free and used physical memory and swap space in the system, as well as the buffers and cache consumed by the kernel.

Options

Normal invocation of free(1) does not require any options. The output, however, can be fine-tuned by specifying one or more of the following flags:

-b, --bytes

Display output in bytes.

-k, --kb

Display output in kilobytes (KB). This is the default.

-m, --mb

Display output in megabytes (MB).

-g, --gb

Display output in gigabytes (GB).

-h, --human

Display human-readable output using simplified numbers and labels.

-l, --lowhigh

Display detailed information about low vs. high memory usage.

-t, --total

Display a total summary for physical memory + swap space.

-c n, --count=n

Display statistics n times, then exit. Used in conjunction with the -s flag. Default is to display only once, unless -s was specified, in which case, default is to repeat until interrupted.

-s n, --repeat=n

Repeat, pausing every n seconds in-between.

-V, --version

Display version information and exit.

--help

Display usage information and exit.