You would think that ubuntu would have their game together by now, but I ran out of space again on /boot… so I had to dredge up my old post from a couple of years ago. It’s an oldie but still works.
sudo apt-get purge $(dpkg -l linux-{image,headers}-“[0-9]*” | awk ‘/ii/{print $2
}’ | grep -ve “$(uname -r | sed -r ‘s/-[a-z]+//’)”)