Table of Contents
Running out of disk space in Ubuntu 25.04 can slow down your system and cause update failures, so cleaning unnecessary files regularly helps keep your system fast, stable, and reliable.
STEP 1: Check Current Disk Usage
Before starting any cleanup, it is important to accurately check your current disk usage so you can identify which partitions and directories are consuming the most storage and plan an effective space-freeing strategy.
df -h
Check which folders use the most space:
du -h --max-depth=1 / | sort -hr
STEP 2: Clean Package Cache
Cleaning the package cache removes unnecessary downloaded files from previous installations and updates, helping you quickly free up valuable disk space without affecting system performance.
sudo apt clean
Remove outdated packages:
sudo apt autoclean
STEP 3: Remove Unused Packages
Over time, Ubuntu accumulates unused dependencies and orphaned packages that waste disk space. Removing these unnecessary packages helps keep your system lean, organized, and optimized for better performance
sudo apt autoremove -y
Check orphan packages:
deborphan
STEP 4: Clear System Logs
System log files can grow very large over time, consuming significant disk space. Regularly clearing old logs helps maintain optimal storage and ensures your system runs efficiently.
sudo journalctl --vacuum-time=3d
Restart logging service:
sudo systemctl restart systemd-journald
STEP 5: Delete Temporary Files
Temporary files and user cache accumulate over time and can occupy a lot of disk space. Regularly deleting these files keeps your system clean and ensures more storage is available for important data.
sudo rm -rf /tmp/*
Clear user cache files:
rm -rf ~/.cache/*
STEP 6: Remove Old Snap Versions
Snap packages often keep older versions after updates, which can consume significant disk space. Removing these unused versions helps free storage and keeps your Ubuntu system clean and efficient
snap list --all
Remove unused snap versions:
sudo snap remove --purge <package-name>
STEP 7: Find Large Files
Identifying and managing large files is essential for freeing up disk space, as a few oversized files can occupy a significant portion of your storage. Regularly locating and cleaning them keeps your system optimized
sudo find / -type f -size +500M -exec ls -lh {} \
Delete unnecessary large files:
rm -rf /path/to/file
STEP 8: Empty Trash
Deleted files are stored in the Trash and continue to occupy disk space until permanently removed. Regularly emptying the Trash ensures that storage is fully reclaimed and your system remains organized.
rm -rf ~/.local/share/Trash/*
Check freed disk space:
df -h