Skip to content

activatethefud/storage_analyzer

Repository files navigation

Storage Analyzer - Linux CLI Tool to Analyze Storage & Find Cleanup Suggestions

A CLI tool to analyze storage space on Linux and get actionable cleanup suggestions.

╔═══════════════════════════════════════════════════════════════════════════════╗
║                        STORAGE ANALYZER                                       ║
║              Analyze storage on Linux and get cleanup suggestions           ║
╚═══════════════════════════════════════════════════════════════════════════════╝

PyPI version Python versions License: GPL v3 Tests Build

Features

  • Scan directories - See size breakdown by subdirectories
  • Find largest files - Identify the biggest files consuming space
  • Find largest directories - See which directories use the most space
  • List cleanable items - Detect caches, logs, and other cleanable items
  • Get suggestions - Actionable recommendations with copy-paste commands
  • Device filtering - Get suggestions for specific partitions/drives
  • Multi-distro support - Detects available package managers and generates appropriate commands
  • Package manager cleanup - Suggestions for apt, dnf, pacman, zypper, apk, flatpak, snap, docker
  • System cleanup - Journal logs, old kernels, crash reports, etc.
  • Temporary files cleanup - Clean old temp files from /tmp, /var/tmp
  • Large file detection - Find files >100MB consuming space

Quick Demo

List Drives

$ storage-analyzer drives

Available Block Devices:

Disk: /dev/sda (238.5G)
  └── /dev/sda1  976M   /boot/efi
  └── /dev/sda2  65.2G  /
  └── /dev/sda3  7.9G   [SWAP]
  └── /dev/sda4  145.3G /home

Get Cleanup Suggestions

$ storage-analyzer suggest --device /dev/sda2

Analyzing storage for cleanup suggestions on: /dev/sda2 (mounted at /)

⠧ Found 3 suggestions
╭───────────────────── 1. systemd journal logs (160.0 MB) ─────────────────────╮
│ Path: /var/log/journal                                                       │
│                                                                              │
│ Command to run:                                                              │
│ sudo journalctl --vacuum-size=100M                                           │
╰──────────────────────────────────────────────────────────────────────────────╯
╭────────────────────── 2. APT package cache (132.7 MB) ───────────────────────╮
│ Path: /var/cache/apt                                                         │
│                                                                              │
│ Command to run:                                                              │
│ sudo apt-get clean                                                           │
╰──────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────── 3. Old kernel images (0 B) ─────────────────────────╮
│ Path: /boot                                                                  │
│                                                                              │
│ Command to run:                                                              │
│ sudo apt-get autoremove --purge                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────── Summary ───────────────────────────────────╮
│ Total potential savings: 292.7 MB                                           ║
╰──────────────────────────────────────────────────────────────────────────────╯

Scan Directory

$ storage-analyzer scan /home --depth 2

Scanning: /home
Depth: 2

⠸ Scanned 1234 files, 567 directories
╭────────────────────────────────── Summary ───────────────────────────────────╮
│ Total Size: 45.3 GB                                                          │
│ Files: 1234                                                                  │
│ Directories: 567                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

Top Directories:
                                                                                
  Path                                                    Size                   ───────────────────────────────────────────────────────────────────── 
  /home/user/Downloads                            15.2 GB                   
  /home/user/.cache                                8.3 GB                    
  /home/user/Videos                                12.1 GB                    
  ...

Show Disk Usage

$ storage-analyzer disk

Disk Usage:

  Metric      Value  
 ─────────────────── 
  Total    238.5 GB 
  Used     127.3 GB 
  Free     111.2 GB 
  Usage     53.4%   

Safety

This tool is read-only by default:

  • All analysis commands only read data
  • Suggestions provide commands to run manually
  • No files are automatically deleted
╔═══════════════════════════════════════════════════════════════════════════════╗
║                           ⚠️  SAFETY NOTE                                     ║
║  All suggestions show commands for you to run MANUALLY.                     ║
║  No files are deleted automatically.                                          ║
╚═══════════════════════════════════════════════════════════════════════════════╝

Installation

Option 1: Download Pre-built Binary (Recommended)

Download the latest release from GitHub:

# Download the binary
curl -L -o storage-analyzer https://github.com/activatethefud/storage_analyzer/releases/latest/download/storage-analyzer

# Make it executable
chmod +x storage-analyzer

# Move to your PATH
sudo mv storage-analyzer /usr/local/bin/

Option 2: Install from PyPI (coming soon)

pip install storage-analyzer

Option 3: Install from Source

pip install -e .

Or run directly:

