Debug Disk Space Issues on Linux Systems
Disk space issues can be a common problem on Linux systems, but understanding how to diagnose and fix these can keep your system running smoothly.
Check Disk Usage
The first thing you would want to do is to check the overall disk usage. You can do this with the df
command, which stands for “disk filesystem.” Run df -h
to get a human-readable output of the amount of disk space used and available on all mounted filesystems. Look for filesystems that are close to their capacity. If any of them are at or near 100% usage, you will need to do some more investigation to understand what’s consuming the space.
Inspect Specific Directories
Once you’ve identified the filesystems that are full or nearly full, you can use the du
command, which stands for “disk usage,” to analyze which directories and files are taking up the most space. Start by navigating to the root of the filesystem or the directory that seems to be causing the problem. You can run du -sh *
to see the size of each file and directory in the current directory.
# Check all disk spaces in human-readable format
df -h
# Check disk spaces of files in current directory
du
# Check disk usage of current directory
du -sh