Checking Disk Space
# Filesystem usage summary
df -h
# Specific mount point
df -h /
# Inode usage (running out prevents creating files)
df -iFinding Large Files and Directories
# Top 10 largest directories
du -h --max-depth=1 / 2>/dev/null | sort -rh | head -10
# Top 20 largest files
find / -type f -exec du -h {} + 2>/dev/null | sort -rh | head -20
# Files larger than 100 MB
find / -type f -size +100M -exec ls -lh {} \; 2>/dev/nullInteractive Tools
# ncdu — interactive disk usage analyzer
sudo apt install -y ncdu
ncdu /Navigate with arrow keys, press d to delete, q to quit.
Common Cleanup Tasks
# Clean apt cache
sudo apt clean
sudo apt autoremove -y
# Remove old kernels (keep current + one previous)
sudo apt autoremove --purge
# Clean old journal logs (keep last 7 days)
sudo journalctl --vacuum-time=7d
# Find and remove old log files
find /var/log -name "*.gz" -mtime +30 -delete
find /var/log -name "*.old" -delete
# Clean /tmp (files older than 7 days)
find /tmp -type f -atime +7 -deleteMonitoring Disk Growth
Add a cron job to alert when disk usage exceeds a threshold:
0 */6 * * * df -h / | awk 'NR==2 {gsub(/%/,"",$5); if($5>85) print "Disk " $5 "% full"}' | mail -s "Disk Alert" admin@example.com