How to install Oracle Virtual Box on Linux (CentOS / RHEL 7)

Written by - Deepak Prasad

In my last article I wrote an article with steps to install ClamAV (antivirus tool for Linux). Now in this article I will share the steps to install Oracle Virtual Box on CentOS / RHEL 7 Linux . Oracle VirtualBox is a virtualization application that has the capacity to run on multiple computer architectures (Intel, AMD-based systems) and on almost every available OS (OSX, Linux, Windows, Solaris, and so on), where it allows its users to run multiple operating systems on the same physical machine. Basically, virtual box is a full virtualization technology.

Most people count on it while using multiple systems and need to export and import template virtual machines, where virtual box offers a variety of options to exchange virtual machines between all kinds of infrastructures.

Steps to install Oracle Virtual Box on Linux (CentOS / RHEL 7)


Steps to install Oracle Virtual Box

This section will show you how to install Oracle VirtualBox 5.2 on CentOS 7. Firstly, we need to add the VirtualBox yum repository to our system. So, we need to create its repo file in the YUM repository directory:

# cat /etc/yum.repos.d/virtualbox.repo
name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox

We should also have the EPEL repository installed:

# rpm -ivh

Before we start the installation, we need to install some necessary packages to make sure that VirtualBox works fine:

# yum install gcc make kernel-headers kernel-devel fontforge binutils patch dkms glibc-headers glibc-devel qt libgomp

Then, we set up an environment variable called KERN_DIR, from which VirtualBox will get the kernel source code:

# export KERN_DIR=/usr/src/kernels/`uname -r`
To make the changes permanent I will add this variable at the end of my /etc/profile

You can get the list of available VirtualBox rpms in the repo using the below command

# yum list all | grep -i virtual
VirtualBox-4.3.x86_64 4.3.40_110317_el7-1 virtualbox
VirtualBox-5.0.x86_64 5.0.40_115130_el7-1 virtualbox
VirtualBox-5.1.x86_64 5.1.38_122592_el7-1 virtualbox
VirtualBox-5.2.x86_64 5.2.20_125813_el7-1 virtualbox
VirtualGL.x86_64 2.5.2-1.el7 epel
VirtualGL-devel.x86_64 2.5.2-1.el7 epel

Then, we can start the installation of VirtualBox using YUM:

# yum install VirtualBox-5.2

After the installation, we need to rebuild the kernel modules using the following command:

# systemctl start vboxdrv

Now, we have VirtualBox installed and ready for use. Still, VirtualBox only supports graphical interfaces, so we need to have one installed and then we can start it and use it.

We need to have a graphical interface installed on our server and we have a long list to choose from. I would recommend Gnome, as it is one of the most used interfaces with its user-friendliness and its low resources consumption.

Using GNOME as the graphical interface, we can start VirtualBox:

Steps to install Oracle Virtual Box on Linux (CentOS / RHEL 7)


Lastly I hope the steps from the article to install Oracle Virtual Box on Linux was helpful. So, let me know your suggestions and feedback using the comment section.

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can reach out to him on his LinkedIn profile or join on Facebook page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to

Thank You for your support!!

2 thoughts on “How to install Oracle Virtual Box on Linux (CentOS / RHEL 7)”

Leave a Comment