How to Install Vagrant on Debian 11

Vagrant is an open-source software to manage and configure virtualization tools in an automated way; the vagrant was initially started by Mitchell Hashimoto as a personal project. Later, the founder started an organization named as HashiCorp to focus on full time development of Vagrant. The initial release of vagrant provided support to manage VirtualBox only, but it was available for other virtual environment providers like “VMware” and “KVM”. The parent language of vagrant is Ruby; but it can be used in projects that are written in PHP, Python, C#, JavaScript etc.,

In this technologically rich era, sometimes you need to work on several operating systems simultaneously; For this, you may require multiple computing machines that looks impossible to carry them with yourself. Alternatively, there are virtualization tools like VirtualBox that allows you to install multiple OS. For instance, you can install Windows on Linux and vice versa; similarly, Linux on macOS, Windows on macOS. However, while creating virtual machines you may encounter several problems like time consuming, manual configuration; these can be accommodated by using “Vagrant”:

In this descriptive post, we will guide you to install Vagrant on Debian 11; before the installation, let’s describe the importance of Vagrant in abstract way:

How Vagrant is useful for virtualization software users

Virtualization tools: While using tools like VirtualBox, VMware; you have todownload ISO files and then install OS on VM; this process is quite time consuming, as you have to set everything manually.

Vagrant: By using Vagrant, you do not need to download ISO files to install OS; but you need to download Vagrant Boxes (image files) from Vagrant cloud and create virtual machines then. You have to create a vagrant file and then put all the configuration related settings into it; you can further change the memory size, disk size, number of CPU’s etc.

How to install Vagrant on Debian 11

This core part of writing will help you to install Vagrant on Debian 11; for this installation, you must have VirtualBox present on your system or any type 2 hypervisors like VMware workstation, VMware player, Microsoft fusion.

Vagrant can be installed on Debian 11 by following two ways:

  • Method 1: using Debian 11 repository
  • Method 2: using .deb package to install Vagrant

We will provide step by step procedure to both methods:

Method 1: How to install Vagrant on Debian 11 (using apt repository)

This method installs Vagrant from Debian 11 repository; and by following few steps you will be able to do so:

Step 1: Update the packages list

As we are installing through apt repository; so, it is recommended to update the packages list first:

$ sudo apt update

After updating, use the following command to add apt-transport-https package:

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

Step 2: Add the Vagrant repository

You can use the following commands to add GPG key and vagrant repository to your Debian 11 system:

$ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -

Note: The warning in above image shows the depreciation of “apt-key” to add GPG keys; after Debian 11 it will not be available:

$ sudo apt-add-repository “deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main”

Step 3: Installation

After that, update the Debian 11 sytem’s by:

$ sudo apt update 

And now you are ready to install vagrant with the help of below-mentioned command:

$ sudo apt install vagrant 

Verify the installation by checking vagrant’s version:

$ vagrant --version 

Method 2: How to install Vagrant using .deb package on Debian 11

This method will explain the installation method using .deb package from official website of vagrant:

Use the command written below, to download 2.2.18:

Note: At the time of writing this post, the latest available version of vagrant is 2.2.18; however, you can get other versions by navigating to vagrant packages list.

$ wget -O vagrant_2.2.18 https://releases.hashicorp.com/vagrant/2.2.18/vagrant_2.2.18_x86_64.deb

Install the download by using the below stated command:

$ sudo dpkg -i vagrant_2.2.18
vagrant debian

Verify the installation by checking the version of vagrant:

$ vagrant --version 

Note: If in case you encounter a missing dependencies error; you can install them by using the below mentioned command:

$ sudo apt -f install

How to remove Vagrant from Debian 11

If you do not need vagrant anymore on your Debian 11; this section will help you to remove vagrant from your Debian 11 system:

Firstly, you must remove the vagrant programs from “/opt/” folder with the help of command mentioned below:

$ sudo rm -rf /opt/vagrant

Note: If you want to remove it using “apt remove” command; it will ask you to remove vagrant files from “/opt/” directory:

Conclusion

Vagrant is an open-source tool to manage and configure virtual machine environments. With the help of vagrant, you can automate the process of installing an operating system on virtual machines that results in saving time. In this article, we have demonstrated two different ways to install vagrant on Debian 11 system: Method 1 can be followed to install vagrant using apt repository whereas Method 2 is used to install vagrant with the help of .deb package.

Subscribe to Our Newsletter
Join our Newsletter and get the Linux guide and tips
in your inbox for FREE.