Home Ubuntu How to install Vagrant on Ubuntu 22.04

How to install Vagrant on Ubuntu 22.04

by Emmanuel
vagrant on ubuntu

Vagrant is an open-source software used to manage and generate different virtual environments using virtualization techs such as VirtualBox, VMware, and more. It simplifies the config management of virtual machines to boost productivity with the aid of provisioners. Provisioners fundamentally permits the customization of the configuration of virtual machines.

Vagrant gives many development environments to DevOps, allowing the developers to work beyond several operating systems. One exciting feature of Vagrant is that you can install this tool on nearly all Linux distros. It is essential to know that Vagrant is a command-line generated tool.

Also, you must ensure that you have a virtualization engine like Hyper-V, VirtualBox, or Docker setup on your system since you cannot run the Vagrant tools without virtualization software. The Vagrant plugin system also supports KVM and VMware.

Installing Vagrant on Ubuntu 22.04

With that covered, let us get the article going to find out how we can set up Vagrant on our Ubuntu 22.04 system using VirtualBox as a virtualization hypervisor.

Prerequisites

The virtual machine is needed to install Vagrant. In this case, you can choose any virtual machine, from Hyper-V, Docker, VirtualBox, to VMware, but in our instance, we will be using VirtualBox in this tutorial. Alternatively, if you are a VMware fanatic and need guidance on installing VMware on Ubuntu, you can visit our other published article.

VirtualBox

VirtualBox is a cloud computing virtualization tech software that allows one to run multiple applications and OS workloads on one server, enabling better resource management by crafting a virtual machine that behaves precisely like an actual computer. If you haven’t set up VirtualBox on your Ubuntu system, here is a detailed post on how to get it done.

This article will focus on three methods of installing Vagrant on Ubuntu 22.04:

  • Using apt
  • Using apt-get
  • Using aptitude

Let us get the article underway.

Method 1: How to setup Vagrant on Ubuntu 22.04 using apt

You can quickly achieve the installation of Vagrant on Ubuntu in a pretty straightforward way by following the given steps:

Step 1: Update Ubuntu packages

First things first, update the system repo to the latest versions. To do this, open your terminal by hitting the “CTRL+ALT+T” shortcut keys together and issue the following update command:

sudo apt update
update system

Update system

Step 2: Upgrade Ubuntu packages

Once you run the update command, you will be alerted of the number of packages that require an upgrade at the end of the update command. This tells you that the mentioned number of packages have released newer versions. To upgrade them, run the following command, and remember that you can skip this step once you find out that all of your packages are up to date:

sudo apt upgrade
upgrade system

upgrade system

Step 3: Install VirtualBox

Next up, we will install VirtualBox on our system using the following command:

sudo apt install virtualbox
install virtualbox

install VirtualBox

Step 4: Install Vagrant

After you are done installing VirtualBox, it is time to download the Vagrant deb package by running the following command on your terminal:

wget https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_x86_64.deb
download vagrant

Download vagrant

Subsequently, use the following command to install the deb package from the apt installer:

sudo apt install ./vagrant_2.2.19_x86_64.deb
install vagrant

install Vagrant

Step 5: Verify Vagrant installation

Here, we will run the check version command to ascertain whether or not we successfully installed Vagrant on our Ubuntu system.
vagrant --version
vagrant version

vagrant version

The above output explicitly tells that Vagrant is successfully set up on our Ubuntu system.

Here are the complete details of the vagrant package:

Package: vagrant
Architecture: all
Version: 2.2.19+dfsg-1ubuntu1
Priority: optional
Section: universe/admin
Origin: Ubuntu
Maintainer: Ubuntu Developers
Original-Maintainer: Debian Ruby Team
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 3476
Depends: libarchive-tools, curl, openssh-client, rsync, ruby, ruby-bcrypt-pbkdf, ruby-childprocess, ruby-ed25519, ruby-erubi, ruby-i18n, ruby-listen, ruby-log4r, ruby-mime-types, ruby-net-ssh, ruby-net-sftp, ruby-net-scp, ruby-rexml, ruby-zip, ruby-vagrant-cloud
Recommends: vagrant-libvirt
Suggests: virtualbox (>= 4.0)
Breaks: virtualbox (>= 6.2)
Filename: pool/universe/v/vagrant/vagrant_2.2.19+dfsg-1ubuntu1_all.deb
Size: 473364
MD5sum: 8295ce230e36e17a3a60f65a514e717c
SHA1: 92a370b18cff0be7ff54be9ef1be69a7f84b0331
SHA256: 4ef003a92282a98d01e12f6f368413ee4f08b995af457d64bfc375ba9fc9d71f
SHA512: b487fabc8f7fe3bba6de5b7a12cb7a6af54a5e75a8017990e7e7aa7b8dba9b4eeba1e0880fcfa5f914777e06c56f8d159ed174cba1c3d827814856b71d2ca79c
Homepage: https://www.vagrantup.com
Description: Tool for building and distributing virtualized development environments
Description-md5: aeaa276f3844f8ad6c87b93eb0f56ea5
Ruby-Versions: all

