Remove all unused kernels in debian based systems

http://www.unixmen.com/remove-all-unused-kernels-with-1-command-in-debian-based-systems/

sudo apt-get remove $(dpkg -l|egrep '^ii  linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`)

If it doesn’t work, try this:

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

http://www.commandlinefu.com/commands/view/10520/remove-all-unused-kernels-with-apt-get