How to Check RAM Usage on Linux: free, top, htop and the "Available" Rule

CodexFuse Team · 2026-11-04T09:51:39.051Z · 11 min read min read

Check RAM usage on Linux the right way: free -h for the overview, the available-vs-free rule that stops the panic, per-process hunting with top, htop and ps, and what to do when available RAM is actually low.

If your Linux server feels sluggish, learning how to check RAM usage in Linux is the first diagnostic to master — before you buy a bigger VPS. Memory problems hide behind a confusing readout: one column says "free" is nearly zero while another says plenty is "available," and the difference between the two decides whether you actually have a problem. This guide walks the whole memory-check workflow for any distro, from the 5-second free -h overview to per-process hunting with top, htop, and ps — the same checks every VPS hosting admin runs before touching their plan.

How Do I Check RAM Usage on Linux?

Run free -h for the overview, then hunt per-process usage with top, htop, or ps. The complete workflow is:

  1. free -h — the one-command overview; read the available column, not the free column.
  2. ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -n 10 — list the top memory consumers instantly.
  3. top (press M) or htop (press M) — watch memory live and sort by %MEM.
  4. cat /proc/meminfo or vmstat -s — the raw numbers behind the summary.
  5. dmesg | grep oom-killer — confirm whether the kernel ever ran out of memory for real.

The rest of this guide explains what each number means so you stop panicking at a "free" column that is supposed to be small.

The free Command on Linux: Read the Available Column

The free command Linux beginners learn first prints total, used, free, shared, buff/cache, and available memory in one glance. It comes from the procps-ng suite and gets its numbers by parsing /proc/meminfo, so what you see here is the same data the kernel publishes — just formatted. Run it with -h for human-readable sizes (the default unit is kibibytes, which is hard to read at a glance). Here is real output from a live, busy machine:

              total        used        free      shared  buff/cache   available
Mem:           7.7Gi       6.1Gi       517Mi       253Mi       1.7Gi       1.7Gi
Swap:             0B          0B          0B

free -h explained, column by column, using the man page definitions:

ColumnWhat it means
totalTotal usable RAM (physical RAM minus reserved bits and kernel code).
usedUsed or unavailable memory — calculated as total minus available.
freeCompletely unused memory (MemFree in /proc/meminfo). Supposed to be small.
sharedMemory used by tmpfs and other shared-memory filesystems.
buff/cacheKernel buffers plus the page cache — memory Linux borrowed for disk caching.
availableHow much memory new applications can actually use without swapping. This is the number that matters.

Notice the trap in the example above: used reads 6.1Gi of 7.7Gi, which looks alarming — but available says 1.7Gi is still claimable. That machine is fine. Judging memory by the "free" column alone is the single most common misreading in Linux server admin, and the next section kills it for good.

Available vs Free Memory on Linux: the Rule That Stops the Panic

Ignore the free column; watch available instead. "Free" counts memory nobody is touching right now, while "available" estimates how much new applications can take without forcing the system into swap — it includes the disk cache Linux can reclaim instantly. As the site linuxatemyram.com puts it: "Don't panic! Your ram is fine!" — Linux borrows unused memory for disk caching, and "disk cache can always be given back to applications immediately." The one-liner to remember: unused RAM is wasted RAM, so a healthy Linux box almost always shows a tiny "free" number.

In the available vs free memory Linux debate, the man pages settle it: watch available, not free. The man page for proc(5) defines MemAvailable (added in Linux 3.14) as "an estimate of how much memory is available for starting new applications, without swapping." That is why the free man page defines "used" as total minus available: the authors of the tool decided long ago that "available" is the honest measure. A simple rule of thumb: if available is comfortably above 15–20% of total and swap usage is flat, your memory is healthy no matter what the "free" column says. Real warning signs are available near zero, swap usage climbing, or the OOM killer firing (checked in the final section).

How to See RAM Usage by Process on Linux

The how to see RAM usage by process Linux question comes up in every ops channel, and it has three good answers: ps for an instant ranked list, top for the classic live monitor, and htop when you want a friendlier view. All three read the same kernel data; pick by habit and availability. Here they are in order of speed:

The ps one-liner (fastest)

ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -n 10

This prints process ID, parent ID, command, %MEM, and %CPU, sorted with the biggest memory hogs first (the - in --sort=-%mem means descending order). The ps(1) man page defines %MEM as "the ratio of the process's resident set size to the physical memory on the machine, expressed as a percentage" — the honest per-process figure. The syntax was verified against the man page and tested live, so copy it as-is.

top: press M to sort by memory

Open top and press M to sort the task list by %MEM (the man page lists plain M as the %MEM sort key — not Shift+M). For a one-shot sorted view from the shell, use top -o %MEM, which overrides the sort field directly. Top reports memory in KiB by default; pressing E cycles the summary-area units from KiB up through EiB, and lowercase e does the same for the task list. Press m to toggle the memory summary lines themselves.

htop: the visual monitor

htop is a cross-platform, ncurses-based process viewer — top with colors, bars, and mouse-friendly navigation. Install it on Ubuntu or Debian with sudo apt install htop (it ships in Ubuntu's universe repository, enabled by default, and in Debian's main repository). Inside htop, press M to sort by memory (a top-compatibility key) or F6 to pick any sort field, with the current field highlighted in the header. Press F2 to configure the header meters — adding a memory bar makes the usage glanceable from across the room. If you want an even newer look, btop ("a monitor of resources," per its README) adds full mouse support and easy sort switching.

free Command Flags Worth Memorizing

Six free command flags cover nearly every memory question. All of these come straight from the free(1) man page — including one trap that trips up experienced admins:

