Safe maintenance for Linux + Docker, inspired by Mole for macOS, a wonderful project.
LinuxMole is a Mole-inspired CLI for Linux servers with Docker. It focuses on safe, transparent maintenance with previews, structured output, and explicit confirmation.
Note: LinuxMole is under active development. Core functionality is complete and tested, with additional features being implemented.
| Aspect | Status |
|---|---|
| Version | 1.3.1 |
| Tests | 142 passing (100%) |
| Coverage | 19.82% |
| Architecture | Modular (28 modules) |
| CI/CD | β GitHub Actions (Python 3.8-3.12) |
| Completion | 10/11 tasks (90.9%) |
- β Interactive menu with all 14 commands (redesigned in v1.2.0)
- β ncdu-style Disk Analyzer TUI (new in v1.3.0) - flat list navigation with Enter/Backspace
- β Complete system and Docker status monitoring
- β Safe cleanup operations (system + Docker)
- β Application uninstaller (apt/snap/flatpak)
- β System optimization (databases, network, services)
- β Whitelist management and config file support
- β Automated testing and CI/CD pipeline
- β Python 3.8-3.12 compatibility
- β Logging and error handling
- β Modular architecture
- TUI launcher integration (low priority)
- Comprehensive documentation (commands, configuration, examples)
- Additional test coverage
- Performance optimizations
Run lm without arguments to access a modernized interactive menu with all 14 commands organized in 5 color-coded categories:
Choose your preferred execution mode at startup:
- π’ Normal Mode - Execute without root permissions (limited features)
- π΄ Root Mode - Execute with full system access (all features)
- π‘ Dry-Run Mode - Preview commands without executing (safe testing)
Menu items use intuitive color coding for quick identification:
- π΅ Blue - Monitoring & Analysis (status checks, disk usage)
- π’ Green - Cleanup & Maintenance (safe operations)
- π‘ Yellow - System Operations (requires caution)
- π Orange - Configuration (settings management)
- π΄ Red - LinuxMole System (updates, self-uninstall)
Benefits:
- β No need to memorize CLI commands
- β Clear visual hierarchy with color coding
- β Mode selection prevents accidental privilege escalation
- β Interactive wizards with smart defaults
- β Return to mode selection with 'm' (Normal Mode only)
- Mole-like console UX with structured sections and previews
- Safe-by-default cleanup with explicit confirmation
- Docker-aware maintenance (images, networks, volumes, logs)
- System maintenance (journald, tmpfiles, apt, caches)
- Whitelist support and detailed preview logs
The lm analyze --tui command now features a complete ncdu-style redesign for better disk usage analysis:
Key Features:
- Flat List Navigation - View and navigate one directory level at a time (like ncdu)
- Intuitive Controls -
Enterto dive into directories,Backspaceto go back - Smart Sorting - Items automatically sorted by size (largest first)
- Visual Bars - Proportional usage bars relative to the largest item in current view
- Better Performance - Loads only current directory (not entire tree)
- Improved Diagnostics - Clear error messages if Textual library is missing
Keybindings:
β/β- Navigate itemsEnter/β- Enter directoryBackspace/β/Esc- Go to parentR- Refresh viewQ- Quit
Usage:
lm analyze --tui # Interactive TUI in current directory
lm analyze /var --tui # Interactive TUI for specific path
Normal Mode |
Root Mode |
Dry-Run Mode |
System Status |
Docker Status |
_ _ __ __ _
| | (_) | \/ | | |
| | _ _ __ _ ___ __ | \ / | ___ | | ___
| | | | '_ \| | | \ \/ / | |\/| |/ _ \| |/ _ \
| |____| | | | | |_| |> < | | | | (_) | | __/
|______|_|_| |_|\__,_/_/\_\ |_| |_|\___/|_|\___|
https://github.com/4ndymcfly/linux-mole
Safe maintenance for Linux + Docker.
COMMANDS
lm Main menu
lm status Full status (system + docker)
lm status system System status only
lm status docker Docker status only
lm clean Full cleanup (system + docker)
lm clean system System cleanup only
lm clean docker Docker cleanup only
lm uninstall Uninstall apps (APT/Snap/Flatpak)
lm optimize Optimize system (DBs, network, services)
lm analyze Analyze disk usage
lm purge Clean project build artifacts
lm installer Find and remove installer files
lm whitelist Manage whitelist (add/remove/test/edit)
lm config Manage configuration
lm self-uninstall Remove LinuxMole from this system
lm --version Show version
lm update Update LinuxMole (pipx)
OPTIONS
--dry-run Preview only (clean, uninstall, optimize)
--yes Assume 'yes' for confirmations (clean, uninstall, optimize)
-v, --verbose Enable verbose logging
--log-file PATH Write logs to file
-h, --help Show help
EXAMPLES
lm status
lm status --paths
lm status docker --top-logs 50
lm clean --containers --networks --images dangling --dry-run
lm clean docker --images unused --yes
lm clean docker --truncate-logs-mb 500 --dry-run
lm clean system --journal --tmpfiles --apt --dry-run
lm clean system --logs --logs-days 14 --dry-run
lm clean system --kernels --kernels-keep 2 --dry-run
lm uninstall firefox --purge --dry-run
lm uninstall --list-orphans
lm optimize --all --dry-run
lm optimize --database --network
lm analyze --path /var --top 15
lm analyze --tui
lm purge
lm installer
lm whitelist --add "/home/*/projects/*"
lm whitelist --edit
lm config --edit
lm --version
lm update
pipx is the recommended way to install LinuxMole. It provides:
- β Isolated environment - No dependency conflicts
- β Clean installation - Doesn't pollute system Python
- β
Easy updates -
pipx upgrade linuxmole - β Automatic PATH - Command available globally
Install pipx:
sudo apt update && sudo apt install -y pipx
pipx ensurepathInstall LinuxMole:
pipx install linuxmoleRun:
lm statusDevelopment version (latest from main):
pipx install "git+https://github.com/4ndymcfly/linux-mole.git"Using pip directly can cause dependency conflicts with system packages:
# NOT recommended - can conflict with system packages
pip install --user linuxmole
# If you must use pip, at least use a virtual environment
python3 -m venv ~/linuxmole-env
source ~/linuxmole-env/bin/activate
pip install linuxmoleWhy pipx is better:
- pip installs in user/system Python β conflicts possible
- pipx creates isolated environments β no conflicts
- pipx manages PATH automatically β easier to use
The install-linuxmole.sh script provides a manual installation option for systems without pipx. However, pipx is still strongly recommended for better dependency management and easier updates.
When to use the script:
- Systems where pipx is not available or cannot be installed
- Offline installations or restricted environments
- Manual control over installation location
Note: The script installs to /opt/linuxmole and requires root access. Updates must be done manually by re-running the script.
lm statusFull status (system + docker)lm status systemSystem status onlylm status dockerDocker status onlylm cleanFull cleanup (system + docker)lm clean systemSystem cleanup onlylm clean dockerDocker cleanup onlylm uninstallUninstall apps (APT/Snap/Flatpak)lm optimizeOptimize system (DBs, network, services)lm analyzeAnalyze disk usagelm purgeClean project build artifactslm installerFind and remove installer fileslm whitelistManage whitelist (add/remove/test/edit)lm configManage configurationlm self-uninstallRemove LinuxMole from this systemlm --versionShow versionlm updateUpdate LinuxMole (pipx)
lm clean --containers --networks --images dangling --dry-run
lm clean system --journal --tmpfiles --apt --dry-run
lm clean system --logs --logs-days 14 --dry-run
lm clean system --pip-cache --npm-cache --cargo-cache --go-cache --dry-run
lm clean system --snap --flatpak --logrotate --dry-run
lm clean system --kernels --kernels-keep 2 --dry-runlm analyze --path /var --top 15
lm analyze --tui
lm purge
lm installer# Uninstall apps with all configs
lm uninstall firefox --purge --dry-run
lm uninstall docker-compose --yes
lm uninstall --list-orphans
lm uninstall --autoremove
# Optimize system
lm optimize --all --dry-run
lm optimize --database --network
lm optimize --services
# Manage configuration
lm config --edit
lm config --reset- Whitelist file:
~/.config/linuxmole/whitelist.txt - Purge paths file:
~/.config/linuxmole/purge_paths - Edit whitelist:
lm whitelist --edit
See CONTRIBUTING.md for guidelines.
See PUBLISHING.md for the PyPI/pipx release workflow.
- Update version in
pyproject.tomlandlm.py - Tag and push:
git tag vX.Y.Z && git push --tags - Users upgrade:
pipx upgrade linuxmole
Thanks to the original Mole project for inspiration: https://github.com/tw93/mole





