free

system managementLinux/Unix
The free command is one of the most frequently used commands in Linux/Unix-like operating systems. free Display amount of free and used memory in the system

Quick Reference

Command Name:

free

Category:

system management

Platform:

Linux/Unix

Basic Usage:

free [options] [arguments]

Common Use Cases

    Syntax

    free [options]

    Options

    Option Description
    -b, --bytes Display the amount of memory in bytes
    -k, --kilo Display the amount of memory in kilobytes (default)
    -m, --mega Display the amount of memory in megabytes
    -g, --giga Display the amount of memory in gigabytes
    -h, --human Show all output fields automatically scaled to the shortest unit with three digits
    -w, --wide Switch to the wide mode (show buffers and cache columns)
    -c, --count=COUNT Display the result COUNT times, then exit
    -l, --lohi Show detailed low and high memory statistics
    -s, --seconds=SECONDS Continuously display the result with a delay of SECONDS
    -t, --total Display a line showing the column totals

    Examples

    How to Use These Examples

    The examples below show common ways to use the free command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    free
    Display memory usage in kilobytes.
    free -h
    Display memory usage in human-readable format.
    free -m
    Display memory usage in megabytes. # Advanced Examples Advanced free -s 5 Continuously display memory usage every 5 seconds. free -t Display a line showing total memory. free -w Display buffers, cache, and also available memory columns. free -l Show detailed low and high memory statistics. free -c 3 Display the result 3 times and then exit.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    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 caches used by the kernel. Key features of free: 1. Memory Information: free shows the total, used, and free memory for both physical RAM and swap space, helping in system resource monitoring. 2. Buffers and Cache: By default, free shows information about memory used for kernel buffers and page cache, which can be freed for applications if needed. 3. Display Units: free can display memory in different units (bytes, kilobytes, megabytes, gigabytes) or in a human-readable format that automatically selects the most appropriate unit. 4. Continuous Monitoring: With the -s option, free can display memory information at regular intervals, useful for ongoing system monitoring. 5. Total Line: The -t option adds a line showing the total memory (physical + swap), providing a complete picture of all memory resources. 6. Low and High Memory: On some systems, the -l option displays statistics about low and high memory, which is relevant for systems with memory segmentation. 7. Data Source: free reads its information from the /proc/meminfo file, which contains detailed information about memory usage maintained by the Linux kernel. free is commonly used for diagnosing memory-related performance issues, monitoring system resources, and determining if a system is running out of memory or experiencing excessive swapping.

    Related Commands

    These commands are frequently used alongside free or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the free command works in different scenarios.

    $ free
    View All Commands