clean up – remove old kernels on ubuntu

# dpkg –list | grep linux-image

rc: It means package is in remove/deinstall state and only config file exists.
ii: It means package is in install state and it is 100% installed on the system.

to remove all old kernels in rc state:

# x=$(dpkg –list | grep -i linux-image | grep ^rc| awk ‘{ print $2}’)
# echo “$x”
# apt-get –purge remove $x