38 lines
1.2 KiB
Bash
Raw Normal View History

2025-02-28 20:18:55 +00:00
#!/bin/bash
echo "šŸ” Analyzing disk usage... Please wait."
# 1. Show overall disk usage
echo -e "\nšŸ“Š Disk Usage Overview:"
df -h
# 2. Show the largest directories in /
echo -e "\nšŸ“‚ Top 10 Largest Directories in Root (/):"
du -ahx / 2>/dev/null | sort -rh | head -10
# 3. Show the largest directories in /home
echo -e "\nšŸ  Top 10 Largest Directories in /home:"
du -ahx /home 2>/dev/null | sort -rh | head -10
# 4. Show the largest files over 1GB
echo -e "\nšŸ“„ Top 10 Largest Files Over 1GB:"
find / -type f -size +1G -exec ls -lh {} + 2>/dev/null | sort -k5 -rh | head -10
# 5. Check system logs
echo -e "\nšŸ“ Checking Large Log Files in /var/log:"
sudo du -sh /var/log/* 2>/dev/null | sort -rh | head -10
# 6. Find large installed packages (Debian-based)
if command -v dpkg-query &> /dev/null; then
echo -e "\nšŸ“¦ Top 10 Largest Installed Packages (Debian-based):"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -rh | head -10
fi
# 7. Find large installed packages (RPM-based)
if command -v dnf &> /dev/null; then
echo -e "\nšŸ“¦ Top 10 Largest Installed Packages (Fedora-based):"
dnf list installed | awk '{print $2, $1}' | sort -rh | head -10
fi
echo -e "\nāœ… Disk Usage Analysis Completed!"