How to Check Disk Space in Linux

See how much space is left, and find out what is using it.

"Is the disk full?" and "what filled it?" are two different questions with two different tools. df answers the first by asking each filesystem for its counters — instant, authoritative. du answers the second by walking directories and adding up what it finds — slower, but it tells you where to look. Almost every disk investigation uses them in that order.

Step by step

1 See the overall picture

$ df -h

One line per filesystem: size, used, available, percentage and mount point. The -h makes the numbers human (G, M) instead of blocks. Note that /home, /var and /boot are often separate filesystems, so "the disk" may be full while another has plenty of room.

2 Check the filesystem you actually care about

$ df -h /var/log

Pass a path and df reports only the filesystem holding it. This avoids the classic mistake of reading the wrong row.

3 Find the biggest directories

$ du -h --max-depth=1 /var | sort -hr | head

Sizes of each subdirectory, largest first. Enter the biggest one and repeat — three or four rounds usually corner the culprit. This drill-down is the standard technique.

4 Find the biggest individual files

$ find / -xdev -type f -size +500M -exec ls -lh {} + 2>/dev/null | sort -k5 -hr | head

Everything over 500 MB, largest first. The -xdev keeps the search on one filesystem, and 2>/dev/null hides the permission noise.

5 Check inodes if the numbers make no sense

$ df -i

A filesystem can be full with free bytes: every file consumes an inode, and millions of tiny files exhaust them. If IUse% is at 100% while Use% is not, deleting files (not freeing bytes) is the fix.

Tips worth knowing

Frequently asked questions

What is the difference between df and du?

df asks the filesystem how much space it has (fast, includes everything). du adds up the files it can reach by name (slower, blind to deleted-but-open files). Use df to confirm the problem and du to locate it.

Why does df show 100% when I deleted files?

The space is not released until every process holding those files closes them. sudo lsof +L1 lists them; restarting the process frees the space.

What does the "Use%" of a filesystem mean exactly?

Used blocks over total, but ext4 reserves about 5% for root by default — which is why you can hit "disk full" as a normal user at around 95%.

If it goes wrong

No space left on device

A filesystem is full — confirm which one, and whether you ran out of bytes or inodes.

The commands behind it

df & du

See free space per filesystem and find what is eating your disk, directory by directory.

find

Locate files anywhere in a directory tree by name, type, size, date — and act on them.

rm

Delete files and directories — and understand -r, -f and why there is no trash bin.

Concepts involved: Inode · Mount

More how-to guides

Extract a .tar.gz archive

Unpack tar.gz, tar.bz2, tar.xz and zip archives from the command line.

Free a port that is already in use

Find which process holds a port and stop it cleanly.

Find and replace text in files

Replace text in one file or across a whole project, safely.

Make a script executable

Give a script permission to run, and understand why it needs it.