Linux free command

Updated: 06/22/2024 by Computer Hope
free command

On Unix-like operating systems, the free command displays the total amount of free and used physical and swap memory, and the buffers used by the kernel.

This page describes the GNU/Linux version of free.

Syntax

free [options]

Options

-b, --bytes Display the amount of memory in bytes.
-k, --kilo Display the amount of memory in kilobytes. This is the default.
-m, --mega Display the amount of memory in megabytes.
-g, --giga Display the amount of memory in gigabytes.
--tera Display the amount of memory in terabytes.
-h, --human Show all output fields automatically scaled to shortest three digit unit and display the units of print out. Following units are used.

B = bytes
K = kilos
M = megas
G = gigas
T = teras

If you have a petabyte of RAM (Random-Access Memory) or swap, the number is in terabytes and your computer is awesome.
-c, --count count Display the result count times. Requires the -s option.
-l, --lohi Show detailed low and high memory statistics.
-o, --old Display the output in old format; the only difference being this option disables the display of the "buffer adjusted" line.
-s,
--seconds
seconds
Continuously display the result delay seconds apart. You may actually specify any floating point number for delay. The usleep system call is used for microsecond resolution delay times.
--si Use power of 1000 not 1024.
-t, --total Display a line showing the column totals.
--help Print help.
-V, --version Display version information.

Examples

free

Running free with no options displays a chart similar to the example below.

             total       used       free     shared    buffers     cached
Mem:       1006708     935872      70836          0     148244     346656
-/+ buffers/cache:     440972     565736
Swap:       262140     130084     132056
Tip

When using the free command, the two important lines are the -/+ buffers/cache line and Swap line. To get a good idea on how much free memory is available, the free section in the buffers/cache is what you should be reading. Linux keeps the contents of memory in the buffers to help having to access the same data over-and-over from the slower disk drive. If your buffers/cache free memory is low or your swap free is low, a memory upgrade is necessary.

free -ms 5

The command above displays the memory in megabytes with the "s 5" telling the system to continuously poll the data and display the results.

watch free

This command is similar to the command mentioned above and uses watch to display the current memory usage.

ps — Report the status of a process or processes.
top — Display a sortable, continually-updated list of processes.
vmstat — Report statistics about virtual memory usage.