Skip to content

ersinakyuz/snapman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 SnapMan

The Missing Garbage Collector for Ubuntu Snaps

Go Version License Platform Status

SnapMan is a lightweight CLI tool written in Go to safely clean up old, disabled Snap revisions
and reclaim disk space on your Ubuntu system.

InstallationUsageRoadmap


🚀 Why SnapMan?

Ubuntu keeps older versions of snaps (by default 3 revisions) for safety during updates. However, over time, these disabled revisions can accumulate and occupy gigabytes of disk space.

SnapMan helps you by:

  • 🧹 Parsing snap list --all output efficiently.
  • 🔍 Identifying only disabled revisions.
  • ✅ Integrity Verification: Automatically verifies the physical presence of files on your filesystem before reporting.
  • 📊 Reclaim Analysis: Calculates and displays the total potential disk space gain at the end of the operation.
  • 🛡️ Safe Execution: Targets specific revisions without affecting active packages.
  • 🌍 Locale Safe: Works correctly even if your system language is set to German, Turkish, etc.

🛠️ Installation

You can build SnapMan from source. Ensure you have Go 1.20+ installed.

# 1. Clone the repository
git clone https://github.com/ersinakyuz/snapman.git
cd snapman

# 2. Tidy dependencies
go mod tidy

# 3. Build the binary
go build -o snapman ./cmd/snapman

# 4. (Optional) Install system-wide
sudo mv snapman /usr/local/bin/

💻 Usage

Managing snaps requires root privileges to execute removal commands.

  1. Scan and Clean

Run the tool with sudo: Bash

sudo ./snapman

(If you moved the binary to /usr/local/bin, simply run sudo snapman) Example Output Plaintext

eakyuez@ubuntu:~$ ./snapman --dry-run 

SnapMan starting...

Found 15 disabled revisions. Potential gain: 3.57 GB

PACKAGE                 VERSION                     REV    SIZE        STATUS
-------                 -------                     ---    ----        ------
brave                   1.85.117                    578    186.37 MB   Ready
chromium-ffmpeg         120726-120170-119605-1...   88     7.27 MB     Ready
core18                  20251001                    2959   55.49 MB    Ready
core20                  20250822                    2682   63.77 MB    Ready
core22                  20250923                    2139   73.91 MB    Ready
core24                  20251001                    1225   66.84 MB    Ready
firefox                 145.0.2-1                   7423   250.58 MB   Ready
gnome-46-2404           0+git.4ca00c0-sdk0+git...   125    618.26 MB   Ready
libreoffice             25.8.3.2                    362    1.17 GB     Ready
lxqt-support            2025-10                     7      4.21 MB     Ready
mesa-2404               24.2.8-snap185              912    290.77 MB   Ready
opera                   125.0.5729.21               416    179.11 MB   Ready
telegram-desktop        6.3.8                       6880   82.02 MB    Ready
thunderbird             140.5.0esr-2                915    226.32 MB   Ready
wine-platform-runtime   v1.0                        399    346.89 MB   Ready

Dry run enabled: no removals executed.

Operation Complete.
eakyuez@ubuntu:~$ sudo ./snapman 
[sudo] password for eakyuez: 
SnapMan starting...

Found 5 disabled revisions. Potential gain: 293.25 MB

PACKAGE               VERSION         REV     SIZE       STATUS
-------               -------         ---     ----       ------
canonical-livepatch   10.11.9         364     13.39 MB   Ready
core20                20250822        2682    63.77 MB   Ready
core22                20250923        2139    73.91 MB   Ready
lxd                   5.0.5-5c60378   36558   91.40 MB   Ready
snapd                 2.71            25202   50.77 MB   Ready

Proceed to remove 5 revisions? [y/N]: n
Aborted. No changes made.
eakyuez@ubuntu:~$ sudo ./snapman 
[sudo: authenticate] Password: 
SnapMan starting...

Found 1 disabled revisions. Potential gain: 346.76 MB

PACKAGE                 VERSION   REV   SIZE        STATUS
-------                 -------   ---   ----        ------
wine-platform-runtime   v1.0      400   346.76 MB   Ready

Proceed to remove 1 revisions? [y/N]: y
Removed wine-platform-runtime (revision 400) [346.76 MB]

Summary: removed 1, skipped (missing) 0, reclaimed 346.76 MB.

Operation Complete.

📂 Project Structure

This project follows the Standard Go Project Layout to ensure maintainability.

snapman/
├── cmd/
│   └── snapman/     # Main application entry point
├── internal/
│   └── snapsys/     # Business logic (System calls, parsing)
├── go.mod           # Module definition
└── README.md        # Documentation

🗺️ Roadmap

[x] Basic CLI (List and Remove)

[x] Locale-independent parsing (LC_ALL=C logic)

[x] Dry-Run mode (--dry-run flag for simulation)

[x] Interactive Confirmation (Yes/No prompt)

[ ] TUI (Terminal User Interface) - Planned with Bubbletea

[ ] GUI (Graphical User Interface) - Planned with Fyne or Wails

🤝 Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

Fork the Project

Create your Feature Branch (`git checkout -b feat/AmazingFeature`)

Commit your Changes (`git commit -m 'feat: Add some AmazingFeature'`)

Push to the Branch (`git push origin feat/AmazingFeature`)

Open a Pull Request

📝 License

Distributed under the MIT License. See LICENSE for more information.

About

A lightweight CLI tool written in Go to clean up old, disabled snap revisions and free up disk space on Ubuntu (flavours).

Resources

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

 
 
 

Contributors

Languages