DEV Community

Cover image for How to Install VirtualBox on Kali OS(2022)

How to Install VirtualBox on Kali OS(2022)

A few weeks back, in one of my learning, I was to install VirtualBox on my kali OS, but I wasn’t able to install it. I downloaded the VirtualBox installer twice and all gave the same error. I was stalked for a couple of days before I found a way around it and it worked for me.

I did the installation through the terminal, here are the steps.

Firstly, I did uname -a which check my system information, and what I was after in the information was the version of my kernel 5.16.18-1kali7amd64.

Then I did uname -r which showed me the release version of my kernel. I have the information I needed, now let’s go further.

We need to install the Linux kernel header because that is what is conflicting with installing the VirtualBox.

linux-headers is a package providing the Linux kernel headers. These are part of the kernel, although they are shipped separately.

The headers act as an interface between internal kernel components and also between userspace and the kernel. Packages like sys-libs/glibc depend on the kernel headers.

You have to have it if you need to compile kernel modules, and in Linux it is widely used as there are packages which comes as a source and then compiled and linked with the kernel when downloaded. This gives you the ability to link with multiple kernel versions as long as the kernel API hasn’t changed.

So, next is installing the Linux header using sudo apt install linux-headers-$(uname -r | sed ‘s,[^-]*-[^-]*-,,’). This should install the Linux header for your kernel version. While installing the header, you might encounter a failed to install error, kindly solve that by using this command sudo apt --fix-broken install. The error occurred because you have tried to install software and it failed, it still resides in the system memory and needs to be removed. After the error has been resolved, retry installing the Linux header.

After the header has been installed, then install the Linux Image of the header you just installed. Using sudo apt install linux-image-$(uname -r | sed ‘s,[^-]*-[^-]*-,,’).

Linux-image is the kernel binary. Linux headers is the source header files. There’s no reason to include them together, debian keeps dev packages and binary package seperate. In a simple term: linux-image contains the kernel image and the modules, while linux-headers contains the kernel headers.

After the above steps, what is next is to install the build-essential package

A meta-package is what build-essential is. It does not install anything on its own. It is instead a link to a number of other packages that will be installed as dependencies.
Essentially, the build-essential package provides you with everything you need to compile basic C and C++ software on Linux.
If you wanted to, you could install each of these packages separately. The build-essential meta-package, on the other hand, makes it straightforward to get everything you need in one package.
While build-essential is a solid starting point for compiling more difficult software on Linux, you may need to install extra libraries.

Install the build-essential package using sudo apt install build-essential dkms.

We are done installing all that is needed for us to install the VirtualBox on our Kali OS. Next is to now install the VirtualBox and its extension pack.

sudo apt install virtualbox virtualbox-ext-pack Will help you install it.

We are done, VirtualBox is now successfully installed on our machine.

Do you want to test it? Type virtualbox in your terminal, hit the enter button and watch VirtualBox load.

Enjoy your day.

Top comments (0)