GICT knowledge base
How to Update the Linux Kernel
Published
Updating the Linux kernel is one of those tasks that every Linux user encounters sooner or later. Whether you’re a desktop user chasing new hardware support, a developer wanting the latest features, or a system administrator focused on security and stability, keeping your kernel current can make a big difference in how your system runs. If you’ve ever wondered how to tackle a kernel update without risking your setup, this guide is for you. Let’s walk through the process, step by step, in a way that’s practical and approachable—no jargon, no guesswork.
Why Bother Updating the Kernel?
It’s easy to ignore kernel updates until something breaks or you hear about a big security vulnerability. But there are several good reasons to keep your kernel updated:
Security
Kernel updates frequently patch vulnerabilities that could otherwise be exploited. If your computer is ever connected to the internet, these patches are crucial.
Hardware Support
If you buy a new laptop or plug in the latest gadget, it might not work right away unless your kernel is reasonably up-to-date. Developers are always adding drivers for new hardware.
Performance
Each kernel release tends to include performance improvements, many of which you’ll notice in real-world use, especially on newer hardware.
Stability and Bug Fixes
From random freezes to quirky device behavior, a lot of issues are solved simply by running a newer kernel.
But updating your kernel isn’t just about chasing the newest version. In production environments, stability is king. Sometimes, you might stick with a tried-and-true kernel unless you need a specific fix or feature.
Know Before You Start: Back Up and Prepare
Before you jump in, a quick word to the wise: always back up your most important files. Kernel updates are usually safe, especially if you use your distribution’s package manager, but there’s always a chance something unexpected could go wrong. A full backup (or at least a backup of your home directory and configuration files) can save you hours of frustration.
It’s also helpful to know your current kernel version. This way, you can verify the update worked and easily switch back if you run into trouble. Just open a terminal and type:
uname -r
You’ll see something like 5.15.0-78-generic or similar. Jot this down for later.
Method 1: Updating the Kernel Using Your Distribution’s Package Manager
For most people, this is the safest and easiest way to update your kernel. If you’re using Ubuntu, Fedora, Debian, CentOS, or any mainstream distribution, your package manager handles kernel upgrades for you.
Step 1: Update Your Package List
Make sure your system knows about the latest available packages.
On Ubuntu/Debian systems, run:
sudo apt update
On Fedora or newer versions of CentOS/RHEL:
sudo dnf check-update
On older CentOS/RHEL systems:
sudo yum check-update
Step 2: Upgrade Installed Packages, Including the Kernel
On Ubuntu and Debian, upgrade everything (including the kernel) with:
sudo apt upgrade
To upgrade everything and remove unused packages:
sudo apt full-upgrade
On Fedora:
sudo dnf upgrade
On CentOS/RHEL:
sudo yum update
Step 3: Reboot Your System
After upgrading, reboot so the new kernel loads:
sudo reboot
On restart, your system will automatically boot into the latest kernel (unless you’ve changed your bootloader configuration).
Step 4: Check Your Kernel Version
Once your machine restarts, verify the update:
uname -r
If everything worked, you’ll see a newer version than before.
Method 2: Installing a Specific Kernel Version
Occasionally you need a specific kernel version, perhaps for a hardware fix or compatibility. Here’s how you can manage this, especially on Debian-based systems.
To see what’s available:
apt search linux-image
Pick the one you want and install it (replace VERSION appropriately):
sudo apt install linux-image-VERSION
If you’re using Fedora, CentOS, or RHEL, you can specify versions similarly with dnf or yum.
Using Ubuntu Mainline Kernels
Ubuntu users have access to mainline kernels that aren’t officially supported but are great for testing or bleeding-edge hardware. Ubuntu Mainline Kernel Installer is a handy GUI tool, or you can download .deb packages straight from kernel.ubuntu.com. Just remember: these kernels are for adventurous users!
Method 3: Compiling the Kernel from Source (For Advanced Users)
Most users never need to compile their own kernel, but sometimes the “official” packages just don’t cut it. Maybe you need a custom patch, want to try an experimental feature, or have hardware that’s only supported in the latest mainline release.
Step 1: Download the Source
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.x.y.tar.xz
tar -xf linux-6.x.y.tar.xz
cd linux-6.x.y
Step 2: Configure the Build
You can start with your current kernel’s config:
cp /boot/config-$(uname -r) .config
make menuconfig
This brings up a menu where you can tweak kernel options. For most people, the defaults work fine.
Step 3: Compile the Kernel
This is where you’ll want a cup of coffee—compiling can take a while:
make -j$(nproc)
Step 4: Install Modules and Kernel
sudo make modules_install
sudo make install
These commands install kernel modules and copy the new kernel to /boot.
Step 5: Update Your Bootloader
On most systems using GRUB:
sudo update-grub
If you’re on Fedora or RHEL:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Step 6: Reboot and Select the New Kernel
sudo reboot
At boot, you should see your new kernel in the GRUB menu. If something goes wrong, you can always choose an older kernel from the “Advanced options” section.
Troubleshooting and Recovery Tips
- System Won’t Boot: On most systems, you can select a previous kernel in the GRUB menu. If your display stays blank, try holding Shift (or Esc on UEFI systems) during boot.
- Hardware Not Working: If something stops working (like Wi-Fi or graphics), try booting an older kernel and see if the problem disappears. Sometimes it’s best to wait for another update or check for third-party drivers.
- Boot Loader Not Showing New Kernel: Run
sudo update-gruborsudo grub2-mkconfig -o /boot/grub2/grub.cfgto refresh the list. - Cleaning Up Old Kernels: On Ubuntu/Debian,
sudo apt --purge autoremovecan free up space. On Fedora/CentOS, trysudo dnf remove --oldinstallonly.
Best Practices for Kernel Updates
- Back up before making changes. Even a simple USB or cloud backup can save you from disaster.
- Read the release notes. Sometimes new kernels drop support for old hardware or change behavior.
- Don’t rush on production systems. Test updates on a spare machine before rolling them out company-wide.
- Keep at least one known-good kernel installed. Never remove all old kernels at once—you want a fallback option.
- Document your steps. If something breaks, you’ll know exactly what was changed and how to fix it.
Frequently Asked Questions
Q: Can updating the kernel break my system?
A: It’s rare, but possible—especially with very new or old hardware. Always keep a backup and make sure you know how to boot from a previous kernel if needed.
Q: How can I check which kernels are installed?
A: On Ubuntu/Debian systems, run dpkg --list | grep linux-image. On Fedora/CentOS, use rpm -q kernel.
Q: Can I uninstall old kernels?
A: Yes, but keep at least one working fallback kernel, just in case.
Q: How often should I update my kernel?
A: For desktops, updating every few months is usually fine. For servers, only update when there’s a real need (security, hardware, bugs), and always test first.
Conclusion
Updating your Linux kernel needn’t be a stressful experience. If you use your distribution’s package manager, it’s often as simple as updating your regular software. For special cases, you can install specific versions or even compile your own—but always with a backup ready and a little caution. By keeping your system’s kernel current, you’ll benefit from better security, improved performance, and expanded hardware support.
Just remember: plan ahead, take your time, and don’t be afraid to ask for help on community forums if you get stuck. Happy upgrading!
Related guides
How to Set Up zram on a Small VPS
Configure zram on Ubuntu with kernel and swap checks. Understand compressed memory limits, monitor real use and avoid unsafe swap-file changes.
LinuxHow to Find Services That Need a Restart After Updates with needrestart
Find services using outdated libraries with needrestart on Ubuntu. Read restart reports, review automatic restart policy and plan maintenance safely.
LinuxHow to Limit a Linux Service’s Memory with systemd
Limit a Linux service with systemd MemoryHigh, MemoryMax and swap controls. Check cgroup support, diagnose pressure and remove only your own policy.
LinuxHow to Protect SSH with CrowdSec on Ubuntu
Protect SSH with CrowdSec on Ubuntu. Connect log detection to firewall enforcement and test temporary blocking without losing administrator access.
