I recently installed Kali Linux on a very old PC, and since it doesn't have a wifi card I bought a Realtek USB wifi adapter. The adapter came with a driver to install, and I went to run the "install.sh", but it came back with two types of error:

1) When extracting the driver, it was unable to change the ownership of any of the extracted file from '400' to '401' - Im guessing that is like with chmod ownerships.

This I sort of solved by removing the extraction part of the shell script and extracting/chmodding the file myself. But problem 2 still applied:

2) It was unable to find the directory "/lib/modules/$(uname -r)/build"

I checked the "/lib/modules/$(uname -r)" directory, where, among other things, the drivers are kept: "/lib/modules/$(uname -r)/kernal/drivers", and indeed there is no 'build' directory. Apparently the directory should be 'the path of kernel source used for driver compilation' (taken from the Installation PDF). Now given that this was in the 'make' part of the script, I don't know where to go from here because I'm not remotely knowledgable about driver compilation. I am also not sure if it is a Kali-specific problem, but I can not find a solution anywhere else and it does not provide any help in the manual. If anyone knows where 'the path of kernel source used for driver compilation' is in Kali, or knows how to compile it manually, or even knows specifically how to install wifi adapter drivers on Kali, I would really appreciate it

http://www.cyberciti.biz/tips/build-linux-kernel-module-against-installed-kernel-source-tree.html is among a couple of websites to mention that things to do with compilation require a 'build' directory as stated above, and suggests doing this to obtain the current kernel build directory:

$ ls -d /lib/modules/$(uname -r)/build

which of course is a problem for me, as it doesn't exist for whatever reason. I have tried:

apt-get install linux-headers-$(name -r)


apt-get update && apt-get install linux-headers-$(name -r)

with the errors:

'E: Unable to locate package linux-headers-3.18.0-kali3-686-pae'


'E: Couldn't find any package by regex linux-headers-3.18.0-kali3-686-pae'

I also used:

apt-get install linux-headers-generic

which failed with:

'E: unable to locate package linux-headers-generic'

And finally I HAVE done:

apt-get install build-essentials

Which said that it is already the newest version

I have checked:

apt-cache search linux-headers-$(name -r)

which came back with no results. And yes, I HAVE tried rebooting my system. Bear in mind that I have no internet on the PC - ethernet or wifi. Sorry for the long post, I felt like I should list the errors as well.

This is a question I asked on Stack Overflow

It was classed as off-topic so I have reopened it here

  • I know this question is 2 years old, but did you find out the answer for yourself? Looking into the same right now. Apr 25, 2017 at 14:12
  • @MathiasConradt Wow, 2 years old, that makes me feel old. Unfortunately, the computer I was trying to run it on was so old and, well, awful, that what I planned to do with it fell through completely. I do remember finding the answer shortly before my entire installation went to hell, but I can't remember off the top of my head. I'll try and confirm this tomorrow, but try this in Terminal: "cd /lib/modules/$(uname -r)/build". It is only a symlink, not the actual build directory, but it should serve your purposes. Do this and tell me your results - I might finally get an answer to this question
    – DJpotato
    Apr 26, 2017 at 13:35
  • I was missing the header files, so I first did an apt-get update / upgrade / dist-upgrade / install linux-source, reboot and then installed the headers, basically following what I found at computingforgeeks.com/… Apr 26, 2017 at 15:33
  • Ah yes, you have the marvel of internet connection. That's where mine fell apart in the end, because I couldn't run those on the computer itself without internet, but i couldn't get internet without installing the kernel headers. Glad it worked out for you. To answer my question specifically, would you mind getting the actual path of your build directory and telling me here (minus your username of course)?
    – DJpotato
    Apr 27, 2017 at 14:28


You must log in to answer this question.

Browse other questions tagged .