This is how you install VirtualBox 5.2 in Ubuntu 17.10
First, we'll add the repository to /etc/apt/sources.list
sudo nano /etc/apt/sources.list
Then at the bottom, we need to add the following line for Ubuntu 17.10 - Note that if you're using a different distro, replace "artful" with whatever the other entries in your sources.list say.
deb https://download.virtualbox.org/virtualbox/debian artful contrib
Once you've done that, control-x to exit, y and then
We need to add the security key for that repository, we do that in one line:
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
Once that's done, we need to update the apt lists:
sudo apt update
Now we need to install dkms which is some kernel drivers that let VirtualBox do what it does best, it's important we install this first as there can be some issues otherwise:
sudo apt-get install dkms
Once that's installed, we can install VirtualBox:
sudo apt-get install virtualbox-5.2
And now it's ready to use!
Just open virtualbox from the terminal to make sure it's all fine, it will let you know if you need to download an update or extra files at this stage:
And we're done!