Back to lessons

Linux Survival Basics

Check Memory Pressure with free

You need to tell whether the system is actually low on available memory.

Command

free -h

What changed

Nothing changes. The command displays memory and swap totals.

Danger

safe

When to use it

Use when apps are slow, processes are being killed, or memory pressure is suspected.

When not to use it

Do not treat the free column alone as the truth; Linux uses memory for cache.

Undo or recovery

No undo needed because this command is read-only.

Expected output

A memory summary showing total, used, free, buff/cache, available, and swap.

demo script

Disposable terminal steps

  1. free -h
  2. ps -eo pid,ppid,stat,pcpu,pmem,rss,comm,args --sort=-pmem | head -n 10

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ free -h
               total        used        free      shared  buff/cache   available
Mem:           1.9Gi       1.4Gi        94Mi        18Mi       410Mi       312Mi
Swap:          2.0Gi       620Mi       1.4Gi
::exit-code::0
$ ps -eo pid,ppid,stat,pcpu,pmem,rss,comm,args --sort=-pmem | head -n 10
  PID  PPID STAT %CPU %MEM   RSS COMMAND        COMMAND
 2011     1 S     4.5  37.9 776M postgres      postgres: main
 1842     1 R    86.4  14.2 291M app-worker    /srv/app/worker --jobs
 1907     1 S    12.8   3.1  63M nginx         nginx: worker process
::exit-code::0

YouTube Short

Read Linux memory correctly.

In free, start with available, not panic. Cache is normal; low available plus swap use is the warning.

LinkedIn hook

Linux memory numbers look scary until you know which column matters.

Question: Which free column do you check first during memory triage?

experiments

A/B tests to run

Metric: rewatch_rate

A: Explain available first.

B: Explain cache first.