Understanding the free Command in Linux
One of the most common things that Linux users and admins do is keep an eye on system memory. The free command is one of the easiest and most useful tools you can use to find out how your system uses memory or fix performance problems.
In this post, I’ll talk about what the free command does, how to read its output, and give some real-life examples.
What is the free command?
The Linux command “free” shows information about how much memory your system is using, such as:
- Total memory available
- Used and free memory
- Buffers and cache memory usage
- Swap space statistics
It provides a quick snapshot of how your RAM and swap are being utilized.
Basic Syntax
free [options]
If you simply run:
free You’ll get an output similar to this:
total used free shared buff/cache available
Mem: 972160 120344 631688 448 220128 711300
Swap: 2097148 0 2097148
Let’s break it down.
Understanding the Output Columns
1. total
The total amount of physical RAM or swap memory in your system.
2. used
The memory that is currently being used by running processes and the system cache.
3. free
The memory that is completely unallocated (not used at all).
4. shared
Memory that is shared between processes (commonly used by tmpfs).
5. buff/cache
Memory used by the kernel for buffers and cache.
Linux uses free memory for caching files to improve performance – but this memory is released automatically when needed by applications.
6. available
This is the most important value – it shows how much memory is actually available for new applications without swapping.
Example with Human-Readable Format
To make the output easier to read, use the -h (human-readable) option:
free -h Output example:
total used free shared buff/cache available
Mem: 15Gi 4.4Gi 2.9Gi 521Mi 8.2Gi 10Gi
Swap: 2.0Gi 0B 2.0Gi
Now you can easily see memory sizes in GB or MB.
Other Useful Options
1. Display in Megabytes or Gigabytes
You can use the -s option to update the output continuously:
free -m # Display in MB free -g # Display in GB
2. Show Memory Every 2 Seconds
You can use the -s option to update the output continuously:
free -h -s 2
This refreshes the memory statistics every 2 seconds — useful for monitoring memory changes in real time.
3. Display the Total at the End
# free -mt
total used free shared buff/cache available
Mem: 949 117 616 0 215 694
Swap: 0 0 0
Total: 949 117 616
This shows a total line summarizing RAM and swap usage.
Understanding Buffers and Cache
One common confusion is when used memory seems high.
For example:
used: 14GB free: 1GB
But your system isn’t actually running out of memory – that’s because Linux uses free RAM to cache frequently accessed data.
You can get a truer sense of available memory by focusing on the “available” column.
Combine with Other Commands
You can combine free with tools like top or vmstat for deeper analysis:
- top or htop → for live process and memory monitoring
- vmstat → for virtual memory statistics
- cat /proc/meminfo → for detailed system memory info
Summary
| Command | Description |
|---|---|
| free | Show memory usage summary |
| free -h | Human-readable output |
| free -m | Display in MB |
| free -s 2 | Refresh every 2 seconds |
| free -t | Show total memory summary |
Final Thoughts
free command is a simple yet essential Linux utility for system monitoring. Understanding how Linux manages memory – especially the buffers/cache concept – helps you make smarter decisions when diagnosing system performance or resource usage.
When you know how to read free output correctly, you’ll never misinterpret “high memory usage” again.