Ubuntu fills up quietly: every app you install caches something in your home folder, apt keeps the .deb files it downloaded, the systemd journal archives its logs, and the file manager keeps a preview of every image you ever opened. All of it can be cleared without losing anything that matters — most of it from your own user account. This guide walks the caches in order of size, with the commands to clear each one safely.
First, sizes:
df -h / # free space on the root filesystem
du -sh ~/.cache 2>/dev/null # your per-user caches
du -sh ~/.cache/* 2>/dev/null | sort -h | tail -15
sudo du -sh /var/cache/apt /var/log/journal /var/cache/PackageKit /var/lib/snapd/snaps /var/lib/flatpak 2>/dev/null
~/.cache, folder by folder
~/.cache is the dump for user-level caches, and one folder there is usually 10× the rest. Quit an app before clearing its folder — a running app will just recreate the files, sometimes half-written:
# after quitting the app (folder name from the du listing above)
rm -rf ~/.cache/spotify
Spotify keeps your offline downloads in that folder too; see Spotify, Apple Music and Podcasts downloads and cache.
Three cautions:
- Don’t wipe all of
~/.cachein one command while apps are running; a few apps keep long-lived work there, such as a cloud sync client’s files that are still waiting to be uploaded (~/.cache/Nextcloud). - Files that are old and untouched (not modified or read for weeks) are the safe win; what was touched recently may be in active use.
- Browser caches (
~/.cache/mozilla,~/.cache/google-chrome, Chromium, Brave, Opera, Vivaldi) are best cleared from inside the browser, together with the history you choose: see browser data: cache, history, cookies.
Thumbnail cache
The file manager draws a preview of every image and video, and keeps it in ~/.cache/thumbnails — years of files later, that alone can be several GB:
du -sh ~/.cache/thumbnails
rm -rf ~/.cache/thumbnails/* # previews are drawn again when you open the folder
The APT package cache
apt keeps every .deb it downloaded in /var/cache/apt/archives, even after the packages are installed:
sudo du -sh /var/cache/apt/archives
sudo apt clean # delete them; apt downloads again if ever needed
Nothing installed or configured is touched. GNOME Software and Software Updater download packages through PackageKit into /var/cache/PackageKit, which apt clean does not reach. It needs root, like the apt cache:
sudo rm -rf /var/cache/PackageKit/* # fetched again when needed
The systemd journal
The journal is the kernel’s and system services’ logs in /var/log/journal. It is capped by default (10% of the filesystem, at most 4 GB — SystemMaxUse if you set it), so it grows to its cap and then only rotates. Check and shrink:
journalctl --disk-usage
sudo journalctl --vacuum-time=7d # keep the last 7 days
sudo journalctl --vacuum-size=100M # and/or shrink to 100 MB
To keep that cap across reboots, set SystemMaxUse=100M under the [Journal] section of /etc/systemd/journald.conf (then sudo systemctl restart systemd-journald). Don’t delete files inside /var/log/journal by hand — vacuuming keeps the current journal consistent. More on /var/log, rotated logs and apt autoremove: the systemd journal, /var/log and the apt cache.
Snap and Flatpak caches
Snap and Flatpak apps cache in their own sandbox: ~/snap/<name>/common/.cache and ~/.var/app/<id>/cache. On top of that, snap keeps disabled old revisions of each app and Flatpak keeps runtimes no app uses any more — often more than the caches: see snap and Flatpak disk space and, if the root filesystem is truly full, Ubuntu: /boot is full.
What not to delete
- ~/.config and ~/.local/share — settings, profiles, mail and app data. Nothing there is regenerated when you delete it, and one folder can be years of work.
- The Trash without looking — check for something dropped in there before emptying.
/var/logas a whole, or/var/lib/snapd/snapswithrm— vacuum the journal and remove snap revisions with systemd’s and snap’s own commands instead.
How CleanMate does it
On Ubuntu 2.7.0 (see all Ubuntu features), the same work from one window, and the risky parts are already sorted out. The Smart Scan page explains what each scan category removes on Mac and Ubuntu:
- Smart Scan › System Junk › APT package cache and PackageKit cache: emptied the same way as
apt clean; the root steps run throughpkexec, which asks once for your password — no admin daemon in between. - Smart Scan › Logs › Systemd journal logs: vacuumed so the last 7 days and at most 100 MB stay (the size limit is adjustable in Settings › Journal size limit) while the active journal stays consistent.
- Smart Scan › User & App Junk › Thumbnail cache: emptied by default; previews are drawn again on demand.
- Smart Scan › User & App Junk › Stale app caches (>30 days): only the files under
~/.cachethat haven’t been modified or read for 30 days, leaving out caches that have their own items (browsers, chat and dev-tool caches). A folder you actively use is untouched. - User & App Junk also lists the cache folder of each Electron, Snap and Flatpak app as its own choice, skipped while that app runs.
- Maintenance carries the long-term limits: remove unused Flatpak runtimes, keep fewer snap revisions, and the journal size cap.
- Caches are deleted for good, not moved to the Trash — that bucket is for files you might want back, like old installers and downloads. Install CleanMate.
Recent files, shell history and other traces are in delete recent files, browser history and app traces.
To stop doing this by hand, caches like these are exactly what automatic cleanup on a schedule handles on Ubuntu.
FAQ
Is it safe to delete the whole ~/.cache folder? Mostly yes, apps rebuild it — but do it with everything closed, and expect the first launches after it to be slower; folder by folder (or stale files only) is the safer habit.
What is the difference between sudo apt clean and sudo apt autoremove? clean deletes cached downloads; autoremove uninstalls packages (on Ubuntu, typically old kernels). The Ubuntu /boot guide covers autoremove and the kernel cleanup story.
How big should the journal be? Whatever fits in your disk’s budget; 100 MB is enough for routine logs on most desktop machines and leaves the active journal untouched.
Do dev caches (pip, npm, Go, Cargo) get cleaned by the same rules? They live in ~/.cache and ~/.npm too, but each dev tool gets its own item — see freeing disk space on Ubuntu as a developer.
