How to Check Free Memory (RAM) in Linux

Why Monitoring Your Server’s Memory Matters

If your Linux web server suddenly becomes sluggish, or if a database query abruptly crashes without a clear error message, the culprit is almost always a lack of available memory (RAM). When a Linux system runs entirely out of physical RAM, it is forced to use the “swap space” (a section of your slow, mechanical hard drive) to process data. This completely destroys your system’s performance.

In severe cases, if swap space also runs out, the Linux kernel will trigger the “OOM (Out of Memory) Killer,” a ruthless background process that will permanently terminate your most important applications—like your MySQL database or Apache web server—just to keep the operating system alive.

Before installing new software or running a massive data script, you must check exactly how much free RAM your server has available. You can do this in seconds using the command line.

The Standard Method: Using the “free” Command

The fastest and most universally supported way to check memory on any Linux distribution (Ubuntu, Debian, CentOS, Red Hat) is the free command.

  1. Open your Linux terminal (or SSH into your remote server).
  2. Type the following command and press Enter: free -m

Understanding the Output:

The -m flag tells the system to display the results in Megabytes (MB). If you simply type free on its own, it will display the numbers in kilobytes, which are far too large and difficult for a human to read quickly.

The output will present a small table with two primary rows: Mem: (your physical RAM) and Swap: (your hard drive overflow space). The most important columns are:

  • total: The total amount of physical RAM installed in your server (e.g., 8192 for an 8GB server).
  • used: The amount of RAM currently being consumed by your running applications.
  • free: The amount of RAM that is completely untouched and empty.
  • available: This is the most crucial number. It represents the actual amount of memory you have left to start a new application without forcing the system to use swap space.

Why “Free” and “Available” Are Very Different

When beginners look at the output of the free -m command, they often panic because the “free” column shows an incredibly low number (e.g., only 120MB free out of 8000MB).

Do not panic. This is how Linux is designed to work.

Linux firmly believes that “empty RAM is wasted RAM.” If you have 8GB of memory and your applications are only using 2GB, Linux will automatically use the remaining 6GB to secretly cache files and buffer data, making your server run much faster. Because the memory is holding cached files, it is no longer considered “free.”

However, if a new application suddenly needs 4GB of RAM to start, Linux will instantly dump those cached files and give the memory to your application.

Therefore, you should always ignore the “free” column. The available column tells you exactly how much memory Linux is willing to surrender to your applications immediately. If your “available” number is extremely low, then your server is in genuine danger of crashing.

The Human-Readable Method: Using “free -h”

If your server has a massive amount of RAM (e.g., 64GB or 128GB), reading the output in Megabytes can still result in long, confusing numbers. You can ask Linux to automatically format the output into the most appropriate size (Gigabytes or Megabytes) by using the “human-readable” flag.

  1. In your terminal, type: free -h
  2. Press Enter.

Instead of displaying “16384”, the table will neatly display “16G”, making it much faster to assess your server’s health at a glance.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.