To delete or remove a kernel from a Linux system, you can use the dpkg
command to uninstall the kernel packages.
Here's an example of how to remove the currently running kernel on a Debian-based system:
dpkg --list | grep linux-image
This will show a list of installed kernel packages, with the currently running kernel highlighted in bold.
sudo apt-get remove linux-image-<version> linux-headers-<version>
Replace <version>
with the version of the kernel you want to remove. You will need to uninstall both the linux-image
and linux-headers
packages for the kernel.
sudo update-grub
This will update the boot loader configuration to remove the entry for the uninstalled kernel.
Note: It is generally not recommended to remove the currently running kernel, as this can potentially cause issues with the system. If you want to switch to a different kernel, it is usually safer to install the new kernel and then reboot the system to use it.