Upgrading Linux Kernel in Ubuntu
Learn how to upgrade the kernel version in Ubuntu command line. Also learn about easily installing mainline Linux kernel.
Want to upgrade your kernel on Ubuntu? Well, in this guide, I will be sharing two ways to do so:
- Upgrade to a newer kernel provided by Ubuntu's repository
- Installing the latest mainline kernel (unofficial)
Let me share a quick command to install the most recent kernel made available by Canonical (parent company of Ubuntu):
sudo apt update && sudo apt upgrade
Suprised?
Upgrade the Ubuntu kernel from the default repository
Yes. You just need to update your system. If there is a newer kernel version available in the updates, it will be installed.
First, check the current kernel version using the following command:
uname -r
Next, update the repositories to find the pending updates:
sudo apt update
And if you see pending updates, you can execute the following command to update your system:
sudo apt upgrade
Once done, reboot your system and check the kernel version.
If the update had a kernel update, it should get you a new kernel:
uname -r
And as you can see, it upgraded the kernel from 5.19 to 6.0.
New Book: Efficient Linux at the Command Line
Pretty amazing Linux book with lots of practical tips. It fills in the gap, even for experienced Linux users. Must have in your collection.
Install mainline kernel in Ubuntu via unofficial PPA
If you don't know, the mainline kernel is maintained by Linus Torvalds and introduces all new features implemented.
So you get to use the spicy stuff before anyone else.
To install the mainline kernel, you'd need a package named mainline
.
Which can only be installed by using PPA on Ubuntu. So first, add the PPA by the following command:
sudo add-apt-repository ppa:cappelikan/ppa
Next, use the following command to update repositories and install the mainline package:
sudo apt update && sudo apt install mainline
Now, check available latest kernel update and latest point release for your system:
mainline --check
To install the latest mainline kernel, you will have to use the following command:
sudo mainline --install-latest
Whereas if you are looking for the latest point release for your kernel, use the following:
sudo mainline --install-point
Once you are done with the download, a reboot is required to take effect from the new kernel.
Now, check the kernel version and it will show the most recent mainline kernel:
uname -r
But you can do the entire process with GUI.
So if you have access to GUI, you can the given guide that explains the complete usage of the mainline
package with GUI:
Roll back to the previous kernel in Ubuntu
If you are facing stability issues with the latest kernel, you can always roll back to the previous kernel.
To roll back to the old kernel, restart your system and select the Advanced options for Ubuntu
option.
And then, select the previous kernel and hit enter:
Yep, it's that simple.
Know how many kernels you have
Ubuntu and other Linux distributions keep the old kernel in case you face any issues running the latest one.
And we have detailed guide on how you can list installed kernels in your system:
I hope you will find this helpful and if you have any queries, let me know in the comments.
A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.