List all installed kernels on Ubuntu except current one
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'
Lists all installed kernels minus the current one. This is useful to uninstall older kernels that take too much space on /boot partition.
Sample Output
linux-image-5.11.0-38-generic
linux-modules-5.11.0-38-generic
linux-modules-extra-5.11.0-38-generic