Learn About the Linux Command 'free'

Get up to date memory information fast

Hands holding computer hard drive

Daniel Sambraus / Getty Images

What is the Free Command?

The free command is a simple utility for checking the amount of free memory on a Linux or Unix system. It's a command line tool that will let you know how much of your system's physical memory and how much swap space is being used and how much is currently free.

Using 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, and type:

free

Then, press enter. You'll see 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 they're listed in kilobytes(KB). For a more easily readable version, use the '-h' flag.

free -h

Notice how that table is much clearer for human eyes to make sense of.

Linux free human readable

If you'd prefer a different size unit, you can use the '-b' flag to set the output into bytes, '-k' for kilobytes, '-m' for megabytes, and '-g' for gigabytes. Since the default output is in kilobytes and bytes are so small, you'd probably only ever use the megabytes flag and possibly the gigabytes one.

free -m
Linux free command megabytes

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

free -t

You'll still get the individual output, but you'll see a line for the total too.

Linux free command with total

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

free -c 5
Linux free command count

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

free -s 3

That will give you a table of data every three seconds. You can combine it with another flag, like '-h,' too.

free -s 3 -h

That will give you 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 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