How to Monitor RAM Usage in Ubuntu Terminal

Random Access Memory (RAM) is the short-term working memory of your server. Every time you launch a Python script, query a MySQL database, or spin up a Docker container, that software requires a chunk of RAM to operate. If your server runs completely out of available memory, the Linux kernel will panic and trigger the “OOM (Out Of Memory) Killer,” forcibly crashing and terminating your most important applications to keep the operating system alive.

To prevent catastrophic crashes, you must know how to quickly check how much RAM is currently being used, and how much is safely available.

The Standard Method: The ‘free’ Command

The free command is the absolute standard utility for checking memory on any Linux distribution. It is instantaneous and requires no installation.

  1. Open your terminal or SSH into your Ubuntu server.
  2. Type the following command and press Enter:
free -h

(Note: Always include the -h flag. This stands for “human-readable” and forces the terminal to display the numbers in Megabytes (MB) and Gigabytes (GB). If you forget the flag, the terminal will output massive, unreadable numbers in raw kilobytes).

How to Read the Output

The terminal will output a small table with two rows: Mem: (your physical RAM) and Swap: (your emergency overflow file on the hard drive).

Look at the Mem: row and focus on three specific columns:

  • total: The absolute maximum amount of RAM physically installed in the server (e.g., 16Gi).
  • used: The amount of RAM currently locked and being actively consumed by running software.
  • available: This is the most important number. This tells you exactly how much memory is completely free and ready to be used if you decide to launch a new application right now.

If your available number drops below 500MB on a production web server, you are in the danger zone and should consider upgrading your hardware or restarting heavy services.

The Detailed Method: Viewing ‘/proc/meminfo’

The free command simply reads data from a constantly updating system file generated by the Linux kernel. If you are an advanced administrator troubleshooting a bizarre caching issue or an obscure memory leak, you might need more detail than free provides.

You can read the raw, unfiltered kernel data directly by outputting the contents of the meminfo file.

cat /proc/meminfo

This will dump a massive list of over 40 different memory statistics to your screen, detailing exactly how much memory is assigned to active buffers, inactive cache, swap caching, and kernel slabs. This is overkill for a quick check, but vital for deep system debugging.

Get the best tech tips delivered straight to your inbox.

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