Skip to content

About

Analyze disk usage and safely reclaim space on Linux servers. 面向 Linux 服务器的磁盘分析与安全清理 CLI。

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

lc — Linux Cleaner

lc icon

Analyze disk usage and safely reclaim space on Linux servers. Built for server workloads such as journald, apt/dnf, Docker, logs, and common stacks (MySQL, PHP, Apache/Nginx, Baota).

Repository: crayonxiaoxin/Linux-Cleaner

中文文档

Features

  • Disk analysis — directory size ranking and large file discovery (with progress + colors)
  • Service insights — MySQL, PHP, Apache, Nginx, Baota path usage via lc services
  • Safe cleanup — journal, package caches, rotated logs, temp files, user caches, Docker, service logs/sessions/old backups
  • Full scan status — every cleaner shows cleanable / clean / skipped
  • Dry-run by default — lc clean previews only; use --execute to delete
  • Self-update — lc update installs the latest GitHub Release (no Go required)
  • Protection — system paths, DB datadir, site roots, and whitelist are never deleted
  • JSON output — --json for scripting and monitoring

Quick Start

# Recommended: install from GitHub Releases (no Go required)
curl -fsSL https://raw.githubusercontent.com/crayonxiaoxin/Linux-Cleaner/main/scripts/install.sh | bash

# Or build from source (requires Go)
make build
sudo make install

Usage

lc                    # Show available commands
lc analyze [path]     # Browse disk usage (default: /)
lc analyze --quick /  # Faster: skip large-file scan
lc services           # Analyze MySQL/PHP/Apache/Nginx/Baota disk usage
lc clean              # Scan reclaimable space (dry-run, shows all cleaners)
lc clean --execute    # Perform cleanup after confirmation
lc report             # Disk summary (includes services)
lc history            # View operation log
lc update             # Install latest release
lc update --check     # Check for updates only
lc version            # Print version
lc --json report      # JSON output for scripts
lc --no-color clean   # Disable ANSI colors

Examples

lc analyze /var
lc services
lc clean
lc clean --execute --only journal,mysql-logs,nginx-logs
lc update
lc report --json | jq '.total_reclaimable'

Safety

  • clean defaults to dry-run. Destructive operations require --execute and typing yes.
  • Never auto-deleted: /, system dirs, /var/lib/mysql, /www/wwwroot, /www/server/panel, package databases.
  • User whitelist: ~/.config/lc/whitelist (one path prefix per line).
  • Disable operation logging: LC_NO_OPLOG=1.
  • Many cleaners require root (sudo lc clean --execute).

Supported Systems

  • Debian / Ubuntu (apt)
  • RHEL / Rocky / Alma / CentOS (dnf/yum)
  • Generic Linux with journald
  • Optional stacks: MySQL/MariaDB, PHP, Apache, Nginx, Baota panel

Build

make build          # local binary in bin/lc
make test           # run tests
make linux-amd64    # cross-compile for amd64
make linux-arm64    # cross-compile for arm64

Requires Go 1.19+ (1.22+ recommended). See docs/release.md.

License

MIT

About

Analyze disk usage and safely reclaim space on Linux servers. 面向 Linux 服务器的磁盘分析与安全清理 CLI。

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages