Free Command in Linux

The free command is one of the most essential Linux system administration tools used to display memory usage information. It provides real-time statistics about physical RAM, swap space, buffers, and cache usage, making it invaluable for system monitoring and troubleshooting memory-related issues.

What is the Free Command?

The free command displays the total amount of free and used physical memory and swap space in the system, as well as the buffers and cache used by the kernel. It reads information from /proc/meminfo and presents it in a human-readable tabular format.

Syntax

free [options]

Key Options

Option Description Example
-b Display output in bytes free -b
-k Display output in kilobytes (default) free -k
-m Display output in megabytes free -m
-g Display output in gigabytes free -g
-h Human-readable format (auto-scales units) free -h
-t Display totals row free -t
-s <interval> Update every N seconds free -s 5

Understanding the Output

The output contains three main rows

  • Mem Physical RAM usage statistics

  • Swap Virtual memory (swap space) usage

  • Available Memory available for starting new applications (modern systems)

Examples

Basic Usage

free
               total        used        free      shared  buff/cache   available
Mem:         2048000     1024000      512000        8000      512000     1536000
Swap:        1048576           0     1048576

Human-Readable Format

free -h
               total        used        free      shared  buff/cache   available
Mem:            2.0G        1.0G        500M        8.0M        500M        1.5G
Swap:           1.0G          0B        1.0G

Display in Megabytes with Totals

free -mt
               total        used        free      shared  buff/cache   available
Mem:            2000        1000         500           8         500        1500
Swap:           1024           0        1024
Total:          3024        1000        1524

Continuous Monitoring

free -h -s 3

This command updates the memory information every 3 seconds, useful for monitoring memory usage in real-time.

Key Fields Explained

  • total Total installed memory

  • used Memory currently in use by processes

  • free Completely unused memory

  • shared Memory used by tmpfs filesystems

  • buff/cache Memory used for buffers and cache

  • available Memory available for new applications without swapping

Common Use Cases

  • System monitoring Quick memory health check

  • Performance tuning Identifying memory bottlenecks

  • Script automation Memory threshold alerts

  • Troubleshooting Diagnosing out-of-memory issues

Conclusion

The free command is an indispensable tool for Linux system administrators and users who need to monitor memory usage. Its simple syntax and comprehensive output make it perfect for both quick checks and continuous monitoring. Understanding memory statistics helps optimize system performance and prevent memory-related issues.

Updated on: 2026-03-17T09:01:38+05:30

703 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements