How to install Vagrant on Ubuntu 18.04

s2 0

is a command line tool used to create and manage virtual machine environments. By default, Vagrant can provision machines in addition to VirtualBox, Hyper-V and Docker. Other providers such as Libvirt (KVM), VMware and AWS can be installed via the Vagrant plug-in system.

Vagrant is typically used by developers to set up a development environment that matches the production environment.

In this tutorial, we are going to show you how to install Vagrant on an Ubuntu 18.04 computer. We use the VirtualBox provider, which is the standard provider for Vagrant. The same steps can be used for Ubuntu 16.04 Xenial Xerus.


Before proceeding with this tutorial, make sure that you are logged in as a user with sudo permissions.

Install Vagrant on Ubuntu

To install Vagrant on your Ubuntu system, do the following:

1. Install VirtualBox

As mentioned in the introduction, we will be provisioning the machines on VirtualBox, so the first step is to install the VirtualBox package available in the Ubuntu repositories:

sudo apt install virtualbox

If you want to install the latest VirtualBox version from the Oracle repositories, check out this tutorial.

2. Installation of Vagrant

The Vagrant package available in Ubuntu’s repositories is quite out of date. We will download and install the latest version of Vagrant from the official Vagrant website.

At the time of this writing, the latest stable release of Vagrant is version 2.2.6. Before proceeding with the next steps, check the Vagrant download page
to see if a newer version is available.

Start updating the package list with:

sudo apt update

Download the Vagrant package as follows curl

curl -O

As soon as the .deb File is downloaded, install it by typing:

sudo apt install ./vagrant_2.2.6_x86_64.deb

3. Check the Vagrant installation

To verify that the installation was successful, run the following command which will print out the Vagrant version:

vagrant --version

The output should look something like this:

Vagrant 2.2.6

Getting started with Vagrant

Now that Vagrant is installed on your Ubuntu system, let’s create a development environment.

The first step is to create a directory that will be the root of the project and that will contain the Vagrantfile file. Vagrantfile is a Ruby file that describes how to configure and provision the virtual machine.

Create the project directory and switch to it with:

mkdir ~/my-first-vagrant-projectcd ~/my-first-vagrant-project

Next, initialize a new Vagrantfile with the vagrant init Command and specify the box you want to use.

Boxes are the package format for the Vagrant environments and are provider-specific. A list of the publicly available Vagrant boxes can be found on the Vagabond Box Catalog

In this example we are using the centos/7 Crate. Run the following command to initialize a new Vagrantfile:

vagrant init centos/7
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
`` for more information on using Vagrant.

You can open it Vagrantfile
, read the comments and make adjustments as needed.

Run the vagrant up Command to create and configure the virtual machine as specified in the Vagrantfile:

vagrant up
==> 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

Vagrant also mounts the project directory /vagrant in the virtual machine that allows you to work on your project’s files on your host computer.

To SSH the virtual machine, do the following:

vagrant ssh

You can stop the virtual machine with the following command:

vagrant halt

The following command will stop the machine if it is running and destroy any resources that were created during the creation of the machine:

vagrant destroy


You learned how to install and use Vagrant on your Ubuntu 18.04 computer. We also showed you how to create a basic development environment.

For more information on Vagrant, visit the official Hiking documentation

If you have any questions please leave a comment below.