FlagWhat it does
-h, --humanHuman-readable sizes in powers of 1024 (Ki, Mi, Gi), shortest 3-digit form with units.
-m, -g, -k, -bForce output in mebibytes, gibibytes, kibibytes, or bytes.
-s N, --seconds NRepeat every N seconds for live monitoring (e.g. free -h -s 2).
-c N, --count NStop after N repetitions (requires -s).
-t, --totalAdd a totals row for RAM plus swap.
-w, --wideShow buffers and cache as separate columns instead of one buff/cache column.
--siUse powers of 1000 (KB, MB, GB) instead of 1024. Note: free has no -H flag — use --si.

The --si row deserves emphasis because the -H flag people expect from df does not exist in free — typing free -H is an error, not a power-of-1000 readout. The default unit with no flags is kibibytes; for scripts, pair a fixed unit with the raw numbers: free -m or free -g. For a continuous watch during a load test, free -h -s 1 -c 30 prints 30 one-second snapshots and exits.

Check RAM Usage From the Terminal: /proc/meminfo and vmstat

Go to /proc/meminfo when you want to check RAM usage from terminal — the raw kernel counters behind free's summary. The fields that matter:

MemTotal:        8124908 kB
MemFree:          530400 kB
MemAvailable:    1752200 kB
Buffers:              16 kB
Cached:          1619096 kB
SwapTotal:             0 kB
SwapFree:              0 kB

MemTotal is the usable RAM, MemFree is the completely idle portion, and MemAvailable is the man-page-sanctioned "can new apps use this" estimate. Cached is the page cache — files Linux keeps in memory so it does not have to re-read them from disk — which is exactly the memory that keeps "free" looking small while "available" stays healthy. SwapTotal and SwapFree tell you whether the system has swap at all; this box has none configured, so memory pressure here has nowhere to overflow.

vmstat is the older companion for the same job: vmstat -s prints the event counters and memory statistics in a table, and vmstat 1 streams one-second snapshots like free -s but across CPU, paging, and block I/O as well. Its memory fields — swpd, free, buff, cache, plus inact and active with -a — track the same story. Both free and vmstat read /proc/meminfo under the hood; they just choose different highlights.

What to Do When Available RAM Is Actually Low

Act only when available is near zero or swap is climbing — not when "free" looks small. The escalation order, using the same commands from this guide:

  1. Identify the hog: run the ps one-liner above. If one process owns the memory, restart or reconfigure it — do not reboot blindly.
  2. Check swap: free -h showing used swap means RAM already overflowed; if you have no swap configured, add it — our swap space guide covers sizing and setup on Ubuntu.
  3. Confirm real exhaustion: dmesg | grep oom-killer shows whether the kernel ever killed processes for memory. If it has, no command flag will save you — the workload needs more RAM.
  4. Rule out slow leaks: sar -r reads the historical memory reports kept in /var/log/sa and shows when usage started climbing, which separates a sudden spike from a leak.
  5. Pair with disk checks: a full disk can masquerade as memory trouble (logs and caches failing to write); the disk space check is the natural sibling diagnostic.

One caution: echo 3 | sudo tee /proc/sys/vm/drop_caches clears the page cache and makes "free" jump — it is a diagnostic trick, not a fix. Linux will immediately start re-caching, because caching is the correct behavior. Dropping caches treats the symptom and hides the workload that caused the pressure.

Sources

Every command and definition in this guide was verified against these sources on 2026-11-04: the free(1), proc(5), top(1), ps(1), vmstat(8), htop(1), and sar(1) man pages on man7.org; linuxatemyram.com for the available-vs-free doctrine; htop.dev and the htop-dev/htop and aristocratos/btop GitHub READMEs for the interactive monitors; and live command runs on a Linux box (free, free -h, /proc/meminfo, ps one-liner) for the annotated real outputs.

Frequently Asked Questions

Why does free show almost no "free" memory? Is my server running out of RAM?

Almost certainly not — Linux intentionally keeps "free" small by using idle memory as a disk cache. Look at the available column instead: it counts cache that can be reclaimed instantly for new applications. If available is healthy (say, 15–20% of total or more) and swap is untouched, your RAM is fine. That is the entire point of the linuxatemyram.com doctrine quoted above.

How do I check memory usage in Ubuntu specifically?

If your real question is how to check memory usage in Ubuntu, the answer is reassuringly boring: the commands are identical to every other Linux distribution — free -h for the overview, top (press M) or htop for live per-process views, and cat /proc/meminfo for raw numbers. Ubuntu ships free and top by default; htop needs sudo apt install htop. If you also want the disk-space half of the server health check, see our guide on checking disk space on Ubuntu.

How do I find which process is using the most RAM?

Run ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -n 10 for an instant ranked list — the biggest consumer is the first row. For a live view, open top and press M, or open htop and press M (or F6 to choose the sort field). %MEM is the process's resident set size as a percentage of total physical RAM.

Does -h mean the same as -m or -g in the free command?

No — -h picks the most readable unit automatically (powers of 1024: Ki, Mi, Gi), while -m and -g force mebibytes and gibibytes. Use -h when reading output yourself and -m or -g when feeding numbers into a script. And remember: free has no -H flag — use --si for powers-of-1000 units.

Is it safe to clear the cache with drop_caches to free RAM?

It is safe but pointless as a fix: echo 3 | sudo tee /proc/sys/vm/drop_caches forces Linux to release the page cache, which briefly inflates "free" — then the system re-caches everything because caching is correct behavior. Use it only as a diagnostic (to confirm pressure was cache-related), and fix actual shortages by finding the memory-hungry process or adding RAM or swap.

Featured on Twelve Tools Hunt for Tools Featured on LaunchBuff Launch Llama Tools Launch your MCP Top Web Development Companies in the US - OnToplist.com Designer Listings Listed on SeeWhatNewAI