12 free Command Examples to Check Memory Usage in Linux

A Linux server that shows almost no free memory is often perfectly healthy. The old way of reading free output makes that harder to recognize. Here’s how to interpret the current free command and use its options to monitor RAM and swap.

Most Linux administrators run free within the first minute of logging in to a slow server because it provides a quick snapshot of memory usage.

The problem is that many older guides, describe an output format that modern systems no longer use. The familiar -/+ buffers/cache line is gone, and options such as -o may no longer be supported.

The free command is part of the procps-ng package and reads memory statistics from /proc/meminfo, a virtual file maintained by the Linux kernel. Its output has evolved over the years, most notably with the addition of the available column and changes to how used memory is calculated and this guide explains how to interpret modern free output and use its current options to monitor memory and swap.

The examples in this guide were tested on Ubuntu 26.04 LTS and Rocky Linux 10. Commands and output may vary slightly across distributions and procps-ng versions, so check free --help on your system when an option behaves differently.

How the free Command Reads Memory in Linux

Before running the examples, it helps to understand where the numbers come from. Once you know what each value represents, the output becomes much easier to interpret.

Linux uses otherwise-unused RAM for the page cache, which stores recently accessed file data in memory so subsequent reads can avoid slower disk access.

The kernel also uses memory for buffers and other caches. As a result, the free column on a busy server can be very small without indicating a memory problem.

Much of this cached memory can be reclaimed when applications need RAM, although reclaiming it depends on the type of memory and the current system workload.

That is why the available column is generally more useful than free when assessing memory pressure. It comes from the MemAvailable field in /proc/meminfo and estimates how much memory can be made available to new applications without swapping. The estimate accounts for reclaimable cache and other kernel memory considerations.

The free manual page (man 1 free) documents the output columns. Here is what each one means in plain language:

  • total is the total usable RAM or swap available to the system, which may be less than the installed physical memory because of hardware reservations and other limitations.
  • used is the amount of memory reported as used. In procps-ng 4.0.1 and later, it is calculated as total - available. Older versions use a different calculation, so their output may not match newer versions or older monitoring scripts.
  • free is memory that is currently unused. It does not include memory occupied by applications, buffers, or caches.
  • shared is memory primarily used by tmpfs filesystems, such as /dev/shm, although the value can include other shared-memory allocations.
  • buff/cache combines memory used for kernel buffers and caches, including the page cache. Much of this memory can be reclaimed when needed.
  • available estimates how much memory is available for new applications without having to swap. It is usually the most useful column for a quick assessment of RAM availability, although it does not guarantee that swapping will never occur.

What Changed Since Older free Versions

If you are following older guides or maintaining existing scripts, several changes in free are worth knowing because they can affect how you interpret memory usage and parse command output.

  • The -/+ buffers/cache line: This line disappeared in procps-ng 3.3.10, which introduced the available column in its place. Scripts that depend on fixed line numbers may accidentally read the swap line instead of the expected memory statistics.
  • The -o and --old options: Older versions supported -o to suppress the buffer-adjusted line. Modern versions no longer need this option because that line has been removed. Check free --help on your system before using legacy commands.
  • Memory units: The -k, -m, and -g options display values in kibibytes, mebibytes, and gibibytes, respectively, using powers of 1024. For decimal units based on powers of 1000, use --kilo, --mega, or –-giga.
  • The used column: In procps-ng 4.0.1 and later, used is calculated as total - available. Older versions use a different calculation, so the reported value can differ even on the same system.
  • Additional output options: Modern versions support useful options such as -h for human-readable units, -w for separate buffer and cache columns, -c for a specified number of repeated reports when used with -s, -L for single-line output, and -v for committed-memory statistics. Check the installed manual page because supported options depend on the version.

Check That the free Command Is Installed

The free command is normally included in standard Linux installations, but some minimal container images omit it. If it is missing, you may see an error such as bash: free: command not found.

On Ubuntu and Debian, the package is named procps. Install it with:

sudo apt update
sudo apt install -y procps

On Rocky Linux, AlmaLinux, RHEL, and Fedora, the package is generally named procps-ng. Install it with:

sudo dnf install -y procps-ng

Once installed, check the version:

free -V

Output:

free from procps-ng 4.0.4

Ubuntu 26.04 packages procps 4.0.4, while Rocky Linux 10 repositories provide procps-ng 4.0.4. The exact package release and version may vary with various Linux distribution updates and enabled repositories. Check your system’s output before relying on a particular option or calculation.

