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.
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.
- 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,.venvand 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.
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.
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.
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.
![]() |
![]() |
| While scanning | Done |
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.
curl -fsSL https://raw.githubusercontent.com/mydisha/lega/main/install.sh | bashThe 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/binAs a .deb package, from the releases page:
sudo apt install ./lega_*_amd64.debWith Go 1.26 or newer:
go install github.com/mydisha/lega/cmd/lega@latestEvery 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/legalega update # install the latest release
lega update --check # only tell me if there is one
lega remove # uninstall lega, its keep list and its logIf you installed the .deb, update and remove it with apt instead.
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 projectsRun 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.
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)| 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 |
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 ~/DownloadsItems 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.
- 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,~/.gnupgor your keyrings is touched. - Browser and editor caches are locked while the app is running.
analyzemoves things to the Trash. It only deletes for good when a drive has no Trash, and asks first.purgeskips 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.
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.
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.
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.
- Does lega go online? Only when you run
lega updateor 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 -hcounts in GiB. - Can I undo a clean? No.
cleanandpurgedelete for good, which is why they only pick data that apps rebuild by themselves.analyzeuses the Trash, so you can restore from there.
git clone https://github.com/mydisha/lega
cd lega
make test
make buildSee CONTRIBUTING.md to add a cleaning rule or cut a release.




