How to Check Your RAM Usage in Ubuntu

The Memory Exhaustion Vector

When an Ubuntu Linux server begins to operate sluggishly or unexpectedly terminates background processes, the primary culprit is almost always RAM exhaustion. If a poorly optimized database query or a memory-leaking web application consumes all available physical memory, the kernel is forced into a panic state, indiscriminately killing processes to keep the server alive. You must be able to instantly interrogate the system to view exactly how much memory is free, used, and cached.

How to Check Your RAM Usage

Linux provides a hyper-efficient command specifically designed to dump a snapshot of the current memory architecture directly to your terminal screen.

1. Open your terminal application or connect to your server via SSH.
2. To retrieve a raw, unformatted data dump in kilobytes, you would simply type free. However, this is incredibly difficult for humans to read. You must use the “human-readable” flag.
3. Execute the following command:

free -h

4. The terminal will instantly output a small table containing two rows: Mem: (Physical RAM) and Swap: (Virtual RAM on the hard drive).
5. Parsing the output:
* total: The absolute maximum memory installed on the server.
* used: The memory currently locked down by active applications.
* free: The memory completely untouched and waiting for an assignment.
* buff/cache: Memory the kernel is actively using to cache files for faster access (this is a good thing; Linux will automatically free this up if applications need it).
* available: This is the most critical number. It represents the true amount of memory you have left before the server starts crashing.

If the “available” number is hovering near zero, and the server is heavily utilizing the “Swap” row, you must immediately upgrade your physical hardware or restart your heavy applications.

Get the best tech tips delivered straight to your inbox.

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