Remove old Ubuntu kernels

If you update your Ubuntu kernel frequently, eventually you will come to the realization that it is taking a lot of space to keep the old versions around on disk. Another annoyance is that your Grub loader will show a very long list. Sure, you can keep them around forever, should you need to recover them, but for most people it’s safe to remove them. You can manually select and remove the packages in Synaptic, but the easiest way I’ve found is to sun the following script instead. It will remove all old kernel version (except the current one!):

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

Occasionally, you might also want to follow that with the following to clean up other artifacts too…
sudo apt-get autoremove


Windows file cleanup/housekeeping

Since I routinely run WAMP servers (see previous article) and develop primarily on Windows machines, I find that a lot of garbage remains on these machines. Often these files are created temporarily and not deleted and/or are created for some perceiver performance gains. Additionally, its often nice to schedule cleanup operations for times when you are not using the machine…. here’s a few common items to consider.

@echo off echo ======= DELETES =========
del /q %windir%*.log
del /q %windir%*.tmp
del /q %windir%securitylogs*.*
del /q %windir%SoftwareDistributionDataStoreLogs*.*
del /q %windir%msdownld.tmp*.*
del /q %windir%$hf_mig$*.*
del /q %TEMP%msdownld.tmp*.*
del /q %TEMP%*.dat
del /q %TEMP%*.log
del /q %TEMP%*.tmp
del /q %TEMP%*.xpi
del /q %TEMP%sess_*.*
del /q %TEMP%logs*.*
del /q c:*.log
del /q c:logs*.*
del /q /s %USERPROFILE%*.dmp
del /q /s %USERPROFILE%SIDisttemp*.*"
echo ======= Prefetch ==========
del /q %windir%Prefetch*.*
echo ======== DEFRAG ===========
%windir%system32defrag.exe c: -f -v >%TEMP%batch_defrag.txt
echo ========= done ============


echo ======== ANALOG ===========
cd c:analog6.0 analog +glocalhost.cfg
echo ========== IP =============
%windir%system32ipconfig.exe /all > %TEMP%batch_ip.txt
echo ======== NETSTAT ==========
%windir%system32netstat.exe -a > %TEMP%batch_netstat.txt

NOTE: this entry will be updated occasionally!