Optimize System Storage on Linux Mint

Learn how to clean up system storage on Linux Mint, using both graphical tools and command-line utilities.

Introduction

Over time, as you use your Linux Mint system, various files accumulate—temporary files, system logs, cache files, old kernels, unused packages, and more. These can gradually consume significant disk space, potentially affecting system performance. Regularly cleaning up system storage helps optimize performance, free up space, and maintain system health.

In this comprehensive guide, we’ll explore different methods to clean up system storage on Linux Mint, using both graphical tools and command-line utilities. This guide is suitable for beginners and advanced users alike.

Why Cleaning Up System Storage Is Important

  • Improved Performance: Reducing unnecessary files helps your system run faster.
  • More Free Space: Reclaim storage for important files and applications.
  • Enhanced Stability: Removing outdated packages and logs minimizes potential conflicts and errors.
  • Security: Eliminating old caches and logs reduces exposure to potential vulnerabilities.

Precautions Before Cleaning

  1. Backup Important Data: Always back up critical data before performing system cleanups.
  2. Review Files Carefully: Double-check before deleting files to avoid removing essential system components.
  3. Use Administrative Privileges: Some cleanup tasks require sudo permissions.

Graphical Tools for Cleaning Up System Storage

1. Disk Usage Analyzer (Baobab)

Disk Usage Analyzer provides a visual representation of disk usage, making it easy to identify large files and directories.

Installation (if not pre-installed)

sudo apt install baobab

How to Use

  • Open Menu > Accessories > Disk Usage Analyzer.
  • Select the drive or folder you want to analyze.
  • Identify large files and directories and delete unnecessary ones.

Pros

  • User-friendly graphical interface.
  • Great for visualizing disk usage.

Cons

  • Doesn’t clean files automatically; manual deletion required.

2. BleachBit

BleachBit is a powerful cleanup tool similar to CCleaner on Windows. It helps delete cache, temporary files, logs, and more.

Installation

sudo apt install bleachbit

How to Use

  • Open BleachBit (as regular user or with sudo for deeper cleaning).
  • Select categories to clean (e.g., browser cache, system logs).
  • Click Clean to start the process.

Pros

  • Thorough cleaning options.
  • Secure file shredding feature.

Cons

  • Misuse can delete important system files; review options carefully.

3. Stacer

Stacer is an all-in-one system optimizer with a clean interface.

Installation

sudo apt install stacer

Features

  • System Cleaner: Removes cache, logs, and temporary files.
  • Startup Apps: Manage startup programs.
  • Uninstaller: Remove unnecessary applications.

Pros

  • Attractive, user-friendly interface.
  • Multiple optimization tools in one app.

Cons

  • Slightly heavier than command-line tools.

Command-Line Tools for System Cleanup

For those comfortable with the terminal, command-line tools offer powerful and flexible cleanup options.

1. APT Package Cleanup

a. Remove Unused Packages

sudo apt autoremove

This command removes unnecessary packages installed as dependencies that are no longer needed.

b. Clean Package Cache

sudo apt clean

This clears the APT cache in /var/cache/apt/archives, freeing up space.

c. Clear Partial Package Files

sudo apt autoclean

Removes obsolete package files that can no longer be downloaded.

2. Removing Old Kernels

Linux Mint often retains old kernels after updates. Removing unused kernels can free up space.

List Installed Kernels

dpkg --list | grep linux-image

Remove Old Kernels

sudo apt remove --purge linux-image-<version>

Replace <version> with the kernel version you want to remove.

Important: Do NOT remove the current kernel. Verify with:

uname -r

3. Cleaning Log Files

System logs can accumulate over time.

Clear System Logs

sudo journalctl --vacuum-time=2weeks

This command deletes logs older than two weeks.

For manual log cleanup

sudo rm -rf /var/log/*.log

4. Removing Thumbnails Cache

Thumbnail caches can consume space, especially if you handle many images.

Clear Thumbnails

rm -rf ~/.cache/thumbnails/*

5. Finding and Removing Large Files

Using du (Disk Usage)

sudo du -ah / | sort -rh | head -n 20

Displays the 20 largest files on your system.

Using ncdu (NCurses Disk Usage)

Installation:

sudo apt install ncdu

Usage:

sudo ncdu /

Navigate with arrow keys to explore directories and delete large files.

6. Cleaning Temporary Files

Clear System Temp Files

sudo rm -rf /tmp/*

Clear User Temp Files

rm -rf ~/.cache/*

Automating System Cleanup with Cron

For regular cleanups, you can automate tasks using cron jobs.

Example: Automate APT Cleanup Weekly

crontab -e

Add the following line:

0 2 * * 0 sudo apt autoremove -y && sudo apt autoclean -y

This runs cleanup every Sunday at 2 AM.

Best Practices for System Cleanup

  1. Backup Data Regularly: Ensure you have backups before major cleanups.
  2. Verify Before Deletion: Double-check files to avoid deleting critical system components.
  3. Automate with Care: Automate only routine, safe tasks like clearing caches.
  4. Monitor Disk Usage: Use tools like baobab or ncdu to identify large files.
  5. Regular Maintenance: Schedule monthly cleanups for optimal performance.

Troubleshooting Common Issues

  • Accidentally Deleted Important Files: Restore from backup or use file recovery tools.

  • Disk Space Not Recovered: Check if deleted files are in Trash or held by running processes.

    sudo lsof | grep deleted
    
  • System Breaks After Cleanup: Boot into recovery mode, reinstall missing packages if needed.

Conclusion

Keeping your Linux Mint system clean not only helps reclaim valuable disk space but also ensures smooth and efficient performance. Whether you prefer graphical tools like BleachBit, Stacer, and Disk Usage Analyzer, or powerful command-line utilities such as apt, ncdu, and journalctl, Linux Mint offers a variety of options to suit every user’s preference.

By regularly performing these cleanup tasks and following best practices, you can maintain a healthy, fast, and reliable Linux Mint system for years to come.


Last modified 20.02.2025: new kotlin and mint content (93a1000)