If you want to clear every cache on Ubuntu in one pass, see how to clear the cache on Ubuntu; this guide goes deep on /var. On a desktop that has run Ubuntu for a year or two, /var is often the surprise: the systemd journal keeps up to 4 GB of logs, apt keeps every package it ever downloaded, old kernels pile up after each update, and one noisy service can push a single log file past several GB. None of it is your data, and all of it can be shrunk with the tools Ubuntu ships. This guide shows how big each part is, the commands that shrink it safely, and what you should leave alone. If apt says the disk is full while df still shows free space, the cause is elsewhere: see Ubuntu says the disk is full, but df shows free space.
First, sizes:
df -h / # free space on the root filesystem
journalctl --disk-usage # the systemd journal
sudo du -sh /var/log /var/cache/apt /var/cache/PackageKit 2>/dev/null
sudo du -ah /var/log 2>/dev/null | sort -h | tail -15 # the biggest log files
The systemd journal
The journal holds the logs of the kernel and every system service, in /var/log/journal. By default it may use up to 10% of the filesystem, capped at 4 GB; it grows to that limit and then drops its oldest files. On a 256 GB disk that is 4 GB of logs you will rarely read.
Shrink it with journalctl itself, never with rm:
journalctl --disk-usage
sudo journalctl --vacuum-time=7d # delete archived journal files older than 7 days
sudo journalctl --vacuum-size=100M # and/or keep at most 100 MB of archived files
Vacuuming only deletes archived journal files; the file the journal is writing to now stays. To include it, archive it first with sudo journalctl --rotate, then vacuum.
Keep it small: SystemMaxUse
Vacuuming is a one-off: the journal grows back to its default limit. To set a lasting cap, add a drop-in file instead of editing the main config:
sudo mkdir -p /etc/systemd/journald.conf.d
printf '[Journal]\nSystemMaxUse=200M\n' | sudo tee /etc/systemd/journald.conf.d/size.conf
sudo systemctl restart systemd-journald
200 MB is weeks of logs on a typical desktop. If you ever need to debug something older, remove the file and restart journald again.
Rotated and oversized logs in /var/log
Besides the journal, some programs still write plain text logs to /var/log. logrotate renames them every week (syslog.1, then syslog.2.gz …) and keeps a few of each. Those rotated copies are safe to delete:
sudo find /var/log -type f \( -name '*.gz' -o -name '*.[0-9]' -o -name '*.old' \) -mmin +60 -print
sudo find /var/log -type f \( -name '*.gz' -o -name '*.[0-9]' -o -name '*.old' \) -mmin +60 -delete
A live log that grew huge (a service logging an error in a loop) is different: the service keeps the file open, so deleting it frees nothing until the service restarts. Empty it in place instead, and then fix the service that fills it:
sudo truncate -s 0 /var/log/syslog
Leave wtmp, btmp, lastlog and /var/log/audit alone: they are login and audit records, not clutter.
The apt cache: clean and autoclean
apt keeps every .deb it downloaded in /var/cache/apt/archives, even after the package is installed:
sudo du -sh /var/cache/apt/archives
sudo apt clean # delete all downloaded .deb files
sudo apt autoclean # or: only those that can no longer be downloaded (outdated versions)
Nothing installed is touched; if apt ever needs a package again, it downloads it. GNOME Software and Software Updater download through PackageKit into /var/cache/PackageKit instead, which apt clean doesn’t reach. Close both apps, then:
sudo rm -r /var/cache/PackageKit/downloads/* /var/cache/PackageKit/metadata/* # fetched again when needed
autoremove and old kernels
apt autoremove uninstalls packages that were installed as dependencies and that nothing needs any more — on Ubuntu, mostly old kernels after updates. Look first, then remove:
apt-get -s autoremove | grep '^Remv' # what would go (changes nothing)
sudo apt autoremove --purge # remove them and their config files
Ubuntu protects the running kernel and the newest ones, so autoremove always leaves a kernel to fall back to. Kernels you installed by hand are not marked automatic and stay; when /boot is full and autoremove can’t even run, follow Ubuntu: /boot is full.
Packages you removed without --purge leave their system config behind (status rc in dpkg -l). They are small, but they clutter the list:
dpkg -l | awk '/^rc/ {print $2}' # list them
dpkg -l | awk '/^rc/ {print $2}' | xargs -r sudo apt purge -y # purge them
Crash reports and core dumps
When a program crashes, Ubuntu’s Apport writes a report to /var/crash, and systemd-coredump may keep a memory dump in /var/lib/systemd/coredump. Both can be hundreds of MB each. Once you have reported the crash (or decided not to), delete them:
sudo du -sh /var/crash /var/lib/systemd/coredump 2>/dev/null
sudo rm /var/crash/*.crash
Safe to delete, or not
| What | Where | Safe? | How |
|---|---|---|---|
| Archived journal files | /var/log/journal |
Yes | journalctl --vacuum-time / --vacuum-size, never rm |
Rotated logs (*.gz, *.1, *.old) |
/var/log |
Yes | find … -delete as above |
| A live log that grew huge | /var/log/syslog, app logs |
Empty it, don’t delete it | truncate -s 0 |
| Downloaded packages | /var/cache/apt/archives |
Yes | apt clean or apt autoclean |
| PackageKit downloads | /var/cache/PackageKit |
Yes, with Software closed | delete the contents, keep the folders |
| Unused dependencies, old kernels | installed packages | Yes, after a look | apt autoremove --purge |
| Crash reports | /var/crash |
Yes | rm |
| Login and audit records | wtmp, btmp, lastlog, /var/log/audit |
No | leave them |
| apt’s state | /var/lib/apt, /var/lib/dpkg |
No | these are what apt knows is installed |
| The running kernel | /boot, linux-image-$(uname -r) |
No | never remove it |
How CleanMate does it
On Ubuntu 2.7.0 (see all Ubuntu features), Smart Scan lists each of these as its own item with its size, and you tick what goes. Steps that need root run through pkexec, which asks for your password once per cleanup — there is no background service with admin rights.
- Logs › Systemd journal logs: vacuums the journal so the last 7 days and at most 100 MB stay; you can change the size in Settings. The active journal is never cut.
- Logs › Rotated / archived logs:
*.gz,*.xz,*.1and*.oldfiles in/var/loguntouched for an hour. - Logs › Oversized active logs: live logs over 50 MB, emptied in place so services keep logging; the journal, login records and audit logs are never touched.
- Logs › Crash reports and Core dumps: Apport reports in
/var/crashand the dumps kept by systemd-coredump. - System Junk › APT package cache (
apt-get clean) and PackageKit cache (skipped while GNOME Software or Software Updater runs). - System Junk › Unused packages & old kernels: what
apt autoremovewould remove, decided again by apt at cleanup time. Extra old kernels (not ticked) removes kernels older than your two newest, never the running one. Leftover package configs purges thercpackages. - Maintenance › Limit journal size writes the
SystemMaxUsedrop-in for you (/etc/systemd/journald.conf.d/60-cleanmate.conf), and can remove it again.
From a terminal, the cm command does the same:
cm --scan --only system,logs # sizes, changes nothing
cm --clean --only logs # clean the logs after one confirmation
cm --json scan --only logs # the same as JSON, for scripts and AI agents
On Ubuntu, what apt purge keeps and where the leftovers in ~/.config hide is in uninstall an app and remove its leftover config files.
After the logs, check what Timeshift snapshots take — the other big invisible folder on a Ubuntu system disk.
The journal and the apt cache are also what a scheduled job or CleanMate’s automatic cleaning targets, so you do not run the vacuum by hand each time.
FAQ
Is it safe to delete /var/log/journal? Not with rm: you can break the journal that is being written. sudo journalctl --vacuum-size=100M frees the same space safely, and a SystemMaxUse drop-in keeps it from growing back.
What is the difference between apt clean, autoclean and autoremove? clean deletes all downloaded .deb files, autoclean only the outdated ones, and autoremove uninstalls packages nothing needs any more, usually old kernels. The first two never change what is installed.
Why is /var/log so big on Ubuntu? Usually the journal at its default limit (up to 4 GB), or one service writing an error in a loop to syslog. sudo du -ah /var/log | sort -h | tail shows which.
Will autoremove delete the kernel I’m using? No. apt protects the running kernel and the newest ones; check the list with apt-get -s autoremove before you confirm.
Does deleting logs make troubleshooting harder? Only for problems older than what you keep. A week or 100–200 MB of journal covers most “what happened yesterday” questions.
