Remove old kernels from Ubuntu

I'm looking to remove old kernels that have left their module directories behind, but it seems that there is no kernel installed!

uname -r returns 6.2.9-x86_64-linode160, but this is not installed. /lib/modules has 24 directories that also don't seem to relate to any packages installed.

The simple answer is just to delete the unused directories, but this is not very elegant. What is the "correct" way to uninstall old kernels?

1 Reply

It seems you are using a Linode-provided kernel, which is not directly installed onto the system but is provided at boot. This would be why you are unable to find the module despite uname -r returning the correct revision.

To manage the kernel on a Linode, you can navigate to your Compute Instance in Cloud Manager, click on the Configuration tab of your Linode, click Edit, and select the desired kernel under Boot Settings.

If you have added additional kernels and need to manage them manually, you can view them using the following command:

dpkg --list | egrep -i --color 'linux-image|linux-headers|linux-modules' | awk '{ print $2 }'

This command provides a list of installed packages related to Linux images, headers, and modules. To remove a specific kernel version, use the following command, replacing <kernel_package_name> with the actual name of the kernel package you want to remove:

sudo apt purge <kernel_package_name>

Please note that manually managing kernels this way is typically not required on Linode instances using Linode-provided kernels, as these are managed through Cloud Manager. However, if you have installed additional kernels, the provided commands can help you remove any kernels you no longer need.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct