How to Check Memory Usage in Ubuntu

The Memory Saturation Vector

When administering a high-traffic Ubuntu web server, the physical Random Access Memory (RAM) is your most critical bottleneck. If a rogue PHP script or a massively complex MySQL database query devours 100% of the available RAM, the Linux kernel will trigger the “Out Of Memory (OOM) Killer,” which brutally and randomly terminates active processes (often the web server itself) to prevent a total system crash. You must proactively monitor your memory telemetry to prevent this catastrophic saturation.

How to Check Memory Usage

Ubuntu provides a specialized, instantaneous command-line utility explicitly designed to read the kernel’s memory allocation tables.

1. Open your terminal application or connect to the server via SSH.
2. If you simply type `free` and press enter, the utility outputs the data in raw bytes, which is mathematically precise but unreadable for rapid diagnostics. You must append the `-h` (human-readable) flag to force the output into Megabytes and Gigabytes.
3. Type the following exact command:

free -h

4. Press Enter.
5. Analyzing the Telemetry: The terminal will generate a small, highly structured table with two primary rows: `Mem:` (your actual physical RAM) and `Swap:` (your emergency hard drive overflow space).
* total: The absolute maximum RAM installed in the machine (e.g., `15Gi`).
* used: Exactly how much memory is currently locked by active applications.
* free: Memory that is completely unassigned.
* available: (This is the most critical metric). This number represents memory that is technically “free,” plus memory that the kernel is temporarily using for cache but will instantly drop if an application needs it. If your `available` memory drops below 500 Megabytes on a production server, you are in imminent danger of an OOM crash.

Get the best tech tips delivered straight to your inbox.

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