Linux servers power everything from hosting websites and running business applications to managing cloud platforms and databases. Their reliability makes them a popular choice, but keeping a Linux server secure requires regular maintenance.

The Kernel is the central component of Linux. It controls how the operating system communicates with hardware, manages memory, schedules processes and enforces access permissions. Because it operates with high system privileges, a vulnerability in this component can have serious consequences.

An attacker who successfully exploits a kernel flaw may be able to obtain elevated permissions, interfere with running services or access information that should remain protected. For administrators responsible for production infrastructure, delaying relevant security updates can therefore expose more than just the operating system.

Applying a kernel update is not always as simple as installing an ordinary application update. A newly installed kernel generally becomes active only after the server boots into it. This creates an operational challenge: administrators need to address security issues while keeping service interruptions to a minimum.

There are three approaches worth understanding:

  1. Updating the kernel through the Linux distribution’s package manager.
  2. Using Kexec to load a replacement kernel and potentially shorten restart time.
  3. Applying eligible security fixes through a live-patching service.

Each method has a different purpose. The right choice depends on the distribution, workload, maintenance requirements and level of uptime the server must provide.

Method 1: Update the Kernel Through the Package Manager

For most Linux servers, the distribution’s package manager is the preferred way to install kernel updates. It obtains packages from configured repositories, resolves dependencies and keeps installed software aligned with the distribution’s packaging system.

The exact commands depend on the operating system.

Identify the operating system and active kernel

Before making changes, establish which kernel is currently running:

uname -r

For example, the command may return:

6.8.0-52-generic

This is the kernel loaded into memory, not necessarily the newest version installed on the server.

Next, check the operating system details:

cat /etc/os-release

Use this information to select the correct update procedure. Also check whether the machine uses a standard distribution kernel, a cloud-specific kernel or a custom build. The correct package can differ between installations.

Updating Ubuntu and Debian servers

Ubuntu and Debian use APT for package management. First, refresh the local package information:

sudo apt update

Then install available package upgrades:

sudo apt full-upgrade

This may include a kernel update if one is available through the configured repositories.

On Ubuntu systems using the standard generic kernel metapackage, the following command can be used to upgrade it:

sudo apt install --only-upgrade linux-generic

For a Debian AMD64 installation using the standard kernel metapackage, use:

sudo apt install --only-upgrade linux-image-amd64

These package names are not universal. Cloud images, alternative architectures and custom kernel configurations may use different packages. Check the system’s existing configuration before selecting a replacement.

Updating RHEL-based systems

RHEL, Rocky Linux, AlmaLinux and Fedora use RPM packages. On systems that use DNF, the kernel package can be updated with:

sudo dnf upgrade kernel

Older installations that still use YUM can use:

sudo yum update kernel

The package manager retrieves the available package and handles its dependencies. Administrators should still review the distribution’s security announcements to understand which vulnerabilities the update addresses.

Reboot and check the result

After installing a new kernel, schedule a restart so the server can load it:

sudo reboot

On a production machine, do not run this command without considering the impact. Notify affected users, check backup availability and make sure console or recovery access is available in case the server does not start as expected.

Once the server is back online, run:

uname -r

Compare the result with the version you intended to activate.

To review installed kernel packages, use the appropriate command:

Ubuntu or Debian:

dpkg -l | grep linux-image

RHEL-based systems:

rpm -qa | grep kernel

These commands show installed packages; uname -r confirms which kernel is currently running. Where this method fits: Package-manager updates are suitable for most Linux environments. They provide a standard, distribution-supported way to install complete kernel updates. The main operational consideration is the restart required to activate the new kernel.

Method 2: Use Kexec to Shorten the Kernel Restart Process

A conventional server restart can involve firmware initialization, bootloader execution, and loading the operating system kernel. Depending on the hardware and configuration, these stages can add time before services become available again.

Kexec offers another way to start a Linux kernel. Rather than following the entire normal boot sequence, it loads a prepared kernel into memory and transfers control to it from the currently running kernel.

This can shorten the transition on compatible systems. However, Kexec is not a patching utility. Administrators must install the updated kernel first; Kexec only provides an alternative way to start it.

Install the Kexec package

On Ubuntu or Debian, install the tools with:

sudo apt install kexec-tools

On a DNF-based system, use:

sudo dnf install kexec-tools

Confirm that the command is available:

kexec --version

Install the kernel update

Use the normal package manager to obtain the kernel you intend to run.

For Ubuntu or Debian:

sudo apt update
sudo apt upgrade

For RHEL-based systems:

sudo dnf upgrade kernel

After installation, locate the kernel image and its matching initial RAM filesystem. On Ubuntu and Debian, list the kernel images with:

ls -lh /boot/vmlinuz-*

Check the initramfs files with:

ls -lh /boot/initrd.img-*

Some RPM-based distributions use filenames such as initramfs-*.img. Do not assume that the Ubuntu naming convention applies to every distribution. The kernel image and initramfs must belong to the same intended kernel version.

Load the replacement kernel

For systems using the standard Ubuntu or Debian file naming convention, the command generally follows this pattern:

sudo kexec -l /boot/vmlinuz-NEW_VERSION \
--initrd=/boot/initrd.img-NEW_VERSION \
--reuse-cmdline

