Write Review


Vagrant is an open-source tool used to build and manage virtual machine environments. A test environment is required to analyze the latest release and new tools in the market. Vagrant default setting uses VirtualBox to manage the virtualization.

It acts as a key configuration tool to assist in managing multiple virtual environments using the same configuration.

This tutorial will take you through the installation process of Vagrant on Ubuntu 18.04 LTS. We are going to use VirtualBox provider, which is the Vagrant default provider

What is VirtualBox?

You can choose to install two different operating system in a single virtual machine, but you need to restart your system every time you install the system. VirtualBox allows you to run multiple operating systems on a single system. You can switch to any without rebooting your system.


Before you start, ensure you’re logged in as a root user with sudo privileges.

Installing Vagrant

Start by installing Vagrant on Ubuntu. To do so follow the following steps.

1. Installing VirtualBox

We need to point our virtual machines on VirtualBox. So, to install the VirtualBox package run the command below:

$ sudo apt install virtualbox

2. Installing Vagrant

The next step is to install the Vagrant package from the Ubuntu repositories by running the following command:

$ sudo apt install vagrant

To get the latest stable version for the Vagrant package, go to the Debian package that is found in Vagrant official download page and download it from there.

3. Verifying Vagrant Installation

Once vagrant is installed successfully on Ubuntu, you need to verify the installation by running the command below:

$ vagrant --version

The output should look like this:

Vagrant 2.0.2

Deploying Vagrant On Ubuntu 18.04

After installing Vagrant on your Ubuntu operating system, you need to create and deploy a development environment.

To do so, start by creating the root directory that contains the Vagrantfile file. This is a file that illustrates the configuration and provision process of the virtual machine.

Create the root directory, then switch it with the following:

$ mkdir ~/my-first-vagrant-project
$cd ~/my-first-vagrant-project

Next, use the vagrant init command to initialize Vagrantfile. Make sure you indicate the box you want to use.

These boxes are Vagrant package format for development environments. To find a full list of the available Vagrant Boxes, go to the Vagrant box catalog page.

In our tutorial, we will use the centos/7 box. To prepare a new Vagrantfile, run the command below:

$ vagrant init centos/7

You should this:

$ A `Vagrantfile` has been placed in this directory. You are now
$ ready to `vagrant up` your first virtual environment! Please read
$ the comments in the Vagrantfile as well as documentation on
$ `vagrantup.com` for more information on using Vagrant.

Next, run the vagrant up command to create and configure the virtual machine based on Vagrantfile.

$ vagrant up

The output should look like this:

$ ==> default: Configuring and enabling network interfaces...
$     default: SSH address:
$     default: SSH username: vagrant
$     default: SSH auth method: private key
$ ==> default: Rsyncing folder: /home/linuxize/Vagrant/my-first-vagrant-project/ => /vagrant

From the results above, it is clear that Vagrant mount the root directory from the project at /vagrant in the virtual machine. This allows the user to work on their files on a host machine.

Run the command below to ssh into the virtual machine:

$ vagrant ssh

To stop your virtual machine, run the command below:

 $ vagrant halt

Running this command should halt the host machine and may destroy all the files that were created before during on your virtual machine:

$ vagrant destroy


Congratulations! You have now installed Vagrant successfully. You can now launch it on your Ubuntu 18.04 machine and start creating a basic development environment within no time.

Check out these top 3 VPS services:

Was this article helpful?