To check Linux disk space, run df -hT . in the directory where you need room. It reports the filesystem containing that directory. To measure a directory's contents, use du -sh ./directory. These commands answer different questions, so their totals do not have to match.
Check the filesystem you are actually writing to
df -hT .
df -i .The dot selects the current directory. Replace it with an existing path on the filesystem you are investigating. With GNU df, -h uses readable size units and -T includes the filesystem type. Look at:
- Size: the reported filesystem capacity.
- Used: blocks already allocated.
- Avail: space available to an unprivileged user.
- Use%: how much of the reported usable capacity is occupied.
- Mounted on: where that filesystem appears in the directory tree.
A separate home partition, mounted drive or container filesystem may fill independently of the root filesystem. Start with the failing path instead of assuming that the first row from df is the relevant disk.
df -i reports inode use where the filesystem exposes meaningful inode counts. Inodes describe filesystem objects. A filesystem can run out of them while still having free data blocks. Some filesystems report inode information differently, so a dash or zero is not automatically an error.
Measure directories with du
For a directory you own, replace ./disk-demo with the path you want to inspect:
du -sh ./disk-demo
du -h --max-depth=1 ./disk-demo | sort -hThe first command summarizes the tree. The second shows its immediate subdirectories plus the total, ordered by size. This example uses GNU options on Linux. macOS and other implementations may offer different flags.
Run a targeted scan before scanning an entire disk. A large directory tree can take time to traverse. Permission errors mean the scan did not see everything; do not suppress those errors and treat the result as complete. When filesystem boundaries matter, GNU du -x stays on the starting filesystem.
A small example you can reproduce
In a new test folder, create this tree without downloading anything:
mkdir -p disk-demo/nested
printf 'hello\n' > disk-demo/small.txt
dd if=/dev/zero of=disk-demo/nested/one-mib.bin bs=1024 count=1024
du -h --max-depth=1 ./disk-demo | sort -h
du -sb ./disk-demoThe large file contains exactly 1,048,576 bytes. The directory total includes the other file and directory metadata, and allocated sizes depend on the filesystem. In the Ubuntu container test, the nested directory and total both appeared in the one-level report, with the one-mebibyte file accounting for most of the usage.
du -sb reports apparent sizes in bytes. Ordinary du estimates allocated storage. A sparse file can have a large apparent length while occupying few disk blocks; compression and filesystem behavior can also affect comparisons.
Why df and du disagree
| Observation | What to investigate |
|---|---|
| df shows more use than your directory scan | Other directories on the same filesystem, unreadable paths, filesystem metadata or a deleted file still held open by a process. |
| du includes another mounted disk | Check the mount layout; consider du -x for a single-filesystem scan. |
| A file looks huge but consumes little space | Compare apparent size and allocated size; the file may be sparse. |
| Writing fails despite free bytes | Check the target filesystem, inode availability, account quota and the exact error message. |
Do not delete unfamiliar system or application files just to make the percentage fall. Identify the owner and purpose of the data, then use that application's supported retention or cleanup process. A filesystem error needs a different response from a full download folder.
Use the result to choose the next step
If you cannot reach the target folder, check path permissions. If Bash cannot find one of these commands, use the command lookup checklist. For a remote Ubuntu machine, connect through SSH and run the checks on that machine; running df on your laptop measures the laptop instead.
Sources and verification
Tested September 11, 2026 in a disposable Ubuntu 24.04 container using a one-mebibyte fixture: df byte/inode reports, du summary, sorted depth-one output and apparent-byte output ran successfully. Container filesystem figures are environment-specific. Quota exhaustion, inode exhaustion and deleted-open-file recovery were not reproduced.
If a write still fails
Use the No space left on device checklist to distinguish exhausted blocks, exhausted inodes and deleted files still held open.
