Learn the steps to install the latest Linux kernel version on Ubuntu 20.04 LTS Focal Fossa or Ubuntu 22.04 Jammy Jelly Fish to change the default using the command terminal.
The kernel is the core program of any Linux-based operating system that offers mediation between the software and hardware of the computer system. That applies to any hardware device running with some software. And when we wrap it with a layer of graphical user interface and other applications around the kernel, we have a full-fledged Linux operating system such as Ubuntu. Well, Kernel keeps work in the background and ensures that the operating system works and that hardware and software can be put into operation.
Well, “Linux kernel” is not the right term to use. There is only one Linux, and that is the so-called kernel. All popular operating systems based on this GNU kernel are referred to as “Linux operating systems.”
In short, a Linux distro is a kernel + GUI (X server) + software + additional tools = a Desktop Linux operating system. Server Linux skips the GUI part to become a pure command-line server.
Hence, whenever we install a Linux distro such as Ubuntu, a kernel will install automatically because the entire system would not be able to run without it. Also, we can update and download Kernels on Ubuntu just like any other package, here we will see how.
Steps to change default Kernel in Ubuntu 22.04 | 20.04 LTS
1. Check your current Kernel version
Before changing the default kernel of Ubuntu Linux, let’s first check what version is running on our system. For that, open your command terminal. If you are using the GUI desktop version, you can open it using the keyboard shortcut Ctrl+Alt+T.
uname -r
2. Run system update & have wget
Let’s ensure everything on our system is up to date, and then we will move to the next step. Hence, first, run the apt update & upgrade command, plus also install wget
tool as well.
sudo apt update && sudo apt upgrade
sudo apt install wget
3. Download the Bash script to change the kernel
Although the user can directly download the Kernel Deb binary package from Ubuntu’s Linux repository to easily install, update, and uninstall Kernels on Ubuntu 22.04 | 20.04 LTS, we can use the script available on GitHub. Use the command given to download the script to your Ubuntu system.
wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
Once the script is on your system, make it executable and move it to /usr/local/bin
to easily use it in the future to get the latest version of the kernel.
chmod +x ubuntu-mainline-kernel.sh
sudo mv ubuntu-mainline-kernel.sh /usr/local/bin/
4. Check available Kernel versions to install
Now that the script is in place, we can use it to check what versions are available to install in addition to the ones already on our system.
To find the latest version available to install:
ubuntu-mainline-kernel.sh -c
Whereas to list all the available Kernel versions that you can install are:
ubuntu-mainline-kernel.sh -r
5. Change or upgrade the default Ubuntu 22.04 | 20.04 Kernel version
We can update the default version or change it to any other available one we want, but first, we need to install it. Here is the command:
To install the latest available:
sudo ubuntu-mainline-kernel.sh -i
6. To install any specific or old version:
sudo ubuntu-mainline-kernel.sh -i version-number
Note: Replace the “version-number“ in the above command with the one you want to install; for example, to get the version v5.15.11 instead of the latest one, then the command will be:
sudo ubuntu-mainline-kernel.sh -i v5.15.1
Once the installation is completed, we can use the same script to list what are the available versions of Kernel on our system:
sudo ubuntu-mainline-kernel.sh -l
Reboot your system
Restart your system to let your system use the latest installed kernel version.
sudo reboot
After the system reboot, check your current version by using:
uname -r
This time, you will see the latest one.
7. Change or Set Default Kernel Version
By default, Ubuntu will automatically pick the latest installed version of the Kernel, but if you want to set another version to start with the boot, you can choose that. In that case, we manually tell the system to choose which version.
Next, edit the Grub file.
sudo nano /etc/default/grub
Add the following two lines. To get an idea, you can see the screenshot.
GRUB_SAVEDEFAULT=true GRUB_DEFAULT=saved
Save the file Ctrl+O, hit the Enter Key, and then exit it Ctrl+X.
Update Grub:
sudo update-grub
Now reboot your system:
sudo reboot
As you start your system, press the Esc button to access the Grub menu. Select “Advanced options for Ubuntu” and then select the Kernel version you want to set as the default one.
8. Uninstall or Remove
To remove any existing kernel from your system, run:
sudo ubuntu-mainline-kernel.sh -u
Select the serial number of the version you want to remove from your system entirely.
Conclusion
• How To Install Linux Kernel 5.x on Almalinux 8 or Rocky
• Install Bpytop on Ubuntu 22.04/20.04
• Whatsdesk- Install WhatsApp Client on Ubuntu 22.04 | 20.04
• 3 Ways to install and use HandBrake Video convertor on Ubuntu 20.04 / 22.04
Top tutorial! Solve my problem with “Bus 001 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)”!
Thanks!!!
Does this work with secure boot? If not can you list any additional steps
Hi,
I’m try to install 5.7 kernel linux with the steps above.
I almost managed to finish all the steps, but after I choose the relevant version, I get the following error: “end kernel panic – not syncing”.
Would love some help with this! What should I do?
this method not working with ec2 ubuntu 22.04,please provide another solution for ec2 ubuntu
I understood everything except for the final command. “Enter number between-” Between what? When I try to type anything it exists.
Couldn’t understand which command you are talking about because there is nothing like you mentioned in the article.