How to Install Vagrant on Ubuntu 20.04

Install Vagrant on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure Vagrant on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Vagrant is a command-line tool for building and managing virtual machines. It is built on top of VirtualBox and VMWare, and it provides many exciting capabilities. You can create isolated development environments, experiment with new products and technologies, install new versions of existing packages, create your own private data center on your laptop, and run different operating systems. All that is available in an easy-to-manage and totally safe silo that can’t interfere with your main activities and operating system.

Install Vagrant on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Install VirtualBox.

To install the VirtualBox package run the commands below:

sudo apt install virtualbox

Step 3. Install Vagrant on Ubuntu.

Now that VirtualBox is installed, run the commands below to install Vagrant:

sudo apt install vagrant

Once vagrant is installed successfully on Ubuntu, you need to verify the installation:

vagrant --version

Step 4. Setup Vagrant Environment.

To setup Vagrant project environment, run the commands below to create a project folder in your home directory:

mkdir ~/my-vagrant-project-start
cd ~/my-vagrant-project-start

Next, download and install your operating system (Vagrant Box) of choice. For example, this command will install the CentOS 8 system:

vagrant init centos/8

Then, create and configure the virtual machine according to the Vagrantfile with:

vagrant up

The system should show the default SSH address, username, and authentication method for the new virtual machine. To ssh into the virtual machine simply run:

vagrant ssh

You can stop the virtual machine using the following command:

vagrant halt

To delete the virtual machine, use the command:

vagrant destroy

That’s all you need to do to install Vagrant on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. Don’t forget to share your valuable queries/suggestions in the below comment box & also drop your worthwhile feedback.