CleanMate

All guides · Ubuntu · Updated

How to clear the cache on Ubuntu: ~/.cache, apt, the journal, thumbnails, snap and Flatpak

Sizes first, then the safe commands: folders under ~/.cache, the thumbnail cache, sudo apt clean, journalctl --vacuum, PackageKit and snap/Flatpak caches — what each one costs, and what you should not delete.

Install on Ubuntu — free and open source

CleanMate for Ubuntu after a scan, listing cache items with their sizes

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:

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

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:

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.

Looking for a BleachBit alternative for Ubuntu? See how CleanMate compares, feature by feature.

Skip the commands

Open source — star it on GitHub: CleanMate for Ubuntu

How CleanMate decides what is safe to remove →