CMD Master
Back to Blog
Arnošt Havelka

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 Lesson
Check disk space and memory in Bash

When 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.

Try the command

Show disk space you can actually read!

Build the command
df
Terminal
C:\Users\User>df -h

Readable disk usage:

Command Prompt
Filesystem 1K-blocks Used Available Use% /dev/sda1 33554432 12582912 18874368 41%
C:\Users\User>df

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.

Command Prompt
C:\Users\User>free -m

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 / 3

Which 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

Bash Self-Sufficiency: MAN Quick Scan

Use man pages to grab exact syntax and options without leaving the terminal.