How to install Virtualbox on Ubuntu Server 12.04

In this tutorial I am going to show you How to install Virtualbox on Ubuntu Server 12.04. Ubuntu Server does not equipped with a Desktop environment or GUI so Virtualbox will also run as a headless virtualbox. But, still we can use Virtualbox to create and manage virtual machines via command line. OK lets get started. 

Steps to install Virtualbox on Ubuntu Server 12.04

Step 1. Open and edit /etc/apt/sources.list. Add the following line to it
deb http://download.virtualbox.org/virtualbox/debian precise contrib
Step 2. Add the Virtualbox public key
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
Step 3. Update system
apt-get update
Step 4. Install Virtualbox and dependency files
apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.2 dkms
Make sure you have a good internet connection since the command above will download some packages from the internet. 

Install Virtualbox Extension Pack

You can download the extension pack from this link: https://www.virtualbox.org/wiki/Downloads or simply use this command
wget http://download.virtualbox.org/virtualbox/4.2.0/Oracle_VM_VirtualBox_Extension_Pack-4.2.0-80737.vbox-extpack

sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.2.0-80737.vbox-extpack
Now add user that will use and run Virtualbox
sudo adduser dhani vboxusers
change dhani with your own username. That's it. For more information about how to create new machine or run a virtual machine using command line, please visit this website: