How to install Vagrant on Ubuntu 20.04

Vagrant is a command line tool for creating and managing virtual machines.

By default, Vagrant can provision computers on top of VirtualBox, Hyper-V, and Docker. Other vendors such as Libvirt (KVM), VMware and AWS can be installed through the Vagrant plugin system.

Vagrant is commonly used by developers to set up a development environment that runs on multiple operating systems.

This article describes how to install Vagrant on an Ubuntu 20.04 machine. We will be using VirtualBox, which is the default provider for Vagrant.

Installing Vagrant on Ubuntu

We will provide virtual machines on top of VirtualBox.

If VirtualBox is not installed on your system, you can install it by running:

sudo apt update
sudo apt install virtualbox

The Vagrant package that is available in the Ubuntu repositories is not regularly updated. We will download and install the latest version of Vagrant from the official Vagrant site.

At the time of this writing, the latest stable release of Vagrant is version 2.2.9. Visit the Vagrant downloads page to see if a new version of Vagrant is available.

Download Vagrant package from wget:

curl -O

Once the file is downloaded, install it by typing:

sudo apt install ./vagrant_2.2.9_x86_64.deb

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

vagrant --version

The output should look something like this:

Vagrant 2.2.9

Getting started with Vagrant

Creating a Vagrant project is as easy as setting up your project root and defining a Vagrant file.

Run the following commands to create a directory and navigate to it with:

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

Next, initialize the new Vagrantfile with vagrant init and then specify the field you want to use.

Boxes are a package format for Vagrant environments and are vendor specific. You can find a list of public Vagrant boxes on the Vagrant boxes catalog page.

For this example, we will use centos / 8:

vagrant init centos/8
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.

Vagrantfile is a Ruby file that describes how to set up and prepare a virtual machine. You can open the Vagrantfile, read the comments and make changes according to your needs.

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-vagrant-project/ => /vagrant

Vagrant mounts the project directory in the / vagrant virtual machine. This allows you to work with your project files on the host computer.

To enter the virtual machine, run:

vagrant ssh

You can stop the virtual machine with the following command:

vagrant halt

To destroy all resources created when the machine was created, enter:

vagrant destroy


We have shown how to install Vagrant on Ubuntu 20.04 and create a basic Vagrant project.

If you have any questions, please leave a comment below.