Linux Survival Basics
Read-onlyCheck Memory Pressure with free
The machine feels slow or unstable, and you need to tell whether Linux is actually short on usable memory or simply using RAM for cache.
Command
free -h
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not panic over a small `free` column by itself. Linux cache is normal; low `available` memory plus swap pressure is the stronger warning.
Expected output
A memory summary showing total, used, free, buff/cache, available, and swap; the `available` and swap lines are usually the first ones to interpret.
System impact
Read-only. Nothing changes. The command displays memory and swap totals from the running system.
Recovery / rollback: no state is changed.
When to use it
Use early in performance triage to check `available` memory, cache, and swap before blaming a specific process.
When not to use it
Do not panic over a small `free` column by itself. Linux cache is normal; low `available` memory plus swap pressure is the stronger warning.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ free -h
total used free shared buff/cache available
Mem: 1.9Gi 1.4Gi 94Mi 18Mi 410Mi 312Mi
Swap: 2.0Gi 620Mi 1.4Gi
$ 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
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
free -hps -eo pid,ppid,stat,pcpu,pmem,rss,comm,args --sort=-pmem | head -n 10
next steps
Related commands
Check Memory Pressure Quickly
See whether memory is actually tight before restarting services.
free -h
Spot OOM Kills in the Kernel Journal
Exit code 137 often means the kernel has something to say.
journalctl -k --since "2 hours ago" --no-pager -o short-iso | grep -Ei 'out of memory|oom|killed process'
Find the Processes Using Memory
The server felt slow. Memory pressure was the first thing to rule out.
ps -eo pid,comm,%mem,%cpu --sort=-%mem | head
Find the Files Eating Your Disk
The disk was full, but guessing at folders was the slow part.
find /var -type f -printf '%s %p\n' | sort -nr | head -20
Read the Failure Cause in systemctl Status
The status page often tells you the failed startup step before you open every log.
systemctl status app-worker --no-pager --lines=50
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.