-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbin bash System Cleanup.sh
More file actions
53 lines (42 loc) · 1.26 KB
/
bin bash System Cleanup.sh
File metadata and controls
53 lines (42 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# System Cleanup Script
# Removes temporary files and clears various caches
echo "Starting system cleanup..."
# Calculate initial disk usage
BEFORE=$(df -h / | awk 'NR==2{print $3}')
# Clear apt cache (for Debian/Ubuntu systems)
if command -v apt-get &> /dev/null; then
echo "Cleaning apt cache..."
sudo apt-get clean
sudo apt-get autoclean
fi
# Clear thumbnail cache
echo "Cleaning thumbnail cache..."
rm -rf ~/.cache/thumbnails/*
# Clear old logs (keeps last 3 days)
echo "Cleaning old system logs..."
sudo journalctl --vacuum-time=3d
# Remove old package versions (for Debian/Ubuntu)
if command -v apt-get &> /dev/null; then
echo "Removing old package versions..."
sudo apt-get autoremove -y
fi
# Clean trash
echo "Emptying trash..."
rm -rf ~/.local/share/Trash/*
# Clear browser cache (Firefox)
if [ -d ~/.mozilla/firefox ]; then
echo "Cleaning Firefox cache..."
rm -rf ~/.mozilla/firefox/*/cache2/*
fi
# Clear browser cache (Chrome/Chromium)
if [ -d ~/.cache/google-chrome ]; then
echo "Cleaning Chrome cache..."
rm -rf ~/.cache/google-chrome/*/Cache/*
fi
# Calculate final disk usage
AFTER=$(df -h / | awk 'NR==2{print $3}')
echo ""
echo "Cleanup complete!"
echo "Disk usage before: $BEFORE"
echo "Disk usage after: $AFTER"