Disk usage management helps monitor storage consumption and prevent system failures due to full disks.
Linux provides command-line tools to analyze, manage, and clean disk space safely.
View disk usage of all mounted filesystems.
df -h
Check space used by specific directories.
du -sh /var
du -sh /home/*
du -h --max-depth=1 /
Locate large files that consume significant disk space.
find / -type f -size +1G 2>/dev/null
Disk space issues can also occur due to inode exhaustion.
df -i
Remove cached package files.
sudo apt clean
sudo apt autoclean
sudo apt autoremove
Clean cached metadata and packages.
sudo yum clean all
sudo yum autoremove
Log files can grow very large over time.
Check log sizes:
sudo du -sh /var/log/*
Clear old systemd logs:
sudo journalctl --vacuum-time=7d
Temporary files are stored in /tmp.
sudo rm -rf /tmp/*
Deleted files may still consume space if used by running processes.
lsof | grep deleted
Restart the related service to release disk space.
Remove cached data from user directories.
rm -rf ~/.cache/*
Use text-based disk usage analyzers.
sudo apt install ncdu
ncdu /
Recheck disk usage after cleanup.
df -h
Regular disk usage monitoring and cleanup prevent storage-related issues. Using built-in Linux tools ensures efficient disk space management while maintaining system stability.