To install VirtualBox on our Ubuntu server, we open /etc/apt/sources.list...
sudo vi /etc/apt/sources.list
... and add the following line to it:
deb http://download.virtualbox.org/virtualbox/debian precise contrib
Then we download the VirtualBox public key...
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
... and update our package database:
sudo apt-get update
Afterwards, we install VirtualBox as follows:
sudo apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.2 dkms
(The dkms package ensures that the VirtualBox host kernel modules are properly updated if the Linux kernel version changes.)