Hacker News today features an Ubuntu story with sysadmins asking how to purge old kernels and headers by using apt. This is necessary maintenance on some systems because /boot fills up.
Here's how we do it:
apt-get remove --purge 'linux-image-[0-9].*' linux-image-$(uname -r)+
apt-get remove --purge 'linux-headers-[0-9].*' linux-headers-$(uname -r)+
Complete script with comments here; we welcome feedback and also pull requests.https://github.com/SixArm/sixarm_apt_scripts/blob/master/apt-purge-old-kernels-and-headers