How to install VirtualBox in Ubuntu, CentOS and Windows

This tutorial explains how to install Virtual Box in Ubuntu, in CentOS and in Windows step by step with practical examples. Learn how to add & create repository, download & import public keys and install the latest version of virtual box in CentOS & Ubuntu Linux including installation steps of VirtualBox in Windows.

VirtualBox is a free and open source software developed by Oracle Corporation. You can download the latest version of VirtualBox from here.

https://www.virtualbox.org/wiki/Downloads

VirtualBox provides software based virtualization. Virtualization allows us to run multiple virtual machines in single computer. Each virtual machine works as an independent computer which further allows us to install and run multiple operating systems in single computer.

Installing VirtualBox in Windows

Download the latest version of VirtualBox from its official site and double click the installer file.

download virtualbox

Whenever we install an application which is downloaded from Internet, Windows warns us about the potential risk involve in installation. Application software downloaded from internet may contain virus, malware, Trojan horse, worm etc.

Since this software is downloaded from its official site, we can safely install and use it in Windows system.

Click Run to confirm the installation process.

start install of virtualbox in window

First screen of Setup Wizard shows welcome message and version number. Click Next to start the installation.

welcome screen

VirtualBox comes with several add-on features. If require, we can install these features with VirtualBox or can skip them to save the disk space.

Select the features which you want to install with VirtualBox.

select feature

Once required features are selected, we have to specify the installation folder location. Default location is set to c:\\Program Files\Oracle\VirtualBox. We can use this location or can set other location.

select virtualbox installation location

If require, you can take the help of Disk Usage option to view the detailed overview of available disk space in all partitions and the required disk space by VirtualBox with selected features.

disk usage option

Select the features which you want to install with VirtualBox and the location where you want to install the VirtualBox and click Next button.

Next screen allows us to select the way we want to access the VirtualBox. Make your selection and click Next button.

access option

In order to install the networking feature, wizard will reset the network interface.

In next screen, setup wizard warns about it. If no important network process is running at this time, click Yes button to continue the installation. If any important network process (such as file transferring, downloading, etc.) is running, lets it finish before clicking Yes button.

VirtualBox installation network interface warning

That’s all information Setup wizard needs before installing VirtualBox. Click Install button to start the installation process.

start installation

Depending on system resources and selected features installation process may take several minutes.

installation running

In installation process, Setup wizard installs drivers for virtual machine which may trigger Windows Security alert.

If receives security alert for device driver, select “Always trust software from Oracle Corporation” and click Install button.

install driver

On last screen, we have an option to launch VirtualBox just after the installation. Select it and click Finish button to close the wizard.

virtual box installation finish

Once installed, VirtualBox can be accessed through Start Menu, Desktop shortcut and Quick launch bar (depending on which you selected during the installation in way to access option screen).

Following figure shows the home screen of VirtualBox Manager. From here we can create and manage virtual machines.

virtual box installed in windows

Installing VirtualBox in Ubuntu Linux

Connect system with internet and run following commands in terminal

$sudo apt-add-repository “deb http://download.virtualbox.org/virtualbox/debian $(lsb_release –sc) contrib”
$wget- q https://www.virtualbox.org/download/oracle_vbox.asc –O- | sudo apt-key add –
  • First command adds VirtualBox repository for current version of Ubuntu.
  • Second command downloads and imports public keys for VirtualBox.

Software management (adding/removing repository, installing/removing software etc.) requires root privilege. The user account which you create during the installation has necessary privilege. Type the password of that account when it asks for authentication.

add virtual box repository in ubuntu

Run following command to update the repository database

$sudo apt-get-update

sudo apt-get update

Now run following command to install the VirtualBox

$sudo apt-get install virtualbox-[version_number]

In this command version_number is the version of VirtualBox which we want to install. For example, to install VirtualBox 5.2, use following command.

$sudo apt-get install virtualbox-5.2

Installation process needs confirmation for two actions: -

  • Do we allow installer to allocate the required disk space?
  • Do we allow installer to install package from unknown source?

To allow the both actions, type Y when it asks.

sudo apt-get install virtualbox

Once installation is finished, we can access VirtualBox from left side panel.

access virtual box

We have successfully installed VirtualBox in Ubuntu.

virtual box installed in ubuntu

Installing VirtualBox in CentOS Linux

Connect the system with internet and run following command

#vim /etc/yum.repos.d/virtualbox.repo

This command creates (if not exist) and opens a new file named virtualbox.repo in /etc/yum.repos.d directory. In CentOS Linux all repository files are stored this directory. In order to install VirtualBox through repository, we also have to create a source repository file in this directory.

vim /etc/repos.d/virtualbox.repo

Now add following lines and save the file

[VirtualBox]
name=CentOS-$releasever / $basearch – VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc

update virtual repo

Run following command to check, update, sync and list repositories.

#yum repolist

If repository file for VirtualBox is correctly edited, this command will download, import and install public key for VirtualBox automatically. If this command returns with error, check repository file again and make sure it does not contain any typing mistake.

yum repolist

To learn how to add, create, manage and troubleshoot custom repositories in detail see this tutorial
How to configure yum repository in Linux

Now run following command to install the VirtualBox

#yum install VirtualBox-[version_number]

In this command version_number is the version of VirtualBox. For example to install VirtualBox 5.2 use following command

#yum install VirtualBox-5.2

Just like Ubuntu, installation process in CentOS also needs confirmation for consumed disk space by package and package source verification. To allow the both actions, type Y when it asks.

yum install virtualbox-5.2

VirtualBox has been installed in CentOS. But it will not run under the regular user account. See following line in above figure

Creating group ‘vboxusers’. VM users must be member of that group!

To allow a regular user to access VirtualBox, we have to add him in vboxusers group.

For example to allow user “sanjay”, we have to use following command

#usermod –a –G vboxusers sanjay

add user in vboxusers group

Once user is added vboxusers group, he can run VirtualBox and create and manage virtual machines in VirtualBox. To run VirtualBox use following command

$virtualbox

virtual box installed centos

That’s all for this tutorial. If you like this tutorial, please share it through your favorite social platform. If you have suggestion or feedback regarding this tutorial, please let us know.

ComputerNetworkingNotes SysAdmin Tutorials Collection How to install VirtualBox in Ubuntu, CentOS and Windows