upstream-institute-virtual-.../cleanup.sh
Mark Korondi 4ec42ceff3 Fixes for Sydney. Removed re-stacking instructions. Gitreview set up.
Change-Id: Idb90f9a7cf79a0cd16622a00b3c02279b4638801
2017-11-02 19:33:04 +00:00

35 lines
716 B
Bash
Executable File

#!/usr/bin/env bash
# Remove older kernels
OLDS=$(dpkg -l | awk '/linux-image-[0-9]/{ print $2 }' \
| sort -r \
| sed 's/linux-image-\(.*\)-generic/\1/g' \
| tail -n +2)
for old in $OLDS; do
sudo apt autoremove --purge -y ".*$old.*"
done
# Empty user caches
rm -rf ~/.cache
sudo rm -rf /root/.cache
# Remove compiled pyc files
sudo updatedb
for pyc in $(locate -- *.pyc); do
sudo rm -rf "$pyc"
done
sudo updatedb
# Remove unused packages
sudo apt autoremove --purge -y humanity-icon-theme snapd lxc.* lxd.*
# Empty packages cache
sudo apt clean
sudo apt autoclean
# Zero out unused space
dd if=/dev/zero of=~/ZERO bs=1M status=progress
sync
rm -rf ~/ZERO