Home Debian How to install kernel headers on Debian

How to install kernel headers on Debian

by Emmanuel
install kernel headers on debian

Kernel headers contain the C header file for the Linux kernel, which provides the several functionality and structure definitions needed when compiling any code that interfaces with the kernel, such as kernel device drivers or modules and some other user programs.

Generally, Linux kernel headers are components habitually used to compile drivers and loadable modules appending support to the kernel. It is also vital to shedding light on the fact that the kernel headers are part of the kernel, despite being separately distributed.

Another critical thing to note is that the kernel headers package must match your system’s currently installed kernel version. Suppose you have kernel version with the default distribution installation, or you have upgraded your kernel via dpkg or apt package manager from Debian base repos.  In that case, you must set up matching kernel headers using the package manager only. On the other hand, if you have compiled kernel from sources, you should also set up kernel headers from sources.

After going through that piece of info, let us now turn our attention to the core part of the article, which will explain how to install kernal headers in Linux, specifically the Debian Linux distro using the default package manager.

How to install kernel headers in Debian

Step 1: First things first, before firing things up, you need to log in as a root user by running the following command:


After that, input your PC’s password, and you should be logged in as a root user, as shown in the snapshot above.

Step 2: Next, we will proceed by checking the already installed kernel version and header package that matched your kernel version using the following commands:

uname -r

apt search linux-headers-$(uname -r)
check the installed kernel

check the installed kernel

Step 3: All kernel header files can be accessed under the /usr/src directory on Debian and its derivatives. You also have the flexibility of checking to confirm if the matching kernel headers for your kernel versions are already installed on your system or not using the subsequent command:

ls -l /usr/src/linux-headers-$(uname -r)
No such file or directory

No such file or directory

From the output above, it is true that the matching kernel header directory does not exist, meaning that the package is not yet installed.

Step 4: Before installing the kernel headers, ensure you update your package’s index list to grab the information about the latest releases using the following command:

sudo apt update
update system

update system

Step 5: After running the update command, you should be notified if there are packages that need an upgrade. If there are, then run the following command; otherwise, skip this part.

sudo apt upgrade
upgrade system

upgrade system

Step 6: Then proceed and run the following command that follows to install the Linux kernel headers package for your kernel version

sudo apt install linux-headers-$(uname -r)
install linux header

install Linux header

Note: You will be asked to affirm your decision to proceed with the installation at some point during the installation. All you have to do is type “y/Y” and hit the “Enter” button or hit the “Enter” button alone, and that should work.

Step 7: Next, go ahead and check if you have installed the matching kernels on your system by utilizing the following command:

ls -l /usr/src/linux-headers-$(uname -r)
check if they mattch

check if they match

To list all the available headers, run the following command:

sudo apt search linux-headers
search linux headers

List all the available Linux headers

Then after using Debian 11 x64 or the second method to find the header, you can alternatively execute the following command to install the header.

sudo apt install linux-headers-5.10.0-10-amd64
install command

install command

Linux Headers FAQs

Where are Linux headers?

Linux-headers is a package providing the Linux kernel headers. These are part of the kernel despite being shipped separately. They interface between internal components, userspace, and the kernel.

Do you require Linux headers?

You require the Linux headers when you plan to develop and compile on your installed machine, Debian. If you, for instance, build an appliance dedicated to a particular task, you are probably not willing to compile on it. Suppose you need to compile your app; you will do this on a different system.

How to view headers in Unix

We use od -bc {filename} | head to look at the header of a binary file. View work too, but it is naturally better to see the output directly on the command line.

How to know if the kernel headers are installed

You can open up the Software Center or the synaptic and ensure the package “Linux-headers-generic” is installed. That package is marked depending on the headers for the latest available kernel version so that it will pull in another package or two for you specifically.

Do you need to keep kernel headers synced with your kernel version?

The answer is NO. You can have a newer Linux-headers version than your running kernel binary. For instance, if you have kernel 4.1 setup, you can have Linux-headers 4.4. If you compile your Glibc with these newer headers and later upgrade to kernel 4.4, you will be able to utilize the new features of this kernel without recompiling Glibc.

Why do we need headers in Linux?

The header files explain an interface: they specify how the functions in the source file are defined. They are utilized so that a compiler can check if the usage of a function is accurate as the function signature (return value and parameter) is present in the header file.

Final thoughts

As you can see, installing Linux kernel headers on Debian is super easy for any Linux-level user, be it a newbie, intermediary, or expert. Furthermore, any Linux-level user should at least know the functionality of Kernel headers and how to install them. You must also be keen on the kernel headers you download as they should be compatible with your system, not only the architecture but also the version. Also, keep in mind that you will need the Linux kernel headers to compile a kernel module.

You may also like

Leave a Comment



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us


©2016-2023 FOSS LINUX



“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.