Table of Contents
- Overview
- Kernel Versioning in Ubuntu
- Checking Kernel Version
- Installing and Updating the Kernel
- Manual Installation from Mainline
- Installing a Specific Kernel Version
- Building a Custom Kernel
- Managing Multiple Kernels and Rollback
- Conclusion
Kernel Versioning in Ubuntu
Ubuntu kernel versions are based on the mainline Linux kernel but include Ubuntu-specific modifications, patches, and configuration changes to ensure compatibility, security, and performance on Ubuntu systems.
A typical Ubuntu kernel version string looks like this:
5.4.0-12.15-generic
- 5.4 β The upstream stable Linux kernel version number.
- 0 β Legacy numbering component retained from older versioning.
- -12 β Represents the Application Binary Interface (ABI) revision.
- .15 β The upload number for this specific kernel release.
- -generic β The kernel flavor, where "generic" is the default flavor commonly used on desktops and servers.
Ubuntu kernels also carry the "Ubuntu" identifier, visible in system files like /proc/version_signature
, to indicate official builds maintained by Canonical.
To check the currently running kernel version, use one of the following commands:
uname -r
# or
cat /proc/version_signature
Checking Kernel Version
To determine the version of the Linux kernel currently running on an Ubuntu system, follow these steps:
-
Open a terminal window.
-
Run the command to display the kernel version:
uname -r
This command outputs the kernel version string, for example:
5.4.0-12-generic
. -
Alternatively, you can check the Ubuntu-specific kernel version signature by running:
cat /proc/version_signature
This command shows detailed information about the kernel release, such as
Ubuntu 5.4.0-12.15-generic 5.4.65
.
These commands help confirm which kernel version is active, which is useful for troubleshooting, compatibility checks, or planning kernel updates.
Installing and Updating the Kernel
Follow these steps to install or update the Linux kernel on an Ubuntu system using official supported methods:
Standard Update via APT
-
Open a terminal window.
-
Refresh the package list to get the latest information about available updates:
sudo apt update
-
Upgrade installed packages, which will include the kernel if a newer version is available:
sudo apt upgrade
-
If a new kernel was installed, reboot the system to load it:
sudo reboot
-
After reboot, verify the kernel version running:
uname -r
Installing a Specific Kernel Version
-
If you need to install a particular kernel version available in the repositories, use the following command format, replacing
<version>
with the exact kernel version string:sudo apt install linux-image-<version>-generic
-
Once installation completes, reboot to start the new kernel:
sudo reboot
Using the Mainline Kernel Installer (For Advanced Users)
-
Add the Mainline PPA to your system:
sudo add-apt-repository ppa:cappelikan/ppa sudo apt update
-
Install the Mainline tool:
sudo apt install mainline
-
Launch Mainline from your applications menu or by running:
mainline
-
Select the desired kernel version and click βInstall.β
-
After installation, reboot the system to boot into the newly installed mainline kernel.
Manual Installation from Mainline
For users seeking to install the latest upstream Linux kernel versions not yet available in the standard Ubuntu repositories, manual installation using the Mainline kernels is an option. Follow these steps:
-
Open a terminal window.
-
Download the desired kernel packages from the official Ubuntu Mainline Kernel PPA server. This typically includes the following packages for your architecture (
amd64
shown here):- linux-headers-
version
-all.deb - linux-headers-
version
-generic-architecture
.deb - linux-image-unsigned-
version
-generic-architecture
.deb - linux-modules-
version
-generic-architecture
.deb
Replace
<version>
and<architecture>
based on the kernel version and system architecture. - linux-headers-
-
Download the packages using
wget
or a web browser. For example:wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.15.10/amd64/linux-headers-5.15.10-051510_5.15.10-051510.202111171831_all.deb wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.15.10/amd64/linux-headers-5.15.10-051510-generic_5.15.10-051510.202111171831_amd64.deb wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.15.10/amd64/linux-image-unsigned-5.15.10-051510-generic_5.15.10-051510.202111171831_amd64.deb wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.15.10/amd64/linux-modules-5.15.10-051510-generic_5.15.10-051510.202111171831_amd64.deb
-
Install all downloaded packages using
dpkg
:sudo dpkg -i linux-headers-*.deb linux-image-unsigned-*.deb linux-modules-*.deb
-
Once installation completes, update the GRUB bootloader:
sudo update-grub
-
Reboot the system to boot with the new kernel:
sudo reboot
-
After reboot, verify the active kernel version:
uname -r
Note that manually installed mainline kernels do not receive automatic updates. Monitor kernel updates and repeat the process to upgrade.
Installing a Specific Kernel Version
To install a specific kernel version available in the Ubuntu repositories, follow these steps:
-
Open a terminal window.
-
Check available kernel versions by searching the package list (optional):
apt search linux-image
-
Install the desired kernel image package by specifying the exact version string. Replace
<version>
with the specific kernel version, for example5.4.0-26
:sudo apt install linux-image-<version>-generic
-
Optionally, install matching header packages to support building kernel modules:
sudo apt install linux-headers-<version>-generic
-
After installation finishes, reboot the system to boot into the newly installed kernel:
sudo reboot
-
Verify the running kernel version after reboot:
uname -r
This method uses official repository packages to install kernels tested and supported by Ubuntu.
Building a Custom Kernel
Building a custom Linux kernel in Ubuntu allows you to tailor the kernel configuration and optimizations specifically for your hardware or use case. Follow these steps:
-
Open a terminal window and install the necessary packages for building the kernel:
sudo apt update sudo apt install build-essential libncurses-dev bison flex libssl-dev libelf-dev
-
Download the Ubuntu kernel source matching your installed kernel version or the version you want to build:
apt source linux-image-$(uname -r)
Alternatively, download mainline kernel source from
https://kernel.ubuntu.com/~kernel-ppa/mainline/
(manual download and extraction). -
Change directory into the kernel source folder (example folder name may vary):
cd linux-*
-
Copy the current kernel configuration as a base:
cp /boot/config-$(uname -r) .config
-
Customize the kernel configuration using a menu-based interface:
make menuconfig
Use arrow keys and options to modify settings as needed, then save and exit.
-
Build the kernel and its modules:
make -j$(nproc) make modules_install
-
Install the newly compiled kernel:
sudo make install
This step installs kernel images and updates the GRUB bootloader automatically.
-
Reboot the system into the new kernel:
sudo reboot
-
After reboot, confirm the active kernel version:
uname -r
Building a custom kernel requires time and understanding of kernel options. Always keep a known working kernel in the GRUB menu to boot if issues arise.
Managing Multiple Kernels and Rollback
Ubuntu allows multiple kernel versions to coexist on the system. This enables you to switch between kernels and rollback if needed. Follow these steps to manage multiple kernels and perform rollback operations:
-
View Installed Kernels: Open a terminal and list all installed kernel images:
dpkg --list | grep linux-image
-
Reboot and Select Kernel: Restart your computer. At the GRUB boot menu, choose Advanced options for Ubuntu.
Under this submenu, select the desired kernel version to boot. This allows you to temporarily use a previous or alternative kernel.
-
Set Default Kernel (Optional): To permanently boot a specific kernel by default, edit GRUB configuration:
sudo nano /etc/default/grub
Modify the
GRUB_DEFAULT
parameter to the menu entry number or name corresponding to your preferred kernel.Save the file, then update GRUB:
sudo update-grub
-
Remove Unwanted Kernels: To free disk space and reduce clutter, uninstall kernels not in use by running:
sudo apt remove linux-headers-<version> linux-image-<version> linux-modules-<version>
Replace
<version>
with the exact kernel version string. -
Verify Current Running Kernel: After rebooting, confirm the active kernel version with:
uname -r
-
Use Tools to Manage Kernels (Optional): For easier management of kernels and boot entries, graphical tools like
grub-customizer
can be installed:sudo apt install grub-customizer
This allows you to reorder, hide, or remove boot menu entries with a GUI.
Managing multiple kernels helps ensure system stability by allowing fallback options. Always keep at least one known good kernel installed before removing old versions.