The Volatile Memory Allocation Interrogation
When operating a headless Ubuntu server, every active database query, Node.js background daemon, and SSH tunnel requires a specific mathematical allocation of Random Access Memory (RAM). Unlike static hard drive storage, RAM is a highly volatile, rapidly fluctuating matrix. If an application initiates a memory leak, it will rapidly consume all available gigabytes. When the server hits 100% RAM utilization, the Linux kernel will trigger the Out Of Memory (OOM) Killer, which violently and randomly assassinates active processes to keep the core OS alive. You must proactively interrogate the kernel to monitor real-time memory telemetry.
How to Check Memory in Ubuntu
The UNIX architecture provides the dedicated, highly optimized `free` utility specifically designed to parse the `sysfs` virtual file system and output the exact RAM allocation parameters.
1. Open your terminal application or connect to the server via SSH.
2. Method 1: The Master Memory Interrogation (`free`):
* This is the mathematically superior and most instantaneous method.
* The standard `free` command outputs data in kilobytes, which is difficult for a human to parse. You must inject the `-h` (human-readable) flag to force the kernel to calculate the output in Megabytes (MB) and Gigabytes (GB).
* Type exactly:
free -h
* Press Enter.
* The Diagnostic Dump: The terminal will instantly output a precise mathematical grid containing two main rows: Mem (Physical RAM) and Swap (Virtual RAM on the hard drive).
* total: The absolute maximum capacity of the installed silicon (e.g., `15Gi`).
* used: The exact amount currently locked by active processes (e.g., `4.2Gi`).
* free: The completely untouched, sterile RAM (e.g., `1.1Gi`).
* buff/cache: Memory the OS is temporarily using to speed up file access. (Crucially, the kernel will autonomously drop this cache if applications need more “free” memory, so this is essentially usable space).
* available: The most important metric. This is the true mathematical estimate of how much RAM a new application can claim without triggering swap.
3. Method 2: The Continuous Live Feed (`watch free`):
* If you need to monitor the memory utilization in real-time while you execute a heavy database query.
* Type exactly:
watch -n 1 free -h
* Press Enter. The terminal will clear, and the `free -h` matrix will execute autonomously every `1` second. Press Ctrl + C to terminate the loop.
4. Method 3: The Process-Specific Analysis (`htop`):
* If `free -h` reveals you are at 99% usage, you must find the specific rogue process. Type `top` or `htop` and press Enter to view the specific %MEM column for every active PID.