How to Install Linux Kernel Headers on Fedora 44

Install kernel-devel and kernel-headers on Fedora 44 for compiling kernel modules, NVIDIA drivers, and VirtualBox with version matching.

Last updatedAuthorJoshua JamesRead time5 minGuide typeFedora

Fedora kernel-module builds fail when the development package does not match the kernel that is actually running. To install Linux kernel headers on Fedora for driver builds, install kernel-devel-$(uname -r); that package provides the module build tree under /usr/src/kernels/ and pulls the compiler tools Fedora needs for normal module compilation.

The kernel-headers package has a different job: it provides userspace C headers, including files under /usr/include/linux/. The current Fedora install transaction for kernel-devel also pulls it in, but you can install it by itself when you are building userspace software rather than kernel modules. These commands target Fedora’s stock kernel packages; alternate kernels, such as a mainline Linux kernel on Fedora, need matching development files from that kernel source.

Install Linux Kernel Headers on Fedora

Refresh Fedora Before Installing Kernel Headers

Refresh Fedora packages first so DNF resolves the current kernel and matching development package from the latest enabled repositories.

sudo dnf upgrade --refresh

If the upgrade installs a newer kernel, reboot before installing kernel-devel. The running kernel reported by uname -r must match the development package you install, or module builds can fail even though the package transaction succeeded.

These commands use sudo because DNF changes system packages. If your account cannot run privileged package commands, add the user to sudoers on Fedora before continuing.

Check the Running Fedora Kernel

Print the active kernel release before installing development files.

uname -r

A Fedora 44 system can return a kernel string like this:

7.0.8-200.fc44.x86_64

The full string matters. The fc44 suffix identifies the Fedora build, and the architecture suffix must match the installed package architecture.

Install kernel-devel for the Running Kernel

Install the kernel-devel package that matches the active kernel exactly.

sudo dnf install kernel-devel-$(uname -r)

On current Fedora, that transaction installs the matching kernel-devel package and the supporting dependencies DNF needs for module builds, including kernel-headers, gcc, make, elfutils-libelf-devel, bison, and flex. Use this path for NVIDIA driver builds on Fedora, VirtualBox kernel modules on Fedora, DKMS modules, akmods modules, and custom module work against Fedora’s packaged kernel.

Install kernel-headers Only for Userspace Builds

Install kernel-headers by itself only when a userspace build needs Linux userspace API headers and you do not need to compile a kernel module.

sudo dnf install kernel-headers

Do not use kernel-headers as a substitute for kernel-devel. A module build needs the Makefiles, configuration, and symbol files from the matching kernel-devel tree.

Understand kernel-devel and kernel-headers on Fedora

Fedora separates these packages because they serve different build targets. The Fedora kernel-devel package provides files for building modules against the kernel package, while the Fedora kernel-headers package provides userspace header files for low-level C builds.

PackageUse It ForInstalled LocationVersion Behavior
kernel-develKernel modules, DKMS, akmods, proprietary drivers, and custom module builds/usr/src/kernels/$(uname -r)Must match the running kernel exactly
kernel-headersUserspace programs that need Linux API header filesUserspace header paths under /usr/include/Can differ from the running kernel without breaking module builds

For most driver-build problems, start with kernel-devel-$(uname -r). The shorter kernel-headers name is useful for userspace development, but it will not create the module build directory that tools usually search for.

Verify Kernel Development Packages on Fedora

Confirm that kernel-devel exists for the active kernel.

rpm -q kernel-devel-$(uname -r)

Successful output includes the active kernel release:

kernel-devel-7.0.8-200.fc44.x86_64

Check the userspace headers package separately when your build specifically needs it.

rpm -q kernel-headers

On Fedora, the kernel-headers version can be close to, but not identical to, the running kernel:

kernel-headers-7.0.6-200.fc44.x86_64

Verify the module build tree by checking for the files module builders normally require.

ls -1 /usr/src/kernels/$(uname -r) | grep -E '^(Makefile|Module.symvers|arch|include|scripts)$'
arch
include
Makefile
Module.symvers
scripts

If the directory is missing or the command returns no key build files, install kernel-devel-$(uname -r) again after rebooting into the kernel you plan to use.

Fix Kernel Header and Module Build Problems on Fedora

Missing kernel source tree or linux/module.h

Errors such as fatal error: linux/module.h: No such file or directory or could not find files needed to compile modules usually mean the active kernel has no matching kernel-devel tree installed.

rpm -q kernel-devel-$(uname -r)

If the package is missing, Fedora reports the exact active-kernel package name that is not installed.

package kernel-devel-7.0.8-200.fc44.x86_64 is not installed

Install the matching package and rerun the failed build.

sudo dnf install kernel-devel-$(uname -r)

kernel-devel Does Not Match the Running Kernel

A mismatch often happens after Fedora installs a newer kernel but the system has not rebooted into it yet. Compare the active kernel with installed kernel and development packages.

uname -r
rpm -qa 'kernel-core*' 'kernel-devel*' | sort -V

If kernel-core shows a newer release than uname -r, reboot first. After Fedora starts the newer kernel, install the matching development package again.

sudo dnf install kernel-devel-$(uname -r)

If the active kernel came from a third-party or custom source, do not force Fedora’s stock kernel-devel package onto it. Use the development package, headers, or build tree provided by that kernel source.

DKMS or akmods Rebuilds Still Fail

Fedora driver packages commonly use akmods, while some third-party packages use DKMS. Use the rebuild tool that matches the driver package you installed, and check that the tool exists before running its rebuild command.

command -v dkms
command -v akmods

If either command prints no path, that rebuild tool is not installed on the system. Do not install DKMS or akmods only to satisfy this check; use the tool required by the driver package you already installed.

For DKMS packages, rebuild registered modules after confirming kernel-devel-$(uname -r) is installed.

sudo dkms autoinstall

For akmods packages, rebuild modules for the active kernel.

sudo akmods --force

If a packaged driver still fails, continue in the driver-specific workflow because Secure Boot, module signing, and package-source issues are separate from header installation. Fedora driver examples include NVIDIA drivers and VirtualBox on Fedora.

Update or Remove Kernel Development Packages

Installed kernel development packages update through normal Fedora DNF maintenance.

sudo dnf upgrade --refresh

After a kernel update, reboot and reinstall kernel-devel-$(uname -r) if a module builder reports missing development files for the new active kernel.

Remove the development packages when the system no longer builds kernel modules or userspace software that needs the Linux headers.

sudo dnf remove kernel-devel kernel-headers

DNF also removes dependencies that were installed only for the kernel-devel transaction, such as compiler and parser packages, when no other installed package needs them. Review the transaction summary before confirming removal on development workstations.

Verify removal with RPM.

rpm -q kernel-devel kernel-headers
package kernel-devel is not installed
package kernel-headers is not installed

Conclusion

Fedora has the matching kernel development tree when rpm -q kernel-devel-$(uname -r) succeeds and /usr/src/kernels/$(uname -r) contains the build files your module tool expects. Keep kernel-headers separate in your mental model: it supports userspace C builds, while kernel-devel is the package that fixes most driver, DKMS, akmods, and custom module build failures.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: