Skip to content
mydishaPublic

About

Disk cleaner and disk usage analyzer for Ubuntu, Linux Mint, Zorin OS and Pop!_OS. A safe, interactive terminal UI written in Go: clear caches, logs, old packages and node_modules, and see what fills your disk.

Topics

Resources

Contributing

Stars

9 stars

Watchers

0 watching

Forks

Repository files navigation

lega

Free up disk space on Ubuntu, Linux Mint, Zorin OS and Pop!_OS from a friendly terminal UI.

Clean caches and junk safely, see what fills your disk, and clear out old build folders.

CI Latest release Go version Built with Bubble Tea Platform License: MIT

The lega start screen: the LEGA wordmark beside host, OS, kernel, CPU and memory, the free space on the home disk, and a menu with Status, Clean, Analyze and Purge.

Lega is Indonesian for the feeling of relief, and for a room with space to breathe. That is what your disk gets. The project is inspired by Mole, which does the same job on macOS.

What it does

  • Clean removes caches, logs, old packages and other junk that is safe to delete: browsers, developer tools, chat apps, the Trash, APT, the journal and old snaps. You see every item and its size before anything goes.
  • Analyze lets you walk your folders sorted by size, like ncdu. Jump to the largest files, open a folder in Files, or send something to the Trash.
  • Status shows how full each disk is and which folders fill your home.
  • Purge finds node_modules, target, .venv and other build folders in your projects that you can rebuild any time.
  • Stays safe. Personal files, settings, logins and history are never touched. Riskier items start unselected. Every removal is logged.

A look around

The screenshots below use a dark terminal theme with a Nerd Font, so the icons are Nerd Font glyphs (see Icons). lega follows your own terminal colors.

Clean

Every item shows its size before its name, grouped by where it comes from. Items you should look at first start unselected and say why: review for data you may want to keep, locked while the app is running, sudo for system items. The line under the list tells you what the item under the cursor does, and the total updates as you select.

The Clean screen: items grouped under System, Browsers, Developer tools, Apps and System (needs sudo), each with a checkbox, a size and a name. Docker build cache (18.8 GB) is under the cursor and marked review. The footer reads: Selected 9.8 GB in 11 items.

Status

Status shows how full each disk is, then scans your home folder with a live count of files and bytes, and ranks the folders that fill it.

Status while scanning: disk bars for / at 71% and /boot/efi at 19%, and Scanning… 3,074,131 files, 172.8 GB under Home. Status when done: the same disk bars, then the home folder at 191.5 GB in 3,825,211 files, with the ten largest folders as bars, led by www at 61.9 GB.
While scanning Done

Analyze

Analyze walks any folder sorted by size, with each entry's share of its parent. Open a folder with →, list the largest files with f, or send something to the Trash with d. Folders lega cannot read are counted in the header instead of failing the scan.

The Analyze screen in ~/go: 4.6 GB in 142,802 files, sorted by size, 25 folders not readable. pkg/ takes 4.5 GB (98%) and bin/ 93.5 MB (2%).

Install

curl -fsSL https://raw.githubusercontent.com/mydisha/lega/main/install.sh | bash

The script picks the build for your CPU (amd64 or arm64), checks it against the release checksums and puts lega in ~/.local/bin. No sudo needed.

Other ways to install

Install a given version, or into another folder:

curl -fsSL https://raw.githubusercontent.com/mydisha/lega/main/install.sh | bash -s -- v0.1.0
curl -fsSL https://raw.githubusercontent.com/mydisha/lega/main/install.sh | sudo bash -s -- --prefix /usr/local/bin

As a .deb package, from the releases page:

sudo apt install ./lega_*_amd64.deb

With Go 1.26 or newer:

go install github.com/mydisha/lega/cmd/lega@latest

Every release file is listed in SHA256SUMS and carries a build provenance attestation. To check where a download came from:

gh attestation verify lega_linux_amd64.tar.gz -R mydisha/lega

Update and uninstall

lega update           # install the latest release
lega update --check   # only tell me if there is one
lega remove           # uninstall lega, its keep list and its log

If you installed the .deb, update and remove it with apt instead.

Use

lega              # menu
lega clean        # pick junk to remove
lega analyze      # explore your home folder by size
lega analyze /var # ... or any other folder
lega status       # disks and what fills your home folder
lega purge        # remove build folders from your projects

Run lega as your normal user. When you pick system items such as the APT cache or the journal, it asks for your sudo password once, right before it cleans them.

Purge
Purge project build folders
In ~/Projects

▸ [x]    1.7 GB  ~/Projects/api/target
  [x]  985.7 MB  ~/Projects/web-app/node_modules

Folders used in the last 7 days start unselected.
Selected: 2.7 GB in 2 folders

space select • a all/none • enter continue • q back

The menu opens with a short summary of your machine: host name, OS, kernel, CPU and memory.

