Running out of disk space on Linux? Before you delete your photo collection or reinstall the system, try the methodical approach: find what's eating your disk, then clean it with tools built for the job. I ran 7 common cleanup methods on an Ubuntu 24.04 machine on October 21, 2026, measured exactly what each one freed, and found one hidden cache folder holding 3 GB all by itself. Here's what worked and what didn't.

Step 0: Find What's Eating Your Disk

Cleaning blindly is how people delete something important. Start with one command:

du -sh /* 2>/dev/null | sort -rh | head -10

This shows the biggest top-level directories. On my test machine, the surprise was /home/hatch/.cache at 4.4 GB. Drilling one level deeper:

du -sh ~/.cache/* 2>/dev/null | sort -rh | head -5

Result: pip's download cache alone was 3.0 GB (954 cached packages), Playwright browser binaries were 681 MB, and a Hugging Face model cache was 680 MB. The apt package cache in /var/cache/apt was 153 MB, system logs were only 8.2 MB.

If you prefer a visual tool, install ncdu — it gives you an interactive, navigable breakdown of any folder:

sudo apt install ncdu
ncdu ~/

(I installed ncdu 1.19 from Ubuntu's own repositories during this test — it worked first try.) On Windows, the equivalent is TreeSize Free; Microsoft's own support guide walks through the built-in options too (Microsoft Support).

The 7 Methods, Tested

1. Purge the pip cache — freed 3.0 GB

Python's package installer keeps a local copy of every package it has ever downloaded, in ~/.cache/pip. If you've installed Python tools more than a couple of times, this folder quietly grows into gigabytes. It's completely safe to clear — pip simply re-downloads if it ever needs a cached file again.

pip cache purge

On my test machine (pip 24.0, Python 3.12): 954 files removed, 3.0 GB freed. This was the single biggest win by far, and it took about two seconds.

2. Clean the apt package cache — freed 153 MB

Every time you run apt upgrade, Ubuntu keeps downloaded .deb files in /var/cache/apt/archives so it can reinstall without re-downloading. Over months, this pile grows. One command empties it:

sudo apt clean

Test result: /var/cache/apt went from 153 MB to 0. Also run sudo apt autoremove to remove orphaned packages no longer needed — on my machine a dry run found nothing to remove, but on a long-lived desktop it routinely frees hundreds of megabytes.

3. Vacuum the system journal — freed 0 MB (honestly)

Systemd keeps logs in the journal, and they can grow large on servers. The command to cap them:

sudo journalctl --vacuum-size=50M

Result on my machine: freed 0 bytes — because only 8 MB of journals existed in the first place. I'm including this because it shows an important truth: not every "cleanup tip" matters on every machine. On a desktop this is usually noise; on a server that's been running for years, it's worth checking with journalctl --disk-usage first.

4. Clear thumbnail and user caches — freed ~1 MB

Desktop environments cache file thumbnails in ~/.cache/thumbnails. Safe to delete, but honestly small — 1.1 MB on my test machine. On a desktop where you've browsed folders full of photos for years, it can reach hundreds of megabytes:

rm -rf ~/.cache/thumbnails/*

5. Empty the trash — check before you celebrate

Linux desktops have a trash can (~/.local/share/Trash) that keeps "deleted" files until you empty it. It's the #1 reason people delete files and see no space freed. Empty it from your file manager (right-click the trash icon) or:

rm -rf ~/.local/share/Trash/files/*

My test machine had nothing in the trash, but I've seen desktops where this alone recovered 20+ GB.

6. Find the giant forgotten files

Sometimes one forgotten file is the whole problem — an old VM image, a video export, a debug log. This finds files over 500 MB:

find / -xdev -type f -size +500M 2>/dev/null

On my test machine this turned up only system binaries (browser, compiler libraries, code tools) — all belonging to installed software, so all left alone. If it turns up a 40 GB file named old-backup-final-FINAL.tar.gz, you know what to do.

7. Move data, don't just delete it

When the drive is genuinely full of files you want to keep — photos, videos, project archives — the answer isn't cleanup, it's relocation. Move the big, rarely-touched stuff to an external drive or cloud storage. On Linux, rsync -av --remove-source-files moves a folder while preserving everything:

rsync -av --remove-source-files ~/Videos/ /mnt/external-drive/Videos/

What About Windows and macOS?

I tested on Linux, so the steps above are the ones I can vouch for personally. On Windows, the equivalents are Storage Sense (Settings > System > Storage, turn it on) and the built-in Disk Cleanup tool — Microsoft documents both in its official guide. On macOS, Apple menu > About This Mac > More Info > Storage Settings shows a breakdown with built-in recommendations (empty trash automatically, offload iCloud files). The principle is identical on every system: measure first, then clean the caches and package files — never random system folders.

FAQ

Is it safe to delete everything in ~/.cache? Mostly yes — caches are meant to be rebuilt. But don't blanket-delete it while apps are running; browsers and IDEs keep live state there. I deleted only specific cache folders (pip, thumbnails) in this test, which is the safer pattern.

How much space should I keep free? Aim for at least 10–15% of the drive free. Below that, Linux filesystems slow down, and some updates will refuse to install.

Will deleting cache files break my programs? Package caches (pip, apt) and thumbnails: no. Application data folders (browser profiles, configs): don't touch those unless you know exactly what they hold. When in doubt, rename instead of delete — if nothing breaks for a week, delete the renamed folder.

Why is my disk full but I can't find what's using it? The trash can and hidden dot-folders (~/.cache, ~/.local/share) are the usual hiding spots. du and ncdu find them; the file manager's default view doesn't.

Conclusion

On my Ubuntu 24.04 test machine, two commands — pip cache purge and sudo apt clean — freed 3.15 GB in under a minute, and the journal vacuum proved that not every cleanup tip pays off on every system. The real lesson: run du first. Knowing that one cache folder held 3 GB turned a vague "my disk is full" into a two-command fix. Next time your system warns about low space, start with the audit, hit the package and download caches, empty the trash, and only then consider moving data elsewhere.

How this article was made

All Linux numbers come from tests I ran on October 21, 2026, on Ubuntu 24.04.5 LTS (kernel 7.0.0-39-generic), using du, df, pip cache purge (pip 24.0, Python 3.12), sudo apt clean, apt autoremove --dry-run, journalctl --vacuum-size, and find. ncdu 1.19 was installed from Ubuntu's repositories to verify that step. The Microsoft Support and TreeSize links were checked and returned HTTP 200 on the test date. Windows and macOS guidance is general how-to knowledge, not tested by me — the article says so where relevant. No benchmarks were invented; the journal-vacuum zero result is reported honestly as a zero. This article was written by Tiny, UnlockProof's AI assistant, and is awaiting human editorial review before publication.