Replace NEW_VERSION with the version actually installed on the server.

The –reuse-cmdline option carries over the current kernel’s boot parameters. Before loading the image, check the file paths and confirm that the system’s hardware and boot configuration support the procedure.

Start the new kernel

On systems where the operation is supported, the restart can be initiated with:

sudo systemctl kexec

The available procedure depends on the distribution and system configuration. Follow the relevant operating system documentation if this systemd operation is unavailable.

Kexec needs particular care on production servers. A direct execution method such as kexec -e can bypass parts of the normal shutdown process. Services may not get their usual opportunity to stop cleanly, which can put application data, databases and filesystems at risk.

Test the procedure outside production before relying on it. After the server starts, check the active kernel:

uname -r

If the expected version is not running, investigate the boot process and system logs before attempting another restart.

Where this method fits: Kexec may be useful when reducing kernel transition time is important. It does not remove downtime, install security fixes or replace normal update management. Its suitability should be established through testing on the actual server hardware and operating system.

Method 3: Apply Eligible Fixes With Live Kernel Patching

Some organizations cannot easily schedule frequent restarts. Hosting platforms, payment services and business-critical applications may need to remain available for long periods.

Live kernel patching addresses part of this problem. It allows supported fixes to be applied to a running kernel without requiring an immediate reboot. The technique changes affected kernel functionality while the system continues operating.

It is not a universal replacement for kernel upgrades. Only fixes supported by the relevant live-patching technology can be applied this way. Compatibility also depends on the distribution, kernel release and service being used.

Examples of available technologies include Canonical Livepatch, Red Hat kpatch, SUSE Live Patching, Oracle Ksplice and KernelCare. Their supported systems and licensing arrangements differ.

Canonical Livepatch on Ubuntu

Canonical provides Livepatch for eligible Ubuntu systems through Ubuntu Pro. First, check the machine’s Ubuntu Pro status:

sudo pro status

If the system is not attached to a subscription, obtain the appropriate token from the Ubuntu Pro account. Attach the machine with:

sudo pro attach YOUR_TOKEN

Replace

YOUR_TOKEN
with the actual subscription token. Treat it as a credential and do not publish it in tickets, screenshots or shared command output.

Enable the service:

sudo pro enable livepatch

Then inspect its status:

sudo canonical-livepatch status

The output provides information about the Livepatch client and patches applied to the running kernel.

A successful service installation does not mean every kernel vulnerability has been addressed. Administrators should review the status output and continue applying complete kernel updates when required. Some fixes cannot be delivered through Livepatch and still need a conventional restart.

Red Hat kpatch

Red Hat provides kpatch for supported RHEL configurations. Before using it, check that the operating system release and running kernel are compatible with the available service and patches.

On a supported system, install the package:

sudo dnf install kpatch

Enable and start the service:

sudo systemctl enable --now kpatch.service

Check whether the service is running:

sudo systemctl status kpatch.service

To review the installed live patches, use:

sudo kpatch list

Use the documentation for the exact RHEL release when configuring kpatch. Installing the package alone does not confirm that a particular security issue has been patched. Check the installed patch list and relevant vendor advisories.

Where this method fits: Live patching is useful when a server has strict availability requirements and a supported fix is available. It can reduce the need for immediate restarts, but it does not eliminate the need for complete kernel maintenance.

Practical Guidelines for Safer Kernel Updates

Choosing an update method is only one part of the process. The way updates are prepared and verified also affects server reliability.

Keep track of security announcements. Review advisories from the Linux distribution in use. Prioritise issues according to severity, exposure and the role of the affected server.

Check backups before maintenance. Make sure important data and configuration files are backed up. A backup should be more than a completed job in a control panel: periodically test whether the data can actually be restored.

Test changes before production deployment. Where possible, install kernel updates in a staging environment first. Check application behaviour, network connectivity, storage devices, filesystems, third-party modules, virtualisation and container workloads.

Use automation with safeguards. Configuration-management and patch-management tools can help maintain consistency across multiple servers. Include reporting, monitoring and error handling. Avoid unattended reboots on critical systems unless a tested maintenance and recovery process is in place.

Confirm what is running. After a restart, use

uname -r
to identify the active kernel. If live patching is enabled, inspect its status and verify that the expected fixes are present.

Keep reboot planning in place. Live patching covers only eligible changes. Schedule full kernel updates and restarts when the distribution or patching provider requires them.

Conclusion

Kernel security maintenance involves more than downloading and installing a package. Administrators must make sure that the required fix is available, that the server can safely apply it and that the protected kernel is actually active.

For most Linux systems, the distribution’s package manager remains the normal route for installing kernel updates. Kexec can provide a faster transition on compatible machines, while live-patching services can address selected vulnerabilities without an immediate restart.

These approaches serve different operational needs. A server with a regular maintenance window may need only standard package updates. An environment concerned about restart duration may evaluate Kexec. A service with demanding uptime requirements may benefit from an eligible live-patching solution.

Whichever approach is selected, keep backups current, test changes where possible, review vendor security guidance and verify the result. A planned and consistently followed patching process is a more dependable way to protect Linux infrastructure than waiting until a vulnerability or service interruption forces an urgent response.