How to Install Vagrant on Ubuntu Linux

This post shows students and new users steps to install and use Vagrant on Ubuntu Linux Vagrant is a tool for building and managing virtual machine environments via the command line. Out of the box, Vagrant supports VirtualBox, VMware, AWS, and also works with other virtualization software providers to provision virtual machines.

Vagrant is great for developers as it isolates machine dependencies and their configurations within a single disposable, consistent environment, so whether you are working on Linux, Mac OS X, or Windows, everyone will be running the same code in the same environment, against the same dependencies and configured the same way.

For this post, we’ll be using the VirtualBox as our virtualization platform which is also the default provider for Vagrant.

Also, for students and new users learning Linux, the easiest place to start learning is on Ubuntu Linux. Ubuntu is the modern, open source Linux operating system for desktop, servers and other devices.

When you’re ready to install and use Vagrant on Ubuntu Linux, follow the steps below.

How to install VirtualBox on Ubuntu

Since we’re going to be using VirtualBox as our provider, let’s go and install it on Ubuntu Linux. You can simply run the apt get command to install VirtualBox. However, we’re written a detailed post on how to install and configure VirtualBox on Ubuntu.

Read that post instead, then continue below to installing Vagrant on Ubuntu Linux.

How to install VirtualBox on Ubuntu Linux

After reading the post above and installing VirtualBox, continue below.

How to install Vagrant on Ubuntu Linux

At the time of writing this post, the latest stable version of Vagrant is version 2.2.18. You can check the Vagrant Download page to see if a newer version is available to use instead.

First, update Ubuntu package index using the commands below.

sudo apt update

Then download Vagrant package using the curl command below with the download link to version 2.2.18.

curl -O 

Once the .deb file is downloaded, install it by typing:

sudo apt install ./vagrant_2.2.18_x86_64.deb

Now that Vagrant is installed let’s go and create a development environment on your Ubuntu Linux machine.

The first step is to create a directory to be used as our project directory to hold Vagrant files. Vagrant file is a Ruby file that describes how to configure and provision the virtual machine.

mkdir ~/vagrant-project
cd ~/vagrant-project

With your Vagrant project folder created, run the commands below to initialize a new Vagrant file using the vagrant init command and specify the Linux box to use.

For this tutorial, we’re going to be using Ubuntu Linux 20.04 64bit.

vagrant init ubuntu/bionic64

When you run the commands above, you’ll get similar message as below with some details of the configurations settings.

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.

Next, run the vagrant up command to create and configure the virtual machine as specified in the Vagrantfile:

vagrant up

You should see Vagrant build process started. It should download Ubuntu ISO image and setup the environment for it based on its default configuration settings for Ubuntu 20.04.

Wait for the setup to complete and start using the your environment.

To ssh into the virtual machine, run:

vagrant ssh

You can stop the virtual machine with the following command:

vagrant halt

To complete delete or destroy the virtual machine, run the commands below:

vagrant destroy

That should do it!


This post showed you how to install and use Vagrant on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.