The examples in this guide target procps-ng 4.0.4. If your system uses an older release, consult free --help and man 1 free to confirm which options it supports.

1. Display System Memory with the free Command

With the version confirmed, start by running free without any options. It displays RAM and swap statistics in kibibytes by default.

free

Example output:

              total        used        free      shared  buff/cache   available
Mem:         3990272      612480     2104316       18224     1273476     3377792
Swap:        2097148           0     2097148

This server has approximately 3.8 GiB of RAM. Although about 2.0 GiB is completely free, approximately 3.2 GiB is available for applications because much of the memory in buff/cache can be reclaimed.

The swap line shows approximately 2 GiB of configured swap, with none currently in use. That is useful information, but zero swap usage is not a requirement for a healthy system. Check memory pressure and swap activity alongside these figures when diagnosing performance problems.

2. Show Human-Readable Output with free -h

Raw kibibyte values are difficult to interpret at a glance. The -h option scales the values to readable units and adds the appropriate suffix.

free -h

Example output:

               total        used        free      shared  buff/cache   available
Mem:           3.8Gi       598Mi       2.0Gi        17Mi       1.2Gi       3.2Gi
Swap:          2.0Gi          0B       2.0Gi

The Gi and Mi suffixes stand for gibibytes and mebibytes, respectively, using powers of 1024. This is the same type of information shown by the default command, presented in a more readable format.

For quick checks during troubleshooting, free -h is often the most convenient choice.

3. Display Memory in Bytes, KiB, MiB, or GiB

Human-readable output is convenient for administrators, but fixed units are often more useful when comparing measurements or processing command output. The -b, -k, -m, and -g options select the unit, while --tebi and --pebi support larger units on systems with substantial memory.

  • -b, --bytes displays values in bytes.
  • -k, --kibi displays values in kibibytes. This is the default when no unit is specified.
  • -m, --mebi displays values in mebibytes.
  • -g, --gibi displays values in gibibytes. Because the output uses whole units, smaller amounts of memory can be hidden by rounding down.
  • --tebi and --pebi display values in tebibytes and pebibytes, respectively, where supported by the installed version.

For example, to display memory in mebibytes, run:

free -m

Example output:

               total        used        free      shared  buff/cache   available
Mem:            3896         598        2054          17        1243        3298
Swap:           2047           0        2047

The values are now easier to compare in a consistent unit. Keep in mind that displayed values may be rounded or truncated, depending on the selected unit and procps-ng version. If you are writing monitoring scripts, verify the output format and parsing assumptions against the version deployed on your systems.

4. Use Decimal Units with free –si and –mega

The unit options covered earlier use powers of 1024, but disk manufacturers, cloud providers, and some monitoring dashboards use powers of 1000. To display memory in decimal units, use --kilo, --mega, --giga, or --tera. You can also combine -h with --si for human-readable output using decimal units.

For example, to display memory in megabytes, run:

free --mega

Example output:

               total        used        free      shared  buff/cache   available
Mem:            4086         627        2154          18        1304        3458
Swap:           2147           0        2147

The same system now reports approximately 4,086 MB of RAM instead of 3,896 MiB. These values describe the same amount of memory using different units: 1 MB equals 1,000,000 bytes, while 1 MiB equals 1,048,576 bytes.

This distinction explains why a cloud server advertised with 4 GB of RAM may show a different figure when you run free -h. The installed memory is not necessarily missing; the difference may simply come from how the units are measured.

If this cleared up why your memory figures never matched what your hosting provider advertised, share it with someone who is still trying to work out where their missing RAM went.

If this cleared up why your free output never matched what your hosting provider advertised, share it with someone who’s still trying to work out where their missing RAM went.

5. Split Buffers and Cache with free -w

So far, the buff/cache column has appeared as a single value, which is sufficient for a quick memory check. When investigating memory usage in more detail, it can help to see buffers and cache separately. The -w (wide) option does exactly that.

free -h -w

Example output:

               total        used        free      shared     buffers       cache   available
Mem:           3.8Gi       598Mi       2.0Gi        17Mi        96Mi       1.1Gi       3.2Gi
Swap:          2.0Gi          0B       2.0Gi

The buffers column represents memory used for kernel buffers, corresponding to the Buffers field in /proc/meminfo. It is often relatively small.

The cache column includes the page cache and reclaimable kernel slab memory, corresponding to the Cached and SReclaimable fields in /proc/meminfo. This memory helps Linux avoid unnecessary disk access and can often be reclaimed when applications need more RAM.

