Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

🧹 cache-cleaner

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.

Shell Platform License Stars

FeaturesUsageWhat Gets CleanedWarningContributing


Overview

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

Features

  • 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)

Usage

Clone the repository:

git clone https://github.com/robotjaol/cache-cleaner.git
cd cache-cleaner
chmod +x clean.sh

Run standard cleanup:

./clean.sh

Run aggressive cleanup (also touches Docker, Flatpak, and dev caches):

./clean.sh --aggressive

If your clean.sh does not yet parse flags, split it into two scripts (clean.sh and clean-aggressive.sh) or add a simple case "$1" in --aggressive) ... ;; esac block. See Roadmap.

What Gets Cleaned

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 -y

Aggressive

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 {} +

Warning

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"

Roadmap

  • 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.sh for one-line install via curl
  • Add tests / CI (shellcheck lint on push)

Contributing

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.

License

MIT. See LICENSE (add this file if not present yet).

About

Fast, aggressive Ubuntu/Linux cache cleaner written in Bash. Reclaim disk space by cleaning system caches, logs, temp files, APT, Snap, Flatpak, Docker, Python, Node.js, and developer build artifacts in one command.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages