Monitoring and diagnostics

Command free

Show memory usage

Linux · Bash examples · commands run on the selected server

When to use free

Use free to inspect Linux memory accounting before deciding that a server is running out of memory. Cached data can often be reclaimed, so available memory is usually more informative than the unused value alone.

Syntax

free [PARAMETERS]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-h
Human readable units.
-m
Dimensions in mebibytes.
-s N
Repeat output at intervals of N seconds.

Usage examples

Check memory

free -h

Memory and swap figures are shown in human-readable units.

Take three measurements

free -m -s 2 -c 3

Three samples are collected at two-second intervals for a short comparison.

View exact bytes

free -b

Values are reported in bytes for more precise capture.

Notes and limitations

  • To estimate the memory reserve, see available, and not only free: part of the cache can be freed.
  • Container data may reflect host memory; separately consider the limits cgroup.

Common questions and troubleshooting

Does a low free value prove memory exhaustion?

No. Linux uses spare RAM for cache. Inspect available memory, swap activity and application behaviour before drawing that conclusion.

Why do container limits differ from free output?

Host-wide accounting and container control-group limits can differ depending on environment and tool version. Inspect the container's actual resource limits.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man free.