How to remove all old kernels in ubuntu


To remove all old kernels in Ubuntu be sure to be running in the latest kernel installed. For that just do a ls /boot check which one is the newer kernel and then compare with the one running using uname -a.

The script to remove:

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



Comments are Disabled