KlystorDownload

Free up space on Linux: apt, dnf, logs, Snap and Flatpak

On Linux, space is mostly lost in package caches, logs and old app versions. Each tool has its own cleanup command: here are the right ones, distribution by distribution.

7 min readUpdated

01Measure

Free space on each partition, then the heaviest folders in your home directory:

df -h
du -sh ~/* ~/.[!.]* 2>/dev/null | sort -h | tail -15

The ncdu tool, available in every distribution, also lets you browse the tree while seeing each folder’s size.

02The package manager

It keeps downloaded packages and dependencies that are no longer needed. On Debian, Ubuntu and Linux Mint:

sudo apt autoremove --purge
sudo apt clean

On Fedora:

sudo dnf autoremove
sudo dnf clean all

autoremove also removes old kernels on Ubuntu; Fedora keeps only three. Read the proposed list before confirming.

03systemd logs

The system journal can reach several GB. Check its size, then limit it:

journalctl --disk-usage
sudo journalctl --vacuum-size=200M

For a permanent limit, set SystemMaxUse=200M in /etc/systemd/journald.conf. Do not empty /var/log by hand: some services expect their files.

04Snap and Flatpak

Snap keeps old revisions of each app. Reduce them to two from now on, then list the disabled ones:

sudo snap set system refresh.retain=2
snap list --all | grep disabled

Each line is removed with sudo snap remove NAME --revision=NUMBER.

Flatpak leaves runtimes that no app uses anymore:

flatpak uninstall --unused

05Caches, Trash and snapshots

~/.cache holds your apps’ caches (browsers, thumbnails, developer tools). Its contents rebuild; clear it with your apps closed. The Trash lives in ~/.local/share/Trash and is emptied from the file manager.

If you use Timeshift or Snapper, old snapshots can take up a lot of space: delete them from Timeshift or with snapper delete, keeping the most recent one. For Docker and development dependencies, see Clean up developer caches.

What not to do

  • deleting by hand in /usr, /var/lib/dpkg, /var/lib/rpm or /boot: the package system or boot can break;
  • removing a kernel by hand, especially the one in use (uname -r);
  • running sudo rm -rf /var/log/*: use journalctl --vacuum-size;
  • copying a cleanup command found online without understanding what it erases.

Klystor

All of this, safely and in minutes

Klystor measures your disk, explains every item and only offers what rebuilds itself or what you choose. A dry run before every deletion, the Trash by default. Free during the beta, for macOS, Windows and Linux.

Need help?