Linux Tutorials

Install Kernel Headers on Kali Linux

Kernel headers are what you install when you need to compile something that plugs into the running kernel. DKMS drivers, VirtualBox guest additions, VMware modules, third-party network card drivers, eBPF tooling, and most kernel-adjacent build targets all ask for the headers during their build step. A fresh Kali Linux install doesn’t ship them by default because the base image is lean, so this guide is the tool of choice anytime you see No headers found in a build log.

Original content from computingforgeeks.com - post 88

On Kali the kernel is rebased frequently (it rolls along Debian testing/unstable), so the version you install today will not be the version you install next month. The commands below resolve the headers for whatever kernel is currently running, which is the only reliable way to keep this step from breaking after updates.

Tested April 2026 on Kali Linux Rolling 2026.1 with kernel 6.18.12+kali-amd64 and GCC 15.2.0

Step 1: Identify the running kernel

Before installing anything, check what kernel is booted right now. The headers need to match this string exactly:

uname -r

On the current Kali Rolling build this returns:

6.18.12+kali-amd64

And confirm which linux-image package the running kernel came from:

dpkg -l | grep '^ii  linux-image' | awk '{print $2, $3}'

Two package names cover the running kernel: the versioned one and the amd64 metapackage:

linux-image-6.18.12+kali-amd64  6.18.12-1kali1
linux-image-amd64               6.18.12-1kali1

Step 2: Refresh the package index

Kali rolls constantly. If your index is a week old the headers package apt returns may no longer match what’s actually in the mirrors:

sudo apt update

Check which version of the headers package apt will offer for the running kernel:

apt-cache policy "linux-headers-$(uname -r)"

The Candidate version should match the linux-image package release:

linux-headers-6.18.12+kali-amd64:
  Installed: (none)
  Candidate: 6.18.12-1kali1
  Version table:
     6.18.12-1kali1 500
        500 http://http.kali.org/kali kali-rolling/main amd64 Packages

The Installed line should show (none) initially, and the Candidate should match the release number of your running kernel package. If the candidate is blank, the Kali mirror doesn’t have a headers build for your current kernel yet (this sometimes happens in the day or two after a new kernel lands). Run apt full-upgrade, reboot into the fresh kernel, then retry.

Step 3: Install the headers

Install the exact-match package. The command uses command substitution so it resolves the correct version at runtime:

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

On a minimal Kali box, apt pulls in the common headers package, GCC, and some toolchain bits alongside the kernel-specific headers:

Setting up gcc-15-for-host:amd64 (15.2.0-16)...
Setting up linux-headers-6.18.12+kali-amd64 (6.18.12-1kali1)...
Setting up gcc-15 (15.2.0-16)...
Setting up g++-15 (15.2.0-16)...

Step 4: Verify the install

Confirm the headers landed in the right place. The build symlink under /lib/modules/$(uname -r) is what kernel module builds look for first:

ls -la "/lib/modules/$(uname -r)/build"

The symlink points into /usr/src where the actual headers live:

lrwxrwxrwx 1 root root 45 Feb 25 12:06 /lib/modules/6.18.12+kali-amd64/build -> ../../../src/linux-headers-6.18.12+kali-amd64

The symlink resolves to /usr/src/linux-headers-6.18.12+kali-amd64, where the actual Makefiles and include directories live. Check that it’s populated:

ls /usr/src/

You should see both the architecture-specific and common headers packages unpacked:

linux-headers-6.18.12+kali-amd64
linux-headers-6.18.12+kali-common
linux-kbuild-6.18.12+kali
python3.13

Two packages cover the headers: the architecture-specific one (linux-headers-6.18.12+kali-amd64) has the per-kernel-config includes, and linux-headers-6.18.12+kali-common has the source tree parts that are identical across architectures.

Step 5: Confirm the toolchain is ready

Kernel module builds need gcc and make at a minimum. Both come in as dependencies of the headers package on Kali:

gcc --version | head -1
make --version | head -1

Both tools should resolve cleanly and report reasonably fresh versions:

gcc (Debian 15.2.0-16) 15.2.0
GNU Make 4.4.1

If you’re also going to build DKMS modules (which is the normal path for VirtualBox guest additions, Nvidia drivers, and most third-party hardware drivers) install the DKMS framework too:

sudo apt install -y dkms build-essential

Step 6: Track the latest kernel automatically

The linux-headers-amd64 metapackage always depends on the headers for the latest available kernel, which means installing it once keeps you current through every future kernel bump:

sudo apt install -y linux-headers-amd64

From now on, every time apt full-upgrade pulls in a newer linux-image-amd64, the matching linux-headers package gets dragged along with it. After the next reboot your DKMS modules will rebuild against the new kernel on their own. This is the set-it-and-forget-it path.

Wrap up

That’s all there is to it. You now have matching kernel headers, a C/C++ toolchain, and (optionally) DKMS ready to go. If you’re installing Kali inside a hypervisor, the next logical step is installing VirtualBox on Kali Linux or the VMware open-vm-tools package, both of which compile kernel modules on install and will succeed silently once the headers are in place. Headers are also the first dependency when installing the Metasploit Framework from source, and they matter the moment you start building against the JDK or any tool that wraps native JNI code. Once the headers are wired up, consider also protecting GRUB with a password to round out the boot-time hardening.

Related Articles

Networking Secure Asterisk and FreePBX from VoIP Fraud and Brute Force Attacks Cloud Do You Need CNAPP For Your Cloud? CNAPPs Explained Security 6 Benefits of Enlisting Cybersecurity Services for Your Business Security Use Let’s Encrypt on Private Network with Cloudflare

12 thoughts on “Install Kernel Headers on Kali Linux”

  1. nice article,it is useful to me and others to know about this items,please just keep it….

    Reply
  2. Not working for me on the raspberry pi 5.

    E: Unable to locate package linux-headers-6.1.77-v8
    E: Couldn’t find any package by glob ‘linux-headers-6.1.77-v8’

    Need them in order to install the wifi drivers for my wifi dongle.

    Reply

Leave a Comment

Press ESC to close