In this guide, I’ll take you through different ways to install the latest release of Vagrant on Ubuntu 20.04/18.04, Debian 10 & Kali Linux distributions. Vagrant is an open source tool for building and managing virtual machine environments in an easy-to-use single workflow. Vagrant focuses on automation, lowering development environment setup time and increasing production parity.

Vagrant works with VirtualBox, KVM, Hyper-V, Docker containers, VMware, and AWS. The software is written in Ruby and actively developed by HashiCorp.

Setup Pre-requisite

Note that Vagrant depends on existing hypervisor on your system, this can be VirtualBox, KVM, or VMware. We have the following guides to help you with the installation of these hypervisors

How to install latest VirtualBox on Kali Linux Rolling

How to install the latest VirtualBox on Ubuntu / Debian

Install KVM on CentOS / Ubuntu / Debian / SLES / Arch Linux

Install the latest Vagrant from apt repository

The other method of installing Vagrant on Debian and its derivatives is from an apt repository.

Install repository addition dependencies:

sudo apt update
sudo apt -y install apt-transport-https ca-certificates curl software-properties-common

Add the official Vagrant APT repository to your system:

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"

Once the repo is added, proceed to install vagrant:

sudo apt update
sudo apt install vagrant

Installation should take few seconds to complete:

Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Get:2 http://mirrors.digitalocean.com/ubuntu focal InRelease [265 kB]
Hit:3 https://apt.releases.hashicorp.com focal InRelease
Hit:4 http://mirrors.digitalocean.com/ubuntu focal-updates InRelease
Hit:5 http://mirrors.digitalocean.com/ubuntu focal-backports InRelease
Fetched 265 kB in 1s (340 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  vagrant
0 upgraded, 1 newly installed, 0 to remove and 47 not upgraded.
Need to get 40.9 MB of archives.
After this operation, 115 MB of additional disk space will be used.
Get:1 https://apt.releases.hashicorp.com focal/main amd64 vagrant amd64 2.2.16 [40.9 MB]
Fetched 40.9 MB in 1s (33.4 MB/s)
Selecting previously unselected package vagrant.
(Reading database ... 65336 files and directories currently installed.)
Preparing to unpack .../vagrant_2.2.16_amd64.deb ...
Unpacking vagrant (2.2.16) ...
Setting up vagrant (2.2.16) ...

Install Vagrant from a .deb package

The first and quick method of installing latest Vagrant on Ubuntu 20.04/18.04, Debian 10 and Kali Linux is from .deb package. Check Vagrant Downloads page for the latest release of Vagrant. Here we’ll install v2.2.16

Download the latest release of Vagrant with wget

VER="2.2.16"
wget https://releases.hashicorp.com/vagrant/${VER}/vagrant_${VER}_x86_64.deb

Once the package is downloaded, install the package with the dpkgcommand:

sudo dpkg -i vagrant_${VER}_x86_64.deb

If there are some missing dependencies, run:

sudo apt -f install

Using Vagrant on Ubuntu / Debian / Kali Linux

After the installation, you can check the version:

$ vagrant --version
Vagrant 2.2.16

Download a test Vagrant Box. In this example, I’ll download Kali Linux:

$ vagrant box add offensive-security/kali-linux

To Download Ubuntu 20.04 Vagrant image, use:

$ vagrant box add generic/ubuntu2004 --provide=virtualbox

To launch a VM using Vagrant, you’ll need to create a Vagrantfile. The primary function of the Vagrantfile is to describe the type of machine required for a project, and how to configure and provision a Virtual Machine.

mkdir boxes && cd boxes
touch Vagrantfile

Below is an example of Vagrantfile content

# -*- mode: ruby -*-
# vi: set ft=ruby :

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'

Vagrant.configure("2") do |config|
  ##### DEFINE VM #####
  config.vm.define "ubuntu-01" do |config|
  config.vm.hostname = "ubuntu-01"
  config.vm.box = "generic/ubuntu2004"
  config.vm.box_check_update = true
  end
end

Bring up the VM by running:

$ vagrant up

Then ssh to the instance with

$ vagrant ssh

To shutdown VM, use:

$ vagrant halt

Hibernate VM

$ vagrant suspend

Set VM to initial state by cleaning all data

$ vagrant destroy

That’s all, enjoy using Vagrant and read more on Vagrant Documentation link.

Also read:

Using Vagrant with Libvirt on Linux

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!


As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

LEAVE A REPLY

Please enter your comment!
Please enter your name here