Installing the Kernel Headers in Kali Linux is sometimes necessary to install certain tools or software (i.e. VMware Tools). Follow this tutorial to learn how to do it.
First, we need to make sure that the official Kali Linux repositories are added to the “sources.list” file.
Open a Terminal and type leafpad /etc/apt/sources.list and press Enter.
In the file that opens, look over it. If it contains all the lines listed below, then you can close it and continue on to Step Three. However, if it is empty or contains text different than the text listed below, delete everything inside it and replace it with the below text:
deb http://http.kali.org/kali kali main non-free contrib
deb http://security.kali.org/kali-security kali/updates main contrib non-free
deb-src http://http.kali.org/kali kali main non-free contrib
deb-src http://security.kali.org/kali-security kali/updates main contrib non-free
If you have to manually type it, be sure to double check it, as even the slightest error will result in Kali Linux not updating properly.
Once you have finished, close leafpad and click Yes when it asks you if you want to save the changes.
Now, in the Terminal, type the below command:
apt-get update && apt-get install -y linux-headers-$(uname -r)
And press Enter.
It will ask you if you want to install the new updates (headers). Type Y for “yes” and press Enter again.
Once it has completely finished updating, and you’re presented with the root@kali prefix again, type reboot in the terminal to restart Kali Linux.
The Kernel Headers have now been installed.
Thank you for following our tutorial!