Check disk space and memory in Bash
See free disk with df -h, folder size with du -sh, and RAM with free -m.
Start Interactive LessonWhen a machine feels full, you need three numbers: how much disk is left, how large this folder is, and how much RAM is free. df, du, and free answer those questions. The -h and -m flags turn raw blocks into sizes people can read.
How much disk is left: df -h
df reports filesystems. -h prints sizes in G and M instead of 1K blocks.
Show disk space you can actually read!
Readable disk usage:
How large is this folder: du -sh
du walks the current directory. -s prints one summary line. -h keeps the size readable. Together they are du -sh (or du -hs).
du -sh
Typical output: 128M . — this folder and everything under it.
How much RAM is free: free -m
free -m shows memory in megabytes: total, used, free, and available. Look at the available column when you want to know if a new process will fit.
Use df -h for the whole disk, du -sh for “why is this project huge?”, and free -m when programs start swapping.
Knowledge Check
1 / 3Which command shows free space on filesystems in readable units?
References
These documentation links provide authoritative details for the commands used in this article.
Up Next
Use man pages to grab exact syntax and options without leaving the terminal.