A growing cache value is not automatically a problem. To determine whether memory is under pressure, also check available, swap activity, and other memory-pressure indicators.

6. Show Combined RAM and Swap Totals with free -t

Sometimes you need a quick view of the combined RAM and swap totals, such as when estimating the memory resources available to a workload. The -t option adds a Total line that combines the RAM and swap figures.

free -t

Example output:

               total        used        free      shared  buff/cache   available
Mem:         3990272      612480     2104316       18224     1273476     3377792
Swap:        2097148           0     2097148
Total:       6087420      612480     4201464

In this example, the system has approximately 3.8 GiB of RAM and 2.0 GiB of swap, giving a combined total of about 5.8 GiB in the displayed accounting.

However, RAM and swap are not interchangeable. RAM provides much faster access, while swap uses disk-backed storage and can introduce substantial latency. The combined Total line is useful for understanding the overall memory accounting, but it does not tell you how much RAM is available without swapping or how much memory a workload can use before performance degrades.

For capacity planning, consider the available column alongside actual workload requirements, swap activity, and memory pressure rather than relying on the combined total alone.

7. Watch Memory at Regular Intervals with free -s and -c

A single snapshot shows only one moment, but memory problems often develop while a deployment, backup, or other workload is running. The -s option repeats the output at a specified interval, while -c limits the number of reports so the command exits automatically.

free -h -s 5 -c 3

Example output:

               total        used        free      shared  buff/cache   available
Mem:            31Gi       6.5Gi        22Gi       503Mi       3.1Gi        24Gi
Swap:             0B          0B          0B

               total        used        free      shared  buff/cache   available
Mem:            31Gi       6.5Gi        22Gi       533Mi       3.2Gi        24Gi
Swap:             0B          0B          0B

               total        used        free      shared  buff/cache   available
Mem:            31Gi       6.5Gi        22Gi       483Mi       3.1Gi        24Gi
Swap:             0B          0B          0B

The -s option accepts fractional intervals, such as 0.5, for half-second updates. If you omit -c, the command continues until you stop it with Ctrl+C.

Repeated snapshots help you spot changes in memory usage, but they do not reveal the entire picture. If available memory keeps falling or swap usage increases, investigate the workload and check memory pressure before deciding whether the server needs more RAM.

8. Print Memory Statistics on One Line with free -L

Repeated output can scroll quickly and be difficult to compare, especially when monitoring memory over time. The -L option, introduced in procps-ng 4.0.4, prints the statistics on a single line, making the output easier to scan or collect in a log.

free -h -L -s 5 -c 3

Example output:

SwapUse          0B CachUse       3.1Gi  MemUse       6.4Gi MemFree        22Gi 
SwapUse          0B CachUse       3.1Gi  MemUse       6.3Gi MemFree        22Gi 
SwapUse          0B CachUse       3.1Gi  MemUse       6.3Gi MemFree        22Gi 

The labels represent selected memory statistics:

  • SwapUse is the amount of swap currently used.
  • CachUse is the combined buffers-and-cache figure.
  • MemUse is the reported memory usage.
  • MemFree is the amount of completely unused RAM.

The exact formatting and spacing can vary with the installed version and output units. This format does not include available, so use the standard output when you need to assess how much memory can be made available to applications.

9. Show Committed Memory with free -v

The previous examples show current memory statistics, but Linux also tracks memory commitments: the amount of memory the kernel has promised to applications. This is not necessarily the same as the physical RAM they have actually touched or are currently using.

The -v option adds a Comm row showing the commit limit, committed memory, and the difference between them.

free -h -v

Example output:

               total        used        free      shared  buff/cache   available
Mem:            31Gi       6.5Gi        22Gi       500Mi       3.1Gi        24Gi
Swap:             0B          0B          0B
Comm:           15Gi        51Gi       -35Gi

In the Comm row, total represents the commit limit, used represents committed memory, and free represents the difference between the two. The `free` value can be negative when committed memory exceeds the limit.

This information is particularly useful when Linux memory overcommit is disabled by setting vm.overcommit_memory = 2. Under this policy, the kernel restricts commitments that would exceed the applicable commit limit, and some memory-allocation requests can fail even when free -h reports available RAM.

However, allocation failures depend on the allocation type and system policy. A negative committed-memory balance is not, by itself, proof that every new allocation will fail. Consult the kernel’s overcommit settings and /proc/meminfo when diagnosing such problems.

10. Show Low and High Memory with free -l

