Curl your way to success hunting used diskspace hogs in a hurry.
Go to file
Your Name 585f477db1 Initial release: Disk space reporting tool for Ubuntu/Linux systems 2025-06-07 19:30:52 -04:00
README.md Initial release: Disk space reporting tool for Ubuntu/Linux systems 2025-06-07 19:30:52 -04:00
disk-check-macos.sh Initial release: Disk space reporting tool for Ubuntu/Linux systems 2025-06-07 19:30:52 -04:00
disk-check.sh Initial release: Disk space reporting tool for Ubuntu/Linux systems 2025-06-07 19:30:52 -04:00

README.md

Disk Space Report Script

A comprehensive disk space analysis tool for Ubuntu/Linux systems that helps identify storage usage patterns and suggests cleanup opportunities.

Features

  • APT Cache Analysis: Estimates size of package cache that can be cleared
  • Package Management: Identifies old installed packages taking up space
  • Journal Log Analysis: Checks system journal logs for cleanup opportunities
  • Temporary Files Check: Analyzes temporary directories for cleanup
  • Docker Volume Analysis: Identifies unused Docker volumes consuming space
  • Docker Log Management: Finds large Docker log files and suggests rotation
  • Large Directory Discovery: Lists directories consuming significant space
  • Automatic Report Upload: Uploads results to Hastebin for easy sharing

Requirements

  • Ubuntu/Linux system
  • sudo privileges for comprehensive analysis
  • docker (optional, for Docker-related analysis)
  • jq for JSON parsing (for Hastebin upload)
  • curl for report uploading

Installation

# Clone the repository
git clone https://github.com/yourusername/disk-space-report.git
cd disk-space-report

# Make the script executable
chmod +x disk-check.sh

Usage

./disk-check.sh

The script will:

  1. Analyze various system components for space usage
  2. Generate a comprehensive report
  3. Save the report to /tmp/disk_space_report.log
  4. Upload the report to Hastebin and provide a shareable URL

What It Analyzes

System Components

  • APT Cache (/var/cache/apt): Downloaded package files
  • Package Lists (/var/lib/apt/lists): Package index files
  • Journal Logs: System logging data
  • Temporary Files (/tmp, /var/tmp): Temporary system files

Docker Components (if Docker is installed)

  • Unused Volumes: Dangling Docker volumes
  • Large Log Files: Docker container logs over 1GB

Directory Analysis

  • Large Directories: Directories consuming more than 5GB and 10GB
  • Home Directory Analysis: Large directories in user home folders

Sample Output

The script provides estimates like:

Estimating the size of the apt cache:
1.2G    /var/cache/apt

Estimating the size of journal logs:
Archived and active journals take up 2.1G in the file system.

Directories in / consuming more than 5GB:
7.2G    /var/lib/docker
12G     /usr/share

Cleanup Suggestions

Based on the analysis, you can:

  1. Clear APT cache: sudo apt clean
  2. Remove old packages: sudo apt autoremove
  3. Clean journal logs: sudo journalctl --vacuum-time=30d
  4. Clear temporary files: sudo rm -rf /tmp/* (use with caution)
  5. Remove unused Docker volumes: docker volume prune
  6. Truncate Docker logs: Use the provided command in the script output

macOS Version

For macOS users, there's also a disk-check-macos.sh version that provides similar functionality adapted for macOS systems.

Safety Notes

  • This script only analyzes disk usage - it doesn't delete anything
  • Always review suggested cleanup commands before running them
  • Some cleanup operations cannot be undone
  • The script requires sudo for comprehensive system analysis

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

License

This project is licensed under the MIT License.