Updating your Ubuntu system is important to keep it safe and running well. However, sometimes you might want to stop the kernel (the core part of the system) from updating. This can be useful if you need to keep your system stable or if you have specific software that works best with a certain kernel version.

In this guide, we will show you how to prevent kernel updates in Ubuntu. Don’t worry if you are new to this; we will explain each step in simple terms so you can easily follow along. By the end of this guide, you will know how to manage your kernel updates effectively.

Steps to Prevent Kernel Updates in Ubuntu

Follow the below step-by-step instructions to set kernel packages on hold to prevent it from automatic update.

Step 1: Open the Terminal

First, open the Terminal. Press Ctrl Alt T on your keyboard to do this. The Terminal is where you will enter commands to stop the kernel updates.

Step 2: Check Your Current Kernel Version

Before stopping updates, find out which kernel version you are using. Type this command in the Terminal:

uname -r

This will display your current kernel version.

How to Prevent Kernel Updates in Ubuntu Kernel Linux System Administration
Find Active Kernel Version on Ubuntu

In the command output, you can see that kernel 5.15.0-105-generic is active on this system.

Step 3: List Installed Kernel Packages

To see the kernel packages installed on your system, use this command:

dpkg --list | grep linux-image

This will list all installed kernel image packages.

How to Prevent Kernel Updates in Ubuntu Kernel Linux System Administration
List Installed Kernel Versions on Ubuntu

In the installed packages find out the latest version of kernel-image packages. As per the above output Linux kernel 5.15.0-113-generic is the latest version.

Step 4: Mark the Kernel Packages to Hold

Next, stop the kernel from updating by marking the kernel packages to hold. Replace package_name with your specific kernel packages. like the active kernel package as well as the latest kernel version installed on your system. You can find both from above step. Now run these commands:

sudo apt-mark hold linux-image-5.15.0-105-generic 
sudo apt-mark hold linux-headers-5.15.0-105-generic
sudo apt-mark hold linux-image-5.15.0-113-generic
sudo apt-mark hold linux-headers-5.15.0-113-generic

You should also set on hold the following packages:

sudo apt-mark hold linux-image-generic linux-headers-generic linux-generic

These commands will prevent the specified kernel image and headers from updating. Make sure to use the correct version numbers from your system.

Step 5: Verify the Hold Status

Check if the hold was successful by typing:

apt-mark showhold

This will list all the packages on hold, including the kernel packages.

How to Prevent Kernel Updates in Ubuntu Kernel Linux System Administration
List Onhold Packages on Ubuntu

Step 6: Unhold the Kernel Packages (If Needed)

If you need to update the kernel in the future, you can unhold the packages with these commands:

sudo apt-mark unhold linux-image-5.15.0-105-generic
sudo apt-mark unhold linux-headers-5.15.0-105-generic
sudo apt-mark unhold linux-image-5.15.0-113-generic
sudo apt-mark unhold linux-headers-5.15.0-113-generic
sudo apt-mark unhold linux-image-generic linux-headers-generic linux-generic

This will allow the specified kernel packages to be updated again. Remember to use the correct version numbers from your system.

Conclusion

By following these steps, you can easily stop kernel updates in Ubuntu. This helps keep your system stable and prevents unwanted changes to your operating system’s core. You can always check the hold status and unhold the packages if you need to update the kernel later.