python -m storage_analyzer <command>

Usage

List all drives/partitions

storage-analyzer drives

Scan a directory

storage-analyzer scan /home
storage-analyzer scan . --depth 3
storage-analyzer scan /home /tmp

Find largest files

storage-analyzer large-files /home
storage-analyzer large-files /home --top 20

Find largest directories

storage-analyzer large-dirs /home
storage-analyzer large-dirs /home --top 5

List cleanable items

storage-analyzer clean                              # All cleanable items
storage-analyzer clean --device /dev/sda2            # Only for root partition
storage-analyzer clean --device /dev/sda4            # Only for /home partition

Get cleanup suggestions

storage-analyzer suggest                           # All suggestions
storage-analyzer suggest --device /dev/sda2        # Only for root partition
storage-analyzer suggest --device /dev/sda4        # Only for /home partition

Show disk usage

storage-analyzer disk

How to Filter by Device

  1. First, list all available devices:

    storage-analyzer drives
  2. Find the device you want (e.g., /dev/sda2 for root, /dev/sda4 for /home)

  3. Use --device option:

    storage-analyzer suggest --device /dev/sda2

Detected Cleanable Items

User Cache Files

  • pip cache (~/.cache/pip)
  • npm cache (~/.cache/npm)
  • yarn cache (~/.cache/yarn)
  • Thumbnail cache (~/.cache/thumbnails)
  • Firefox cache (~/.cache/mozilla/firefox)
  • Chrome cache (~/.cache/google-chrome)
  • Chrome GPU cache (~/.config/google-chrome/Default/GPUCache)
  • Trash (~/.local/share/Trash)

Flatpak & AppImage

  • Flatpak cache (~/.cache/flatpak)
  • Flatpak data (~/.local/share/flatpak)
  • Flatpak apps data (~/.var/app)

Development Tools

  • npm global cache (~/.npm/_cacache)
  • bun cache (~/.cache/bun)
  • pnpm cache (~/.cache/pnpm)
  • cargo registry (~/.cargo/registry)
  • gradle caches (~/.gradle/caches)
  • maven repository (~/.m2/repository)
  • uv cache (~/.cache/uv)

Multimedia & Gaming

  • Steam cache (~/.steam)
  • VirtualBox cache (~/.cache/VirtualBox)
  • Rygel media server (~/.local/share/rygel, ~/.cache/rygel)
  • Lollypop music cache (~/.cache/lollypop)

IDE/Editor Caches

  • VS Code cache (~/.config/Code/Cache, ~/.config/Code/CacheData)

Package Managers (auto-detected)

The tool detects which package managers are installed and provides appropriate cleanup commands:

Manager Clean Command Autoremove Old Kernels
apt apt-get clean apt-get autoremove apt-get autoremove --purge
dnf dnf clean all dnf autoremove dnf remove oldest-kernel
pacman pacman -Scc pacman -Rsn $(pacman -Qtdq) (auto by pacman)
zypper zypper clean zypper rm -u zypper rm -u kernel-default
apk apk clean apk del -r $(apk info -e) apk del linux-lts
flatpak flatpak remove --unused - -
snap snap list --all - -
docker docker image prune -a - -

System Cleanup (requires root/sudo)

  • systemd journal logs (journalctl --vacuum-size)
  • Old kernel images (distro-specific commands)
  • Crash reports (/var/crash)
  • Old rotated log files
  • Old temporary files (/tmp, /var/tmp - files older than 7 days)

Examples

Clean up root partition

# Find root device
storage-analyzer drives

# Get cleanup suggestions for root
storage-analyzer suggest --device /dev/sda2

Clean up home partition

storage-analyzer suggest --device /dev/sda4

Find what's using space

storage-analyzer scan /home --depth 2
storage-analyzer large-files /home --top 20
storage-analyzer large-dirs /home --top 10

Development

Run tests

python -m pytest tests/ -v

Run specific test

python -m pytest tests/test_suggestions.py -v

License

GNU General Public License v3 (GPLv3)


╔═══════════════════════════════════════════════════════════════════════════════╗
║  Thanks for using Storage Analyzer!                                          ║
║  Star us on GitHub: https://github.com/activatethefud/storage_analyzer       ║
╚═══════════════════════════════════════════════════════════════════════════════╝

About

CLI tool for Linux that analyzes disk usage, finds the largest files and directories, detects cleanable items like package manager caches, journal logs, and thumbnails, then provides copy-paste commands to clean them up. Works with apt, dnf, pacman, zypper, flatpak, snap, and docker.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages