Virtualization tools are necessary for the creation and management of virtual machines. In this sense, managing them can be done quickly and easily thanks to Vagrant. So today you will learn how to install Vagrant on Ubuntu 20.04 either from the official repositories or from the program’s website.
Introduction to Vagrant
Vagrant is a free command-line tool, available for Windows, macOS X, and GNU/Linux, that allows you to generate reproducible and sharable development environments in a very easy way. All this from virtual machines such as Virtualbox, KVM, or Docker.
The great advantage of a vagrant is that it has a configuration file Vagrantfile where all the configuration of the VM we create is centralized. This means that you can share the file and the other user will have the same environment as you. This is especially useful in teams, as it ensures that everyone has the same environment, with the same dependencies and configuration.
As great as it is, Vagrant is not intended for working with large numbers of virtual machines, for more complex infrastructures there are other tools.
Install Vagrant on Ubuntu 20.04
As Vagrant is a well-known tool for virtual machine management, it is available from the repositories. However, we can also choose another method that gives us the possibility to get the latest stable version.
Method 1: Install Vagrant using the official repositories
This method is the easiest and safest but does not provide the latest stable version. So the decision is up to you.
To do so, just open a terminal or connect via SSH.
Then update the operating system:
sudo apt update sudo apt upgrade
After that, you can install Vagrant, by running:
sudo apt install vagrant
In the end, you can display the installed version
Now you can use Vagrant.
Method 2: Getting the latest version of Vagrant on Ubuntu 20.04
If you want to have the latest stable version available, you just have to know which is the latest stable version and run
Replace the version number with the latest version so that the command can be executed. At the time this post is being published, the latest stable version is
Then proceed with the installation as if it were a regular DEB package.
sudo apt install ./vagrant_2.2.14_x86_64.deb
Then, check the installed version to verify that the command is working:
First steps with Vagrant
Using Vagrant is easier than you might think because it is based on well-documented commands.
First, create a new folder where the Vagrant project will be hosted.
Of course, you can replace the name
vagrant_example with any name you want.
Then, access the newly created folder.
To start Vagrant and thus the project itself, run the command
vagrant and the subcommand
init together with the image of your choice.
These images are many and you can consult the catalog at this link.
For our example, we will use CentOS 8
vagrant init centos/8
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 vagrantup.com for more information on using Vagrant.
With this command, you also create a Vagrantfile that you can modify and revise as you wish.
To start the virtual machine, just run the following command:
And to access via SSH to the virtual machine, you have to execute the following command:
If you want to shut it down:
Once you shut it down, you can restart it with the command
Or to remove it and its contents:
This way you can use Vagrant.
In this post, you have learned how to install and take the first steps with Vagrant in an Ubuntu 20.04 environment. Vagrant is a tool designed to perform operations within a professional environment where it is required to improve the management of virtual machines.
So, what do you think about Vagrant? did you know it? do you like it? Leave us a comment and share this post
More information in the official Vagrant documentation.