Ubuntu: for i in `dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+' | grep -Fv $(uname -r) | awk '{print $2}'`; do sudo apt-get remove --purge --yes $i; done;