A safe and comprehensive Linux system maintenance and cleanup script designed to help keep your system clean, healthy, and optimized.
Linux Cleaner performs common maintenance tasks such as APT cleanup, log management, cache cleanup, Docker cleanup, disk health checks, SSD/NVMe TRIM, and more — while prioritizing system safety.
⚠️ Important: Always review what the script will remove before performing cleanup, especially when running it withsudo.
- 🛡️ Safe Cleanup
- 🧪
--dry-runMode - 📦 APT Cleanup & Package Repair
- 📝 Journal / Log Cleanup
- 🗑️ Temporary Files Cleanup
- 🌐 Browser Cache Cleanup
- 🐍 Python / Pip Cache Cleanup
- 🐳 Docker Cleanup
- 💾 Large File Analysis
- ⚡ SSD / NVMe TRIM
- 🩺 SMART Disk Health Check
- 🧠 RAM & Swap Information
- 🐧 Kernel Security Check
- 💥 Crash Report Cleanup
- 💾 Maintenance State Backup
- 📋 Detailed Logs
- 🚫 Does Not Automatically Remove Active Kernels
Clone the repository:
git clone https://github.com/spyschools/Linux-Cleaner.git
cd Linux-CleanerMake the script executable:
chmod +x Linux-Cleaner.shRun Linux Cleaner:
sudo ./Linux-Cleaner.shYou can install Linux Cleaner as a system-wide command:
sudo install -m 755 Linux-Cleaner.sh /usr/local/bin/linux-cleanerThen run it from anywhere:
sudo linux-cleanerPreview the cleanup operations without applying changes:
sudo ./Linux-Cleaner.sh --dry-runIf installed system-wide:
sudo linux-cleaner --dry-run
--dry-runis recommended before performing a full cleanup, especially on production systems.
Linux Cleaner is designed to minimize the risk of accidental system damage.
The script:
- Performs safety checks before maintenance
- Supports
--dry-run - Checks for required commands
- Provides detailed logs
- Handles optional components gracefully
- Avoids automatically removing the active kernel
- Performs package repair operations when required
- Avoids blindly deleting critical system files
Linux Cleaner does not automatically remove active/running kernels.
This prevents the script from accidentally deleting the kernel currently being used by the system.
- Clean package cache
- Remove unnecessary packages
- Repair package configuration/state
- Analyze system journal
- Remove old journal entries according to the configured cleanup policy
- Record maintenance activity
Clean unnecessary temporary files while avoiding critical system locations.
Clean supported browser cache directories.
Clean unnecessary Python/Pip cache data.
Detect and clean unused Docker resources when Docker is installed.
Analyze large files and help identify what is consuming disk space.
Run filesystem TRIM using fstrim when supported.
Check available SMART information using smartctl.
Display:
- RAM usage
- Available memory
- Swap usage
Inspect the currently running and installed kernel information.
Clean unnecessary crash report files.
Linux Cleaner provides detailed logging to make maintenance activity easier to review and troubleshoot.
Logs can show:
- Operations performed
- Operations skipped
- Detected system information
- Errors and warnings
- Cleanup results
Linux Cleaner can preserve maintenance-related state information before performing operations.
This provides an additional layer of protection and makes it easier to understand the system's maintenance status.
Linux Cleaner is primarily designed for Debian-based Linux distributions, including:
- Debian
- Ubuntu
- Linux Mint
- Kali Linux
- Other Debian-based distributions
Some features depend on the installed software, filesystem, hardware, and Linux distribution.
- Bash
sudo- Debian-based package manager (
apt) systemd/journalctl
The following tools are used when available:
dockersmartctllsblkfstrim
Missing optional tools should not prevent the other maintenance functions from running.
Some operations require administrator privileges.
Run Linux Cleaner with:
sudo linux-cleaneror:
sudo ./Linux-Cleaner.shBasic cleanup:
sudo linux-cleanerDry run:
sudo linux-cleaner --dry-runHelp:
sudo linux-cleaner --helpAvailable options may depend on the version of Linux Cleaner installed.
╔══════════════════════════════════════╗
║ 🧹 LINUX CLEANER ║
║ System Maintenance Tool ║
╚══════════════════════════════════════╝
[✓] Checking system
[✓] Cleaning APT cache
[✓] Repairing package state
[✓] Cleaning journal logs
[✓] Cleaning temporary files
[✓] Cleaning browser cache
[✓] Cleaning Python/Pip cache
[✓] Checking Docker
[✓] Analyzing large files
[✓] Checking disk health
[✓] Checking RAM & swap
[✓] Checking kernel security
[✓] Running SSD/NVMe TRIM
[✓] Maintenance completed successfully.
Linux Cleaner is provided as-is, without warranty.
System cleanup can modify or remove files, packages, caches, logs, and other system resources.
Although Linux Cleaner is designed with safety in mind, users should understand the operations being performed before running the script.
Use this software at your own risk.
Contributions, bug reports, feature requests, and improvements are welcome.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature- Commit your changes:
git commit -m "Add new feature"- Push the branch:
git push origin feature/my-feature- Open a Pull Request.
This project is currently distributed without a specified license.
If you want others to freely use, modify, and distribute the project, consider adding an open-source license such as MIT License.
If you find Linux Cleaner useful, please consider giving the repository a ⭐ Star on GitHub.
Repository:
spyschools/Linux-Cleaner
Simple. Safe. Powerful.
Keep your Linux system clean, healthy, and maintained.