Linux systems can run out of disk space because of logs, application data, package caches, temporary files, backups or unexpectedly large directories.
Use df -h to identify full filesystems, then
use du and find to locate the
directories and files consuming the space.
Identify the cause before deleting anything. Review large files, logs and application data before making changes.
Check Disk Space With df
The df command reports the amount of disk space
used and available on mounted filesystems.
df
For most troubleshooting tasks, use the human-readable option:
df -h
The -h option displays sizes in a more readable
format such as GB and MB.
Understand df -h Output
df -h
A typical result contains columns such as:
- Filesystem — the filesystem or device.
- Size — total filesystem size.
- Used — space currently used.
- Avail — available space.
- Use% — percentage of space used.
- Mounted on — filesystem mount point.
The most important column during a disk-space incident is
usually Use%.
Check a Specific Filesystem
You can check the filesystem containing a particular path.
df -h /var
This is useful when an application reports that a directory
such as /var is running out of space.
Check Disk Space in a Specific Directory With du
While df tells you about filesystem capacity,
du helps identify how much space files and
directories are using.
Check the size of a directory:
du -sh /var/log
The options mean:
-s— show a summary.-h— use human-readable sizes.
Find Which Directories Are Using the Most Space
A useful first step is to inspect the major directories under a filesystem.
sudo du -xh --max-depth=1 /
For a particular directory:
sudo du -xh --max-depth=1 /var
Sort the results to make large directories easier to identify:
sudo du -xh --max-depth=1 /var | sort -h
Find Large Files With find
Once you identify a directory consuming significant space,
use find to locate large files.
For example, find files larger than 100 MB:
sudo find /var -type f -size +100M -print
To find files larger than 1 GB:
sudo find /var -type f -size +1G -print
Find the Largest Files and Sort Them
You can combine find with other Linux commands
to identify large files.
sudo find /var -type f -printf '%s %p\n' 2>/dev/null | sort -nr | head -20
This approach lists the largest files first.
Command behavior can vary slightly between Linux
implementations, so verify the supported find
options on your distribution with:
man find
Check Disk Devices With lsblk
The lsblk command displays block devices and
their relationships.
lsblk
For filesystem information:
lsblk -f
This is useful when you need to understand which disks, partitions and filesystems are present on a Linux system.
Check Inodes When Disk Space Looks Normal
A filesystem can have available storage but still fail to create new files if it has exhausted its available inodes.
Check inode usage with:
df -i
If inode usage is at or near 100%, look for directories containing very large numbers of small files.
df -h shows plenty of free space but applications
cannot create files, checking df -i can help
identify an inode-related problem.
Why df and du Can Show Different Results
It is possible for df and du to report
different amounts of used space.
One common reason is that a process can keep an already deleted file open. The directory entry is removed, but the filesystem space can remain allocated until the process releases the file.
When investigating this situation, check for open deleted files using tools available on your distribution, such as:
sudo lsof +L1
If lsof is installed, this can help identify
processes holding deleted files open.
Check Log Files
Logs are a common source of unexpected disk consumption on servers.
Start by checking the size of common log locations:
sudo du -sh /var/log
sudo du -xh --max-depth=1 /var/log | sort -h
Then inspect particularly large files:
sudo find /var/log -type f -size +100M -ls
Before deleting logs, determine whether log rotation or the application generating the logs needs attention.
Check Temporary and Application Data
Temporary files, application caches, package data and container storage can also consume significant disk space.
Inspect directories rather than deleting their contents blindly:
sudo du -xh --max-depth=1 /tmp | sort -h
sudo du -xh --max-depth=1 /var | sort -h
The exact directories worth investigating depend on the software and Linux distribution installed on the system.
Check Container Storage
On systems running Docker, images, containers, volumes and build cache can consume substantial disk space.
If Docker is installed, inspect its disk usage:
docker system df
This provides an overview of Docker's storage consumption.
Check Disk Space With a Simple Workflow
When a Linux server reports low disk space, use a structured workflow instead of immediately deleting files.
-
Run
df -hto identify the full filesystem. -
Run
df -ito check inode usage. -
Use
duto identify large directories. -
Use
findto locate unusually large files. - Inspect logs, application data, caches and backups.
-
Check for deleted files still held open by processes if
dfanddudisagree. - Make the smallest safe cleanup or configuration change.
-
Run
df -hagain and validate the application.
Quick Disk-Space Troubleshooting Path
Step 1: Run
df -h.
Filesystem full?
→ No: investigate application behavior, mounts and other possible causes.
→ Yes: continue.
Step 2: Run
df -i.
Inodes full?
→ Yes: locate directories containing large numbers of files.
→ No: continue.
Step 3: Use
du to identify large directories.
Step 4: Use
find to locate large files.
Step 5: Review logs, application data, backups, caches and container storage.
Step 6: If
df and du disagree significantly,
investigate open deleted files.
df vs du vs lsblk vs find
| Command | Best used for | Example |
|---|---|---|
df |
Filesystem capacity and free space | df -h |
du |
Directory and file usage | du -sh /var/log |
lsblk |
Disks, partitions and block devices | lsblk -f |
find |
Finding files based on conditions | find /var -type f -size +100M |
Common Linux Disk-Space Mistakes
Deleting files without identifying the cause
Removing a large file may temporarily create free space without fixing the process that caused the growth.
Using rm on system directories
Never delete system files simply because they appear large. Determine what they are and whether the associated service needs them.
Ignoring inode usage
A filesystem can have free capacity while running out of inodes.
Ignoring open deleted files
Deleting a log file doesn't necessarily immediately return all its storage if a running process still has the file open.
Cleaning production systems without a plan
Disk cleanup should be controlled, documented and validated, especially on production servers.
Linux Disk-Space Command Cheat Sheet
# Show filesystem usage
df -h
# Show inode usage
df -i
# Show filesystem containing a path
df -h /var
# Show directory size
du -sh /var/log
# Show immediate subdirectory sizes
du -xh --max-depth=1 /var | sort -h
# Find files larger than 100 MB
find /var -type f -size +100M -print
# Show disks and filesystems
lsblk -f
# Find deleted files still held open
sudo lsof +L1
References
Use official documentation when validating command syntax and distribution-specific behavior.