1

I've installed the latest version of Kali Linux using virtualbox but I can't install guest additions, I found this question.

After uname -r command I have in my terminal:

4.15.0-kali2-amd64

And when I try to install linux-headers executing apt-get install linux-headers-$(uname -r) command I have the following errors:

Unable to locate package linux-headers-4.15.0-kali2-amd64
Couldn't find any package by global 'linux-headers-4.15.0-kali2-amd64'
Couldn't find any package by regex 'linux-headers-4.15.0-kali2-amd64'

For comparison I've installed Ubuntu on Virtualbox and it is working fine.

Please tell me what can I do in this case?

  • 2
    Kudos on that edit @Rui, I much prefer that over linking to the usual Q&A ;-) – Stephen Kitt Aug 26 '18 at 9:21
  • @StephenKitt I have my honest doubts this question seen from a broader angle has not been asked before. However, it is a waste to close a well written question with a good answer. – Rui F Ribeiro Aug 26 '18 at 9:24
3

Your kernel is out-of-date, and the corresponding kernel header packages are no longer available. You need to upgrade your system:

apt update
apt upgrade

then reboot your VM. This should give you the current kernel, 4.17.0-kali3 as I write this, and allow you to install the corresponding header packages.

To install the guest additions then, run the following command:

apt install virtualbox-guest-dkms virtualbox-guest-x11 linux-headers-$(uname -r)
  • I don't know how and why but my /etc/apt/sources.list file was empty i just added "Couldn't find any package by regex 'linux-headers-4.15.0-kali2-amd64'" into this file and followed your steps in your answer and it is working fine for me. Thanks for your help! – Uladzimir Khadakouski Aug 26 '18 at 9:42
  • 1
    Stephen, We are having multiple instances of people having the sources.list empty. It might be more than clueless users, or a statistic anomaly, something is wrong. Which in turns makes that duplicatte having more sense where applicable. – Rui F Ribeiro Aug 26 '18 at 9:46
  • Yes, I think there are several (real) dupes for this question... – Stephen Kitt Aug 26 '18 at 10:52
0

When you run apt update and the kernel getting updated to a newer version. The command uname -r may takes the current older kernel version.

This mismatches between the updated kernel version and the old version the reason why it fails.

So to test: Do not update

  1. apt install linux-headers-$(uname -r)
  2. do not install the new headers
  3. run update and upgrade
  4. rerun apt install linux-headers-$(uname -r)
  5. error
  6. reboot
  7. rerun apt install linux-headers-$(uname -r)
  8. works..
  • Welcome, The question is how to install the guest addition, not the linux-headers. – GAD3R Sep 21 '18 at 14:38
  • 1
    It does seem like the title of the question is aimed at installing the guest additions, but the question (confusingly) lands at asking how to get past the "unable to locate ... linux-headers..." issue. – Jeff Schaller Sep 21 '18 at 15:07
  • 1
    @JeffSchaller Already mentioned on the accepted answer , upgrading the package , rebooting , installing the kernel headers and the guest additions. – GAD3R Sep 22 '18 at 10:13
  • That it does and I was providing feedback on why it fails. Sure it was the accepted answer but I wanted to provide additional information on WHY it actually fails. Don't understand the downvoting tbh. – herpyderp Sep 28 '18 at 13:24

protected by GAD3R Sep 21 '18 at 14:36

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.