Install and Run Vagrant on Ubuntu 20.04

A Vagrant is a command-line tool for building and managing virtual machines. By default, Vagrant can provision machines on top of VirtualBox, Hyper-V, and Docker. Other providers such as Libvirt (KVM), VMware, and AWS can be installed via the Vagrant plugin system. Vagrant is typically used by developers to set up a development environment that works across multiple operating systems.

Here at LinuxAPT, we will look into how to install Vagrant on Ubuntu 20.04 LTS.


Steps to install Vagrant on Ubuntu 20.04 LTS Focal Fossa

1. Perform System Update

To begin, ensure that all your system packages are up-to-date by running the following apt-get commands in the terminal:

$ sudo apt update
$ sudo apt upgrade


2. Install VirtualBox

You can Install Virtualbox using the following command:

$ sudo apt install virtualbox


3. Install Vagrant on the system

First, download the latest stable version of Vagrant. Visit the Vagrant downloads page to see if there is a new version of Vagrant available:

$ curl -O https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb

Once the file is downloaded, install using the following command:

$ sudo apt install ./vagrant_2.2.9_x86_64.deb

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

$ vagrant --version


How to Deploy your development environment with Vagrant ?

You can create a Vagrant project is as simple as setting up the project root directory and defining a Vagrantfile. Run the following commands to create the directory:

$ mkdir ~/my-project
$ cd ~/my-project

Next, initialize a new Vagrantfile using the vagrant init command, followed by the box you want to use. In this example, we will use the centos/8 box:

$ vagrant init centos/8

Run the vagrant up the command to create and configure the virtual machine as specified in the Vagrantfile:

$ vagrant up

To ssh into the virtual machine, run:

$ vagrant ssh

You can stop the virtual machine with the following command:

$ vagrant halt

To destroy all resources created during the creation of the machine, enter:

$ vagrant destroy


How To Uninstall vagrant on Ubuntu 21.10 ?

To uninstall only the vagrant package we can use the following command:

$ sudo apt-get remove vagrant

We can use the following command to remove vagrant configurations, data and all of its dependencies, we can use the following command:

$ sudo apt-get -y autoremove --purge vagrant


[Need help in fixing Linux VirtualBox issues ? We can help you. ]

This article covers how to install the Vagrant virtual development environment on your Ubuntu 20.04 LTS Focal Fossa system. In fact, Vagrant is a command-line tool for building and managing virtual machines. To use Vagrant, you must have a virtualization engine like VirtualBox, Hyper-V, or Docker installed on your system. The Vagrant plugin system also provides support for KVM and VMware. 

Related Posts