dotlinux blog

How to Install Kernel Headers in Ubuntu and Debian

Kernel headers are an essential part of the Linux operating system. They provide the necessary files for building kernel modules, such as device drivers. In this blog post, we will guide you through the process of installing kernel headers in Ubuntu and Debian.

2026-05

Table of Contents#

  1. Prerequisites
  2. Checking the Current Kernel Version
  3. Installing Kernel Headers in Ubuntu
  4. Installing Kernel Headers in Debian
  5. Verifying the Installation
  6. Conclusion
  7. References

Prerequisites#

Before we begin, make sure you have the following:

  • A system running Ubuntu or Debian.
  • Administrative privileges (sudo access).

Checking the Current Kernel Version#

First, we need to check the current kernel version installed on your system. Open a terminal and run the following command:

uname -r

This will display the kernel version number. For example:

5.15.0-46-generic

Installing Kernel Headers in Ubuntu#

  1. Update the package list:
sudo apt-get update
  1. Install the kernel headers:
sudo apt-get install linux-headers-$(uname -r)

The $(uname -r) part will automatically substitute the current kernel version. For example, if your kernel version is 5.15.0-46-generic, the command will install linux-headers-5.15.0-46-generic.

Method 2: Using apt#

  1. Update the package list:
sudo apt update
  1. Install the kernel headers:
sudo apt install linux-headers-$(uname -r)

Installing Kernel Headers in Debian#

Method 1: Using apt-get#

  1. Update the package list:
sudo apt-get update
  1. Install the kernel headers:
sudo apt-get install linux-headers-$(uname -r)

Method 2: Using apt#

  1. Update the package list:
sudo apt update
  1. Install the kernel headers:
sudo apt install linux-headers-$(uname -r)

Verifying the Installation#

After the installation is complete, you can verify that the kernel headers are installed correctly. Run the following command:

dpkg -l | grep linux-headers-$(uname -r)

This will list the installed kernel headers package. If the package is listed, the installation was successful.

Conclusion#

In this blog post, we have shown you how to install kernel headers in Ubuntu and Debian. By following these steps, you can ensure that you have the necessary files for building kernel modules. Remember to always update your system before installing new packages.

References#