Occasionally you will need to free up some disk space on the /boot partition after updating your kernel several times. Here are a few commands to list all installed kernels on your Ubuntu system, except the running one.
kernelver=$(uname -r | sed -r 's/-[a-z]+//') dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver
List all installed kernels:
dpkg -l linux-image-\* | grep ^ii
Then, you can remove the un needed kernels with this command:
sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")