The safest way to get a new kernel is the same way you get other software: from your distribution. Its packages are built and tested for your system and receive security fixes.
Check what you have
uname -r6.8.0-45-genericList installed kernel packages:
dpkg --list 'linux-image*' # Debian, Ubuntu
rpm -q kernel # Fedora, RHEL family
pacman -Q linux # ArchUpdate it
On Debian and Ubuntu:
sudo apt update
sudo apt full-upgradePackage names such as linux-image-amd64 (Debian on 64-bit PCs) and linux-image-generic (Ubuntu) are metapackages. They depend on the current kernel package, so keeping one installed brings in new kernels.
On Fedora and RHEL family systems:
sudo dnf upgrade kernelOn Arch, upgrade the whole system with sudo pacman -Syu. Partial upgrades are not supported there.
Reboot to use it
Installing puts new files on disk. The old kernel keeps running until you restart. (Live patching services can apply some fixes without a reboot, but they do not replace this step in general.)
sudo rebootAfterwards, check uname -r again.
Keep a fallback
Debian, Ubuntu and Fedora normally keep older kernels installed. If the new one fails, choose the older entry in the boot loader menu, often under "Advanced options" in GRUB on Debian and Ubuntu. The menu may be hidden by default.
Fedora limits how many are kept with installonly_limit, 3 by default. Arch replaces the linux package in place, so you can also install linux-lts as a fallback.
On Debian and Ubuntu, sudo apt autoremove can remove old kernels that are no longer needed. Read the list before you confirm, and do not remove the running one.
Package hooks normally build the initramfs and update the boot menu for you.
Building from source
You can also build the kernel from kernel.org. The broad steps are configuring (make menuconfig), building (make), then sudo make modules_install and sudo make install. It needs build tools and time, and you must handle updates yourself. Learners should try it only in a virtual machine.
Practise package management in the packages lab.
Try it
- Run
uname -rand list your installed kernel packages. - On Debian or Ubuntu, run
apt list --upgradeableaftersudo apt updateand look forlinux-packages. - Check how much space
/boothas withdf -h /boot. A new kernel needs free space there.
Check your understanding
Installing and updating the kernel
All 5 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.