The Linux kernel is the base of Linux. From opening applications to installing or uninstalling them, connecting to the internet, managing ports, and almost everything else, the kernel handles it all. You can consider it as the plinth or foundation of the Linux operating system on which many services, software, and applications work. In this tutorial, we will learn how to update kernel version in Ubuntu.
Keeping an updated kernel in Linux is crucial. It offers many advantages like enhanced stability, performance updates, security patches, compatibility for new software, and some new features too. If you have a server or a home PC running the Linux operating system, we recommend that you keep the kernel version always updated so your system runs smoothly and securely. Linux distributions that are based on the apt package manager, like Debian, Ubuntu, Linux Mint, etc, have a similar process to update the kernel. So if you are on any of these, you can follow this guide to update the kernel version.
In this Tutorial, we will learn
- Prerequisites
- How to Check the Current Linux Kernel Version?
- Update Kernel version using APT package manager
- How to Remove Old Kernels from Linux?
- Conclusion
Important: Before proceeding, make sure to keep backup of all your important files and folders.
Prerequisites
- A PC or Server with Ubuntu installed
- A sudo user
How to Check the Current Linux Kernel Version?
The first thing before updating the Linux kernel version is to check the current version installed on the system. To do so, you need to execute the command given below
# uname -r
You can see the output showing the version, or you can check it with another command
# cat /proc/version
Both commands will show the current version of the kernel installed on your PC or on your server
Update Kernel version using APT package manager
Since we are using the Ubuntu operating system, which supports the apt package manager, we will use the apt command to update the kernel version. This process allows us to update the kernel only from trusted sources, ensuring we get the updates that are secure and stable.
# sudo apt update -y
As the repository updation completes, let’s go ahead and upgrade the kernel
# sudo apt upgrade -y
Using the above two commands, your system’s packages will be refreshed, and the kernel will be upgraded to the latest version
Now, reboot the system to apply the new kernel.
# sudo reboot
As the system reboots, you should run the commands below to check the updated kernel version
# uname -r
or
# cat /proc/version
How to Remove Old Kernels from Linux?
As you will update the new kernels periodically, the older kernels will be saved on your system, consuming storage space. It is a good practice to remove the older kernels, which helps in maintaining the cleanliness of the system and freeing up storage space.
To remove older kernels, you can use the “apt autoremove” command. This command will find out the unused kernels as well as the packages that are not needed with your current setup and remove them from the system, but it won’t remove the older configuration files. So if you want to keep older configuration files, you can just execute the command given below
# sudo apt autoremove -y
If you want to remove older kernels and packages along with the older configuration files, then you can use the “apt autopurge” command. With this command, all the older and unused kernels, as well as the packages along with the configuration files, will be removed from the system, making your system clean.
# sudo apt autopurge -y
Conclusion
The steps to update the kernel version in Ubuntu have been completed. Now your system has the latest version installed, and you have also successfully removed the older kernels and packages along with older configuration files.
Leave a Reply