Method 2: How to install Vagrant on Ubuntu using apt-get

As usual, update the apt database using apt-get by issuing the following command:
sudo apt-get update
apt get update command

Apt-get update command

Then upgrade the packages if there are any that need to be upgraded using the following command:

sudo apt-get upgrade
apt get upgrade command

Apt-get upgrade command

After updating and upgrading the apt database, proceed further and install Vagrant using apt-get by running this command:

sudo apt-get -y install vagrant
apt get to install vagrant

Apt-get to install Vagrant

Method 3: How to install Vagrant using aptitude

If you prefer this method, you might need to set up aptitude first, as it does not come pre-installed by default on Ubuntu. To install aptitude, run the following command:
sudo apt install aptitude
install aptitude

install aptitude

Once aptitude is  setup, run the following command to update the apt database using the aptitude command:

sudo aptitude update
aptitude update

aptitude update

Once the update process of apt is done, you can now go ahead and install Vagrant using aptitude by running the following command:

sudo aptitude -y install vagrant
aptitude install vagrant

aptitude install vagrant

Now that the installation process is done, let us turn our focus and look at how we can put this special software into action.

How to use Vagrant on Ubuntu 22.04

After the successful installation, you might ask yourself how to get his software up and running on your system; however, you need not worry anymore because we’ve got you covered. Here are the step-by-step guidelines to get this right.
Step 1: First, we will create a project directory using the following syntax:
mkdir ~/project_name
Where:
mkdir ~/fosslinux_project
make directory called fosslinux

Make a directory called fosslinux

Note: Ensure you replace the “project_name” with your preferred project name to avoid errors.

Step 2: Next, maneuver to the recently created directly by issuing the following command:
cd ~/fosslinux_project
navigate to the directory

Navigate to the directory

Step 3: Visit the Vagrant official website and select your VagrantBox (built-in virtual environment image of your operating system). In our instance, we chose “debian/jessie64.” After that, run the following command:

vagrant init debian/jessie64
create vagrant file

Create vagrant file

Step 4: Next, we need to create and configure the virtual machine. To do this, run the following command:

vagrant up
vagrant is up

Vagrant is up

The above-given command will append the selected “debian/jessie64” to your VirtualBox environment, as shown in the final image below:

setting up jessie64

setting up jessie64

To have a glimpse, open the VirtualBox on your Ubuntu system as displayed in the snapshot below:

fosslinux project created

fosslinux_project created

In this way, you have the flexibility of appending any other OS environments on any given virtual machine via Vagrant on your Ubuntu system 22.04.
That is covered; let us now look at how we can uninstall Vagrant on Ubuntu 22.04. Here, we will focus on four different methods:
  • How to uninstall Vagrant on Ubuntu.
  • How to uninstall Vagrant and its dependencies.
  • How to uninstall vagrant configurations and Data.
  • How to uninstall vagrant configurations, data, and all of its dependencies.
Let us get going.

How to uninstall Vagrant on Ubuntu 22.04

If you, for one reason or the other, want to uninstall Vagrant from your Ubuntu system, then here are some of the methods you can use to get this done.
To only uninstall the vagrant package, use the following command:
sudo apt-get remove vagrant
get remove vagrant

get-remove vagrant

Let us now emphasize how we can uninstall Vagrant and its dependencies.

How to uninstall Vagrant and its dependencies
To uninstall Vagrant plus its dependencies that are ideally not needed by your ubuntu system, use the following command:
sudo apt-get -y autoremove vagrant
autoremove command

autoremove command

Let us also take you via the method needed to remove vagrant configurations and Data.

How to uninstall vagrant configurations and data
To do away with vagrant configurations and data from your Ubuntu 22.04, you can use the following command:
sudo apt-get -y purge vagrant
purge command

purge command

Finally, let us see how we can remove vagrant configs, data, and all of its dependencies from our Ubuntu system.

How to uninstall vagrant configuration, data, and all of its dependencies
Here, you can use the following command to completely do away with configurations, data, and all of its dependencies:
sudo apt-get -y autoremove --purge vagrant
autoremove purge command

autoremove purge command

At this point, Vagrant should be removed from the system, plus configurations, data, and all of its dependencies.

Final Thoughts

Vagrant is available on the official repo of Ubuntu 22.04 and can also be installed via other methods like apt, apt-get, and aptitude, which we covered well in this post. Vagrant needs a virtualization tool to play around with virtual machines. This post is ideally focused on guiding you on the steps necessary for you to get Vagrant on your Ubuntu version 22.04 without messing.
Furthermore, the post provided several methods to uninstall Vagrant, uninstall Vagrant and its dependencies, uninstall vagrant configurations and Data, and finally, uninstall vagrant configurations and data and all of its dependencies. We hope this came in handy for those looking for how to install and uninstall Vagrant; Otherwise, keep following FOSSLinux for more.

You may also like

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.