
Linux feels a lot like living in a loft apartment: the pipes are on display, every clank echoes, and when something leaks, you’re the first to squelch through the puddle. This guide hands you a mop, half a dozen snappy commands that expose where your disk space and memory have wandered off to, plus a couple of click‑friendly detours. Expect prose that winks, occasionally rolls its eyes, and never ever sounds like tax law.
Why checking disk and memory matters
Think of storage and RAM as the pantry and fridge in a shared flat. Ignore them for a week, and you end up with three half‑finished jars of salsa (log files) and leftovers from roommates long gone (orphaned kernels). A five‑minute audit every Friday spares you the frantic sprint for extra space, or worse, the freeze just before a production deploy.
Disk panic survival kit
Get the big picture fast
df is the bird’s‑eye drone shot of your mounted filesystems, everything lines up like contestants at a weigh‑in.
# Exclude temporary filesystems for clarity
$ df -hT -x tmpfs -x devtmpfs
-h prints friendly sizes, -T shows filesystem type, and the two -x flags hide the short‑lived stuff.
Zoom in on space hogs
du is your tape measure. Pair it with a little sort and head for instant gossip about the top offenders in any directory:
# Top 10 fattest directories under /var
$ sudo du -h --max-depth=1 /var 2>/dev/null | sort -hr | head -n 10
If /var/log looks like it skipped leg day and went straight for bulking season, you’ve found the culprit.
Bring in the interactive detective
When scrolling text gets dull, ncdu adds caffeine and colour:
# Install on most Debian‑based distros
$ sudo apt install ncdu
# Start at root (may take a minute)
$ sudo ncdu /
Navigate with the arrow keys, press d to delete, and feel the instant gratification of reclaiming gigabytes, the Marie Kondo of storage.
Visualise block devices
# Tree view of drives, partitions, and mount points
$ lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT --tree
Handy when that phantom 8 GB USB stick from last week still lurks in /media like an uninvited houseguest.
Memory and swap reality check
Check the ledger
The free command is a quick wallet peek, straightforward, and slightly judgemental:
$ free -h
Focus on the available column; that’s what you can still spend without the kernel reaching for its credit card (a.k.a. swap).
Real‑Time spy cam
# Refresh every two seconds, ordered by RAM gluttons
$ top -o %MEM
Prefer your monitoring colourful and charming? Try htop:
$ sudo apt install htop
$ htop
Use F6 to sort by RES (resident memory) and watch your browser tabs duke it out for supremacy.
Meet RAM’s couch‑surfing cousin
Swap steps in when RAM is full, think of it as sleeping on the living‑room sofa: doable, but slow and slightly undignified.
# Show active swap files or partitions
$ swapon --show
Seeing swap above 20 % during regular use? Either add RAM or conjure an emergency swap file:
$ sudo fallocate -l 2G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
Remember to append it to /etc/fstab so it survives a reboot.
Prefer clicking to typing
Yes, there’s a GUI for that. GNOME Disks and KSysGuard both display live graphs and won’t judge your typos. On Ubuntu, you can run:
$ sudo apt install gnome-disk-utility
Launch it from the menu and watch I/O spikes climb like toddlers on a sugar rush.
Quick reference cheat sheet
- Show all mounts minus temp stuff
Command: df -hT -x tmpfs -x devtmpfs
Memory aid: df = disk fly‑over - Top ten heaviest directories
Command: du -h –max-depth=1 /path | sort -hr | head
Memory aid: du = directory weight - Interactive cleanup
Command: ncdu /
Memory aid: ncdu = du after espresso - Live RAM counter
Command: free -h
Memory aid: free = funds left - Spot memory‑hogging apps
Command: top -o %MEM
Memory aid: top = talent show - Swap usage
Command: swapon –show
Memory aid: swap on stage
Stick this list on your clipboard; your future self will thank you.
Wrapping up without a bow
You now own the detective kit for disk and memory mysteries, no cosmic metaphors, just straight talk with a wink. Run df -hT right now; if the numbers give you heartburn, take three deep breaths and start paging through ncdu. Storage leaks and RAM gluttons are inevitable, but letting them linger is optional.
Found an even better one‑liner? Drop it in the comments and make the rest of us look lazy. Until then, happy sleuthing, and may your logs stay trim and your swap forever bored.