Icons

lega shows icons next to folders, file types and apps (Firefox, Chrome, VS Code, npm, Docker and others). When a Nerd Font is installed, or the terminal ships its symbols (Ghostty, WezTerm), they are Nerd Font glyphs; otherwise they are emoji. The Linux console gets none.

lega --no-icons                       # hide them once
export LEGA_ICONS=off                 # hide them always, e.g. in ~/.bashrc
export LEGA_ICONS=emoji               # or always use emoji (or nerd)

Keys

Key Action
↑ ↓ / j k move
space select or unselect
a select all or none
→ / l open a folder, or show the files of a clean item
← / h go up, or fold
enter continue
f (analyze) largest files in this folder
s (analyze) sort by size, name or file count
d (analyze) move to the Trash
o (analyze) show in the file manager
q / esc back

Scripts and pipes

Every command also works without the interface:

lega clean --dry-run          # list what would be removed
lega clean --yes              # remove the preselected user items
lega clean --yes --system     # ... and the preselected system items (asks for sudo)
lega purge --dry-run ~/code   # list build folders under ~/code
lega purge --yes              # remove build folders not used in the last 7 days
lega status --json
lega analyze --json ~/Downloads

What clean removes

Items marked "review" are listed but start unselected. Look at them before you select them.

Group Item Default
System Thumbnail cache, old desktop session logs selected
Browsers Cache of Firefox (deb, snap, Flatpak), Chrome, Chromium, Brave, Edge, Vivaldi, Opera. Logins, history and bookmarks are kept selected
Developer tools npm, Yarn, pnpm (pnpm store prune), pip, Go build cache, Composer, Bun, Deno, VS Code / VSCodium / Cursor caches selected
Developer tools Go module cache, Cargo registry, Gradle, Maven, JetBrains caches, Docker build cache (docker builder prune) review
Apps Slack, Discord and Teams caches selected
Apps Snap and Flatpak app caches, everything else in ~/.cache review
Files Trash (also on mounted drives), installers in Downloads older than 30 days review
System, needs sudo APT package cache (apt-get clean), journal older than 14 days, rotated logs in /var/log, crash reports and core dumps, old snap versions selected
System, needs sudo Unused packages and old kernels (apt-get autoremove --purge), unused Flatpak runtimes review

lega purge looks in ~/Projects, ~/code, ~/dev, ~/src, ~/www, ~/workspace and similar folders for node_modules, target, .venv, venv, __pycache__, .next, .nuxt, .svelte-kit, .turbo, .gradle, .dart_tool, Python tool caches, and build or dist next to a project file.

Safety

  • Every path is checked right before it is deleted: it must sit inside the folder its rule cleans, symlinks are never followed out of that folder, and mount points and files owned by other users are skipped.
  • Your home folder, ~/.config, ~/.local, your personal folders (Documents, Pictures, ...) and system folders are never deleted. Nothing inside ~/.ssh, ~/.gnupg or your keyrings is touched.
  • Browser and editor caches are locked while the app is running.
  • analyze moves things to the Trash. It only deletes for good when a drive has no Trash, and asks first.
  • purge skips build folders that git tracks and leaves folders used in the last 7 days unselected.
  • System items run through sudo lega _root-clean <item>. Only item names cross over to root; the root side finds the files again by itself, with the same checks.

Keep list

List paths or glob patterns that lega must never remove, one per line, in ~/.config/lega/whitelist:

# keep JetBrains indexes
~/.cache/JetBrains
/var/log/*.gz

If this file exists but cannot be read, clean and purge stop instead of running without it.

Log

Every removal is written to ~/.local/state/lega/operations.log (time, action, item, bytes, result, path). Set LEGA_NO_OPLOG=1 to turn it off.

Supported systems

Ubuntu and the distros built on it: Linux Mint, Zorin OS, Pop!_OS, elementary OS and KDE neon, plus Debian. Release builds are for amd64 and arm64.

On other distros lega still runs. It shows a warning and hides the system items whose tools are missing.

Good to know

  • Does lega go online? Only when you run lega update or the install script. Nothing else connects anywhere.
  • Why do sizes differ from du -h? lega counts like Files and Disks do: 1 GB is 1,000,000,000 bytes. du -h counts in GiB.
  • Can I undo a clean? No. clean and purge delete for good, which is why they only pick data that apps rebuild by themselves. analyze uses the Trash, so you can restore from there.

Build from source

git clone https://github.com/mydisha/lega
cd lega
make test
make build

See CONTRIBUTING.md to add a cleaning rule or cut a release.

License

MIT

About

Disk cleaner and disk usage analyzer for Ubuntu, Linux Mint, Zorin OS and Pop!_OS. A safe, interactive terminal UI written in Go: clear caches, logs, old packages and node_modules, and see what fills your disk.

Topics

Resources

Contributing

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages