How To Install Vagrant on Ubuntu 20.04 | Easy Steps
In this comprehensive guide, brought to you by Orcacore, we will walk you through the process of How To Install Vagrant on Ubuntu 20.04. Vagrant is a powerful open-source tool designed to streamline the management of development environments. With Vagrant, you can effortlessly create, configure, and manage virtual operating systems through a simple Command Line Interface (CLI). This allows you to quickly set up a development environment, perform your tasks, and then shut it down, ensuring a clean and consistent workspace every time.
Vagrant’s versatility extends to its compatibility with various virtualization engines, including VirtualBox, VMware, and libvirt (commonly used on Linux). To leverage Vagrant’s capabilities, you’ll need one of these virtualization engines installed on your system.
Before we begin, ensure you’re logged into your Ubuntu 20.04 server as a non-root user with sudo privileges. If you haven’t already set this up, you can refer to Orcacore’s guide on the Initial Server Setup with Ubuntu 20.04.
Let’s dive into the steps required to complete the How To Install Vagrant on Ubuntu 20.04 setup.
1. Installing VirtualBox on Ubuntu 20.04
VirtualBox is the default provider for Vagrant, making it an ideal choice for this tutorial. If you don’t have VirtualBox installed yet, you can easily install it using the following commands:
# sudo apt update
# sudo apt install virtualbox -y
These commands will update your package lists and then install VirtualBox along with its dependencies. Once the installation is complete, you’re ready to move on to the next step.
2. Set up Vagrant on Ubuntu 20.04
The recommended way to install Vagrant is by downloading the latest version as a .deb file directly from the official Vagrant website. To find the most recent version, visit the Vagrant Release page and note the version number.
Next, use the curl
command to download the Vagrant package. Make sure to replace 2.4.5
with the actual version number you found on the release page.
sudo curl -O https://releases.hashicorp.com/vagrant/2.4.5/vagrant_2.4.5-1_amd64.deb
After the download finishes, update your local package index to ensure your system recognizes the new package:
sudo apt update
Now, you can install Vagrant using the following command:
sudo apt install ./vagrant_2.4.5-1_amd64.deb
This command will install Vagrant from the downloaded .deb file. To verify that Vagrant has been installed correctly, check its version:
vagrant --version
You should see output similar to this:
**Output**
Vagrant 2.4.5
This confirms that Vagrant has been successfully installed on your Ubuntu 20.04 system. Now that you know How To Install Vagrant on Ubuntu 20.04, let’s explore how to use it.
3. Create a Vagrant Project on Ubuntu 20.04
Now, let’s create a simple Vagrant project to demonstrate how to use Vagrant for development environment management.
First, create a directory for your Vagrant project:
mkdir ~/vagrant-project
Next, you need to initialize a new Vagrantfile and specify the "box" you want to use. Boxes are pre-packaged operating system images that serve as the foundation for your Vagrant environment. You can find a wide variety of available boxes on the Vagrant Catalog page.

In this example, we’ll use the ubuntu/trusty64
box, which is an older but stable Ubuntu version. Navigate to your Vagrant project directory:
cd ~/vagrant-project
Now, initialize the Vagrantfile with the following command:
vagrant init ubuntu/trusty64
You should see output similar to:
The vagrant init
command creates a Vagrantfile in your project directory. You can open this file with your favorite text editor and customize it to suit your specific development needs.
To create and configure the virtual machine based on the settings in your Vagrantfile, run the following command:
vagrant up
**Output**
==> default: Configuring and enabling network interfaces...
...
Vagrant automatically mounts your project directory at /vagrant
within the virtual machine. This allows you to seamlessly work on your project files on your host machine while the code executes within the virtual environment.
To access your virtual machine via SSH, use the following command:
vagrant ssh
This will log you into the virtual machine’s command line.
To stop the virtual machine, use the following command:
vagrant halt
This will gracefully shut down the virtual machine.
If you want to completely remove the virtual machine and all associated resources, use the following command:
vagrant destroy
This will permanently delete the virtual machine and free up the resources it was using.
Alternative Solutions to Installing Vagrant
While the official .deb package method is generally recommended, here are two alternative approaches you can use to How To Install Vagrant on Ubuntu 20.04:
1. Using the apt Package Manager (Potentially Outdated)
Ubuntu’s default repositories often contain a version of Vagrant. However, it’s crucial to note that this version might not be the latest. If you’re comfortable using an older version, you can install Vagrant using apt
:
sudo apt update
sudo apt install vagrant
After installation, verify the version using vagrant --version
. Be aware that if the version is significantly older than the latest release, you might miss out on new features and bug fixes. This method simplifies the installation process, but it prioritizes ease of use over having the most up-to-date software.
2. Using Snap Package Manager
Snap is a package management system developed by Canonical, the company behind Ubuntu. It offers a convenient way to install applications and their dependencies. To install Vagrant using Snap, use the following command:
sudo snap install vagrant
Snap packages are containerized, meaning they include all their dependencies and run in a sandboxed environment. This can lead to increased stability and isolation. Verify the installation with vagrant --version
. Snap packages are automatically updated, ensuring you receive the latest features and security patches. However, the sandboxed environment might introduce compatibility issues in some cases, and Snap packages can sometimes consume more disk space compared to traditional .deb packages.
Conclusion
In this tutorial, you’ve learned How To Install Vagrant on Ubuntu 20.04 using the recommended method of downloading and installing the .deb package. You also explored creating a simple Vagrant project and managing the virtual machine. Vagrant offers a powerful and efficient solution for managing virtual development environments, promoting consistency and simplifying project setup. Furthermore, you are also provided with two other alternative methods.
We hope you found this guide helpful. You might also be interested in these related articles: