Fast, aggressive disk space reclaimer for Ubuntu/Linux systems.
One command to clean system caches, logs, temp files, package manager leftovers, container volumes, and developer build artifacts.
Features • Usage • What Gets Cleaned • Warning • Contributing
cache-cleaner is a zero-dependency Bash script for reclaiming disk
space on Ubuntu and Debian-based systems. It targets the usual
suspects that quietly eat gigabytes over time: trash, thumbnail
caches, package manager caches, journal logs, Docker layers, and
stale build artifacts from Node.js and Python projects.
Two modes are provided:
| Mode | Scope |
|---|---|
| Standard | Trash, user cache, thumbnails, /tmp, journal logs, Snap cache, APT cache |
| Aggressive | Everything in Standard, plus pip cache, Python/Node build caches, Docker system prune, Flatpak unused runtimes, old logs, crash dumps |
- No external dependencies, pure Bash and coreutils
- Two cleanup levels depending on how much you want to reclaim
- Covers APT, Snap, Flatpak, Docker, pip, and Node/JS build caches in one pass
- Safe to inspect before running (plain shell, no obfuscation)
Clone the repository:
git clone https://github.com/robotjaol/cache-cleaner.git
cd cache-cleaner
chmod +x clean.shRun standard cleanup:
./clean.shRun aggressive cleanup (also touches Docker, Flatpak, and dev caches):
./clean.sh --aggressiveIf your
clean.shdoes not yet parse flags, split it into two scripts (clean.shandclean-aggressive.sh) or add a simplecase "$1" in --aggressive) ... ;; esacblock. See Roadmap.
Standard
sudo rm -rf ~/.local/share/Trash/* && \
sudo rm -rf ~/.cache/* && \
sudo rm -rf ~/.cache/thumbnails/* && \
sudo rm -rf /tmp/* && \
sudo journalctl --vacuum-time=3d && \
sudo rm -rf /var/lib/snapd/cache/* && \
sudo apt clean && \
sudo apt autoremove -yAggressive
sudo rm -rf \
~/.local/share/Trash/* \
~/.cache/* \
~/.cache/thumbnails/* \
/tmp/* && \
sudo journalctl --vacuum-time=3d && \
sudo apt clean && \
sudo apt autoremove -y && \
rm -rf ~/.cache/pip && \
find ~ -type d -name "__pycache__" -exec rm -rf {} + && \
find ~ -type d -name ".pytest_cache" -exec rm -rf {} + && \
find ~ -type d -name ".mypy_cache" -exec rm -rf {} + && \
find . -type d -name "node_modules/.cache" -exec rm -rf {} + && \
find . -type d -name ".next" -exec rm -rf {} + && \
find . -type d -name "dist" -exec rm -rf {} + && \
find . -type d -name "build" -exec rm -rf {} + && \
find . -type d -name ".turbo" -exec rm -rf {} + && \
find . -type d -name ".vite" -exec rm -rf {} + && \
docker system prune -a --volumes -f && \
sudo rm -rf /var/lib/snapd/cache/* && \
flatpak uninstall --unused -y && \
sudo rm -rf /var/tmp/flatpak-cache/* && \
sudo find /var/log -type f -name "*.gz" -delete && \
sudo find /var/log -type f -name "*.1" -delete && \
sudo rm -rf /var/crash/* && \
find ~ -name ".DS_Store" -delete && \
find /media -type d -name ".Trash-*" -exec rm -rf {} +This script deletes data permanently. There is no undo.
- Aggressive mode runs
docker system prune -a --volumes -f, which removes all unused Docker images, containers, and volumes, including ones not related to your current project. - The Node/Python build cache cleanup (
find . -type d -name "dist" ...) runs against the current working directory, so running it from your home folder or a large monorepo will delete build output across every project underneath it. - Always dry-run unfamiliar cleanup scripts, or review each command block before executing.
Recommended before first run:
# Preview what would be deleted, without -exec rm -rf
find . -type d -name "dist"- Convert to a proper CLI with flags (
--dry-run,--aggressive,--target=docker,apt,node) - Add a dry-run mode that reports reclaimable space before deleting
- Add
install.shfor one-line install via curl - Add tests / CI (shellcheck lint on push)
Issues and pull requests are welcome. If you are adding a new cleanup target, keep it scoped, avoid destructive defaults, and document what it removes in this README.
MIT. See LICENSE (add this file if not present yet).