Not able to start VMs in Virtualbox – Ubuntu 12.10

After installing virtualbox you get the following message:

WARNING: The character device /dev/vboxdrv does not exist.
Please install the virtualbox-ose-dkms package and the appropriate
headers, most likely linux-headers-generic.

You will not be able to start VMs until this problem is fixed.

To fix it run the following commands:

sudo apt-get install build-essential linux-headers-`uname -r`
sudo dpkg-reconfigure virtualbox-dkms
sudo dpkg-reconfigure virtualbox