The -l option displays detailed low- and high-memory statistics. This distinction is most relevant to older 32-bit Linux systems, where the kernel historically divided physical memory into regions it could address directly and regions requiring additional mapping.

free -l

Example output on a system where the low/high distinction is applicable:

               total        used        free      shared  buff/cache   available
Mem:        32588184     7070268    23178584      462872     3239432    25517916
Low:        32588184     9409600    23178584
High:              0           0           0
Swap:              0           0           0

The exact values depend on the kernel architecture and the memory zones it reports. On many modern 64-bit systems, the high-memory row is zero or the distinction is not useful for routine troubleshooting.

For most contemporary servers, free -h is sufficient for everyday memory checks. Use free -l when investigating low/high memory behavior on a system where that distinction matters.

11. See How the Page Cache Changes free Output

Now let’s put the theory from the start of this guide to the test. Watching the page cache grow helps explain why a low free value does not necessarily indicate a memory problem. We’ll write a 1 GiB file and compare memory statistics before and after.

First, take a baseline reading:

free -h

Example output:

               total        used        free      shared  buff/cache   available
Mem:            31Gi       6.6Gi        22Gi       516Mi       3.2Gi        24Gi
Swap:             0B          0B          0B

Next, write a 1 GiB file of random data into your home directory:

dd if=/dev/urandom of=~/cache-test.img bs=1M count=1024 status=progress

This writes data through the filesystem, where it can occupy page-cache memory. The actual memory changes depend on the filesystem, kernel, and current memory pressure.

Run free -h again:

free -h

Example output:

               total        used        free      shared  buff/cache   available
Mem:            31Gi       6.7Gi        21Gi       516Mi       4.2Gi        24Gi
Swap:             0B          0B          0B

In this example, free has dropped by about 1 GiB and buff/cache has increased by a similar amount, while available has barely changed.

This illustrates how Linux can use otherwise-unused RAM for cached file data without significantly reducing the memory available to applications.

Your results may differ because Linux can reclaim cache under memory pressure, and writing a file does not guarantee a specific change in the reported values.

Finally, remove the test file:

rm ~/cache-test.img
free -h

Removing the file makes its storage available for reuse, but the kernel may retain cached pages temporarily. Do not expect buff/cache to return immediately to its original value.

If this example made the buff/cache column easier to understand, share it with a teammate who keeps getting paged about low-free-memory alerts.

12. Check Available Memory in a Script with free -b

The previous example demonstrated why available is generally more useful than `free` when assessing memory pressure. You can use it in a monitoring script that warns when available memory drops below 10% of total RAM.

Create the script:

sudo nano /usr/local/bin/memcheck.sh

If nano is not installed, use another editor, such as vi:

sudo vi /usr/local/bin/memcheck.sh

Add the following content:

#!/usr/bin/env bash
# /usr/local/bin/memcheck.sh
set -euo pipefail

THRESHOLD=10

read -r total available < <(free -b | awk '/^Mem:/ {print $2, $7}')
percent=$(( available * 100 / total ))

if (( percent < THRESHOLD )); then
    logger -t memcheck "only ${percent}% memory available on $(hostname)"
    echo "WARNING: only ${percent}% memory available"
    exit 1
fi

echo "OK: ${percent}% memory available"

Save the file and exit the editor. Here is what the important lines do:

  • THRESHOLD=10 sets the warning threshold to 10% of total RAM. Adjust it to suit your workload and monitoring requirements.
  • free -b displays memory values in bytes, avoiding the unit scaling used by human-readable output.
  • awk '/^Mem:/ {print $2, $7}' extracts total and available memory from the standard `free` output. These field positions assume the normal output format, without -w.
  • logger -t memcheck sends the warning to the system logging facility. On systems using the systemd journal, you can usually retrieve it with journalctl -t memcheck.
  • exit 1 returns a non-zero status when the threshold is breached, allowing cron wrappers, systemd units, or monitoring agents to detect the warning.

Make the script executable and run it using its full path:

sudo chmod +x /usr/local/bin/memcheck.sh
/usr/local/bin/memcheck.sh

Example output:

OK: 84% memory available

The percentage shown will depend on the system’s current memory state.

To run the check every five minutes, open root’s crontab:

sudo crontab -e

Add this line:

*/5 * * * * /usr/local/bin/memcheck.sh >/dev/null

The >/dev/null redirect suppresses standard output, including the normal OK message. Warnings are still sent to the system logger, and the script returns a non-zero exit status when the threshold is breached.

However, cron does not automatically alert you just because a command returns a non-zero status; configure a separate monitoring or alerting mechanism if you need to be notified.

Important: A 10% available-memory threshold is only an example. For production systems, consider workload behavior, swap activity, memory pressure, and the duration of the condition before treating low available memory as an incident.

Tips for Reading free Output on Production Servers

With the script in place, you can catch real memory pressure automatically, and a few habits will help you read free correctly when you’re checking a server by hand.

Judge memory pressure by the available column and by swap activity, not by free. A small amount of swap in use is normal, because the kernel moves pages that haven’t been touched for a long time out of RAM.

Swap becomes a problem when it keeps growing while available keeps shrinking, which you can confirm by watching the si and so columns in vmstat 5, since those show pages moving in and out of swap right now.

Avoid running echo 3 > /proc/sys/vm/drop_caches to “free up memory”. It makes the free column look better for a few minutes, but the kernel then has to read everything back from disk, so applications slow down while the cache refills. The kernel already releases cache automatically when applications need memory, as the page cache example showed.

When available really is low, free tells you that there is a problem but not which process is causing it. The next step is ps -eo pid,comm,rss --sort=-rss | head to list the processes using the most resident memory, followed by journalctl -k | grep -i 'out of memory' to check whether the kernel’s OOM killer, which is the kernel feature that stops a process when memory runs out, has already ended something.

Finally, remember that inside a container free reads the host’s /proc/meminfo, so it shows the host’s memory rather than the container’s limit, unless the runtime uses a tool such as LXCFS to provide a container-specific view. To see a container’s real limit, check its cgroup files, such as /sys/fs/cgroup/memory.max on cgroup v2 systems.

If you manage containers and have ever been confused by free showing the host’s RAM, share this with your DevOps team so nobody sizes a container from the wrong numbers.
Conclusion

You now know how to read the current free output, why the available column matters more than free, and which options replace the ones that older guides still mention. You also have a small script that checks available memory automatically and logs a warning when a server starts running short.

If you’d like to go beyond free and learn the tools that show which processes are using memory, CPU, and disk, our Linux Performance Monitoring Tools course walks through top, htop, vmstat, iostat, and sar with real troubleshooting examples. For a wider set of everyday commands like this one, the 100+ Essential Linux Commands course is a good next step.

We’d love to hear how you check memory on your own servers. Do you rely on free -h, a monitoring agent, or something like htop?

Have you ever had a script break because of the old -/+ buffers/cache line? Feel free to share your memory check one-liners or paste a confusing free output in the comments, and we’ll help you read it.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

Ravi Saive
Ravi Saive
Administrator
About the author

I'm Ravi Saive, an award-winning entrepreneur and founder of several successful 5-figure online businesses, including TecMint.com, GeeksMint.com, UbuntuMint.com, and the premium learning hub Pro.Tecmint.com.

20 Comments

Leave a Reply
  1. How to find out RAM Memory details on an embedded system?

    I know from /proc/meminfo vstat, free etc, but none of the commands give you exact RAM i have.

    Example, I have checked on a system where i know the RAM size of 256 Mb, but none of the above command displays 256Mb.

    is that correct or am i missing something?

    Reply
  2. Nice and neat info. I believe you meant all the mentioned kb, mb, gb are actually kibi, mebi and gibi rather than kilo, mega and giga.

    Reply
    • @Sathish,

      We already explained each switch used with free command in this article, I hope you gone through it each point, still I will update you that free -m is used to show the amount of memory in megabytes.

      Reply
  3. Hi,
    I am newbie to linux. I am practising ubuntu in vmware workstation installed in PC. How do i surf internet using ubuntu while i am in vmware workstation ? Please assist.

    Reply
  4. Thank you for the share, great read. How can I reduce the memory consumption used? I am using a virtual box with ubuntu 14.04 LTS. I have only 82M of 500M free memory left?
    I might guess it is because the low memory I have assigned to Virtual machine 512M upon initialising it.

    Reply
    • @Sinan,
      500MB is not enough to run Ubuntu 14.04, you need at least 1G or 2G of ram to run Ubuntu properly..or else you can stop some unwanted applications to reduce memory consumption, you need to use top command to trace the applications which are utilizing high ram usage..

      Reply
  5. @Sara

    That’s not related to memory as df is used to report file system disk space usage, free is the memory (RAM) and swap usage.

    Reply
  6. TQ & 5* i give to you … im newbie in linux … this is my 2nd linux (ubuntu 14.04) 1st i use (fedora19) sory my english .. i read your all your post (tecmint).. & TQ again for good post.. (y)

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.