When running a Linux server or desktop, monitoring system resources is critical for maintaining stability. If your machine suddenly becomes sluggish or unresponsive, the culprit is often a lack of available RAM (Random Access Memory). While desktop versions of Ubuntu offer graphical System Monitor applications, the fastest, most reliable, and universally available method across all Linux systems—including headless servers—is the command line. To instantly check your current memory usage, you need to use the free command.
The Basic free Command
The free command is a core utility built into almost every Linux distribution. It parses information from the /proc/meminfo file and displays it in a readable format.
- Open your terminal application (press
Ctrl + Alt + T). - Type the following command:
free - Press Enter.
You will see a small table with rows for Mem: (Physical RAM) and Swap: (Virtual memory on your hard drive). However, by default, the numbers displayed are in kilobytes (KB). On modern systems with gigabytes of RAM, reading a number like 16324908 is confusing and unhelpful.
Using the Human-Readable Flag
To make the output understandable at a glance, you should append the -h (human-readable) flag to the command. This tells the system to automatically scale the numbers into Megabytes (M) or Gigabytes (G).
Type: free -h
Understanding the Output Columns
When you run free -h, you will see several columns across the “Mem:” row. Understanding what these mean is crucial for accurate troubleshooting:
- total: The absolute total amount of physical RAM installed in your system (e.g., 15Gi).
- used: The amount of RAM currently being actively used by your operating system and running applications.
- free: The amount of RAM that is completely untouched and empty. (Note: Do not panic if this number seems very low. This is normal in Linux).
- shared: Memory used mostly by tmpfs (temporary file systems). Usually a very small number.
- buff/cache: This is a very important column. Linux intentionally uses your “empty” RAM to cache frequently accessed files and buffer disk writes, making your system run significantly faster. If an application suddenly needs this memory, Linux will instantly drop the cache and hand the RAM over.
- available: This is the most important number. This is the estimated amount of memory actually available for starting new applications, without having to dig into your slow Swap space. It calculates the “free” memory plus the portion of the “buff/cache” that can be reclaimed instantly.
If your available memory is very close to zero, and your Swap used number is rising, your system is officially starved for memory and will begin to slow down dramatically.