Cleanup Ubuntu.
A simple cleanup script by David Francos.
#!/bin/bash
Y="\033[1;33m"; R="\033[0;31m"; E="\033[0m"
function cleanapt(){ apt-get clean; }
function emptytrash(){ rm -rf /home/*/.local/share/Trash/*/** &> /dev/null && rm -rf /root/.local/share/Trash/*/** &> /dev/null && rm -rf /home/*/.Trash* && rm -rf /root/.Trash*; }
function removeconffiles(){ dpkg -P `dpkg -l|grep "^rc"|awk '{print $2}'`; }
function removeoldkernels(){ apt-get remove --purge $(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v `uname -r|cut -d. -f1,2`-`uname -r |cut -d\- -f3,4`|grep -v `uname -r|cut -d\- -f1,2`); }
if [ $UID != '0' ]; then
echo -e $R"Error: must be root, cleaning user's trash"$E
rm -rf $HOME/.Trash* $HOME/.local/share/Trash/*/**
exit 1
else
echo -ne $Y"Cleaning apt cache ..."$E && cleanapt 2>/dev/null ; echo -ne $R" Done\n"$E
echo -ne $Y"Removing old config files ..."$E && removeconffiles 2>/dev/null ; echo -ne $R" Done\n"$E
echo -ne $Y"Emptying trashes ..."$E && emptytrash 2>/dev/null ; echo -ne $R" Done\n"$E
echo -ne $Y"Removing old kernels ..."$E && cleanapt 2>/dev/null ; echo -ne $R" Done\n"$E
fi
sysinfo.sh

#/bin/sh
# ORIGINAL INFO (credit where deserved)
# simple script to give a summary of system information
# Author: http://www.pixelbeat.org/
# Changes:
# V0.1, 16 Nov 2005, Initial release
# V0.s, 22 Oct 2007, Tweak to ensure cdrom info shown.
# Comment out partition info as a bit noisy.
# V0.syn1, 19 Jan 2009, Added free space info and colors.