How to install vagrant on Ubuntu 22.04

Installing Vagrant on Ubuntu: Step-by-Step Guide

Vagrant is a powerful tool that allows developers to create and manage virtualized development environments with ease. It provides a way to quickly set up and configure virtual machines, making it easier to collaborate on projects and ensure consistent development environments across different machines. In this article, we will walk you through the process of installing Vagrant on Ubuntu.

Step 1: Update System Packages

Before installing Vagrant, it’s always a good idea to update your system’s package manager. Open a terminal and run the following command:

sudo apt update

Step 2: Install VirtualBox

Vagrant requires a virtualization software to create and manage virtual machines. One popular option is VirtualBox. Install it by running the following command:

sudo apt install virtualbox

The discussion regarding the installation of VirtualBox has been discussed in the How to Install VirtualBox 7 on Ubuntu 22.04 : A Step-by-Step Guide article.

Step 3: Download and Install Vagrant

To install Vagrant, you need to download the installation package from the official website. Open your web browser and visit the Vagrant downloads page at Select the appropriate package for your Ubuntu version (e.g., 64-bit or 32-bit) or by wget command line from the console we will download it by using command line :

$ wget -O- | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

Output is as shown below :

ramans@dev01:~$ wget -O- | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
--2023-07-02 18:59:02--
Resolving (,,, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3980 (3,9K) [binary/octet-stream]
Saving to: ‘STDOUT’

- 100%[=======================================>] 3,89K --.-KB/s in 0,01s

2023-07-02 18:59:03 (381 KB/s) - written to stdout [3980/3980]
ramans@dev01:~$ echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] jammy main

Once the download is complete, navigate to the directory where the package is saved (usually the Downloads folder) and open a terminal. Run the following command to install Vagrant:

$ sudo apt install vagrant

The output will be as shown below :

ramans@dev01:~$ sudo apt install vagrant
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 149 MB of archives.
After this operation, 383 MB of additional disk space will be used.
Get:1 jammy/main amd64 vagrant amd64 2.3.7-1 [149 MB]
Fetched 149 MB in 1min 17s (1.935 kB/s) 
Selecting previously unselected package vagrant.
(Reading database ... 291161 files and directories currently installed.)
Preparing to unpack .../vagrant_2.3.7-1_amd64.deb ...
Unpacking vagrant (2.3.7-1) ...
Setting up vagrant (2.3.7-1) ...

Step 4: Verify the Installation

After the installation is complete, you can verify that Vagrant is installed correctly by running the following command:

vagrant --version

This command should display the installed version of Vagrant, confirming that the installation was successful.

ramans@dev01:~$ vagrant --version
Vagrant 2.3.7

Step 5: Install Vagrant Plugins (Optional)

Vagrant supports plugins that provide additional functionality and integration with other tools. While not necessary, you may find plugins useful for your specific needs. To install a Vagrant plugin, use the following command:

vagrant plugin install <plugin-name>

Replace <plugin-name> with the name of the desired plugin.

Step 6: Start Using Vagrant

With Vagrant successfully installed, you can start creating and managing virtual environments for your projects. Create a new directory for your project, navigate to that directory in the terminal, and run the following command to initialize a Vagrant environment:

vagrant init

Output :

ramans@dev01:~/bckinfo_project$ vagrant init
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
`` for more information on using Vagrant.

This command will create a Vagrantfile in the current directory, which you can customize to define the configuration of your virtual machine.

Step 7: Managing Vagrant Environments

Vagrant provides a set of commands to manage your virtual environments. Some commonly used commands include:

vagrant up: Start and provision the virtual machine defined in the Vagrantfile.
vagrant halt: Stop the virtual machine.
vagrant destroy: Delete the virtual machine.
vagrant ssh: SSH into the virtual machine.
vagrant suspend: Pause the virtual machine's execution.
vagrant resume: Resume a previously suspended virtual machine.


Installing Vagrant on Ubuntu is a straightforward process that allows you to create and manage virtual development environments effortlessly. By following the steps outlined in this article, you can get Vagrant up and running on your Ubuntu machine and begin leveraging its power to streamline your development workflow. Happy virtualization!

(Visited 118 times, 1 visits today)


No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *