The Resource Allocation Vector
If your headless Ubuntu server begins experiencing severe performance degradation or sudden, inexplicable application crashes, the primary suspect is often RAM exhaustion. When a database or web server consumes 100% of the available physical memory, the Linux kernel triggers the “Out Of Memory (OOM) Killer,” a ruthless failsafe protocol that randomly terminates active processes to keep the system alive. You must preemptively interrogate the kernel to analyze your exact memory consumption before the OOM Killer strikes.
How to Check Memory Usage
The Ubuntu operating system relies on the highly efficient `free` command-line utility to rapidly calculate and report the state of the system’s Random Access Memory (RAM) and Swap space.
1. Open your terminal application or connect to the server via SSH.
2. The Basic Command (Unreadable Output):
* If you simply type `free` and press Enter, the kernel will output the data in raw kilobytes. This massive string of numbers is mathematically accurate but requires manual calculation to understand.
3. The Human-Readable Override (Recommended):
* You must append the `-h` (human-readable) or `-m` (megabytes) flag to the command. This forces the utility to calculate the raw blocks and translate them into familiar Megabytes (MB) and Gigabytes (GB).
* Type the following command:
free -h
* Press Enter.
4. Analyzing the Telemetry Matrix:
* The terminal will generate a tabular grid with two primary rows: Mem: (Physical RAM) and Swap: (Virtual memory on the hard drive).
* total: The absolute maximum capacity of your installed hardware.
* used: The amount of RAM currently consumed by active applications and daemons.
* free: The memory that is completely untouched.
* buff/cache: This is a crucial metric. The Linux kernel intentionally uses free RAM to cache frequently accessed files to speed up the system. If an application suddenly needs more RAM, the kernel will instantly dump this cache to make room. Do not panic if “buff/cache” is high; this is optimal behavior.
* available: This is the most important number. This tells you exactly how much memory is truly available for new applications to use right now, factoring in the disposable cache.