How To Install Linux Kernel Headers on Kali Linux 2021.x

Posted on 31 views

Welcome to our article on How to install Linux Kernel Headers on Kali Linux. If you just installed or upgraded to Kali Linux 2021.x and would like install Kernel headers, then this guide is for you?. In our previous article, we talked about how to Install Kali Linux – Step by Step. When you install new Kali Linux, it doesn’t come with Linux kernel headers out of the box and you’ll have to install them manually, the easiest way to do that will be explained shortly.

The need for Linux headers?

Kernel header files in the Linux kernel are used for two purposes:

  • To define interfaces between components of the kernel, and
  • To define interfaces between the kernel and userspace

Linux headers are needed for building modules that load into the kernel provided by the Linux kernel. When you need to run virtual machines using hypervisors such as Virtualbox and VMware Workstation on Kali Linux, it will require you to have Linux kernel headers installed.

Install Linux Kernel Headers on Kali Linux 2021.x

Follow the following short tutorial on how to install Linux kernel headers. If you are on Kali Linux 2021.x, make sure you have the following repositories on your sources.list file:

$ sudo vim /etc/apt/sources.list
deb http://http.kali.org/kali kali-rolling main contrib non-free

OR

$ sudo nano /etc/apt/sources.list
deb http://http.kali.org/kali kali-rolling main contrib non-free

Update apt-cache and upgrade

Once the packages repo is updated, upgrade your system

sudo apt update
sudo apt upgrade -y

After that, reboot the system:

sudo reboot

Wait for it to come online then check your kernel version by typing:

$ uname -r
5.14.0-kali4-amd64

Install kernel headerson Kali Linux 2021.x

To install kernel headers, run the command:

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

Accept installation prompts that comes after running the command:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gnome-desktop3-data libgnome-desktop-3-19 libxkbregistry0
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  linux-compiler-gcc-10-x86 linux-headers-5.14.0-kali4-common linux-kbuild-5.14
The following NEW packages will be installed:
  linux-compiler-gcc-10-x86 linux-headers-5.14.0-kali4-amd64 linux-headers-5.14.0-kali4-common linux-kbuild-5.14
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 13.8 MB of archives.
After this operation, 61.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

You can also append kernel version to Linux-headers command.For example

sudo apt-get install linux-headers-

That’s all about how one can install Linux Kernel Headers on Kali Linux 2021.x. Let me know in case you encounter any issues. I’ll be happy to help where possible. Below are more guides available on our website:

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.