Debian

How to Install Linux Kernel Headers on Debian 12

The Linux kernel headers are required to compile the kernel modules of different software (i.e. VMware Workstation, VirtualBox). If you don’t have the Linux kernel headers installed on your Debian 12 system, the software that requires it won’t run at all. You have to install the correct version of the Linux kernel headers on Debian 12 to make sure that the software that requires them can compile their kernel modules.

In this article, we will show you how to install the Linux kernel headers on Debian 12 “Bookworm”.

Topic of Contents:

  1. Updating the Debian 12 System
  2. Updating the Debian 12 Package Repository Cache
  3. Checking the Version of the Installed Linux Kernel on Debian 12
  4. Installing the Linux Kernel Headers on Debian 12
  5. Conclusion

Updating the Debian 12 System

Before you install the Linux kernel headers on your Debian 12 system, it’s a good idea to install all the available updates on your Debian 12 system.

If you need any assistance in updating your Debian 12 system, read the article on How to Keep Debian 12 System Up-to-Date.

Once you updated your Debian 12 system, reboot your computer for the changes to take effect with the following command:

$ sudo reboot

Updating the Debian 12 Package Repository Cache

To update the Debian 12 package repository cache, run the following command:

$ sudo apt update

A screenshot of a computer Description automatically generated

Checking the Version of the Installed Linux Kernel on Debian 12

To check the version of the Linux kernel that you’re using on your Debian 12 system, run the following command:

$ uname -r

As you can see, our Debian 12 computer is using the Linux kernel version 6.1.0. The version of the Linux kernel headers that you install must match the version of the Linux kernel that you installed on your Debian 12 system. Otherwise, the software that requires them to compile its kernel modules won’t be able to access it.

A screenshot of a computer Description automatically generated

Installing the Linux Kernel Headers on Debian 12

To install the same version of the Linux kernel headers as the Linux kernel that you’re using on your Debian 12 system, run the following command:

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

To confirm the installation, press Y and then press <Enter>.

The Linux kernel headers and the required dependency packages are being downloaded from the internet. It takes a while to complete.

A screenshot of a computer Description automatically generated

The Linux kernel headers and the required dependency packages are being installed. It takes a while to complete.

A screenshot of a computer Description automatically generated

At this point, the correct version of the Linux kernel headers should be installed on your Debian 12 system.

A screenshot of a computer Description automatically generated

Conclusion

We showed you how to install the correct version of the Linux kernel headers on a Debian 12 system so that the software that requires it can use it to compile its kernel modules on Debian 12.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.