Vagrant is great for developers as it isolates machine dependencies and their configurations within a single disposable, consistent environment, so whether you are working on Linux, Mac OS X, or Windows, everyone will be running the same code in the same environment, against the same dependencies and configured the same way. For this post, we’ll be using VirtualBox as our virtualization platform which is also the default provider for Vagrant. Also, for students and new users learning Linux, the easiest place to start learning is Ubuntu Linux. Ubuntu is the modern, open-source Linux operating system for desktops, servers, and other devices. When you’re ready to install and use Vagrant on Ubuntu Linux, follow the steps below.

How to install VirtualBox on Ubuntu

Since we’re going to be using VirtualBox as our provider, let’s go and install it on Ubuntu Linux. You can simply run the apt-get command to install VirtualBox. However, we’re written a detailed post on how to install and configure VirtualBox on Ubuntu. Read that post instead, then continue below to install Vagrant on Ubuntu Linux. How to install VirtualBox on Ubuntu Linux After reading the post above and installing VirtualBox, continue below.

How to install Vagrant on Ubuntu Linux

At the time of writing this post, the latest stable version of Vagrant is version 2.2.18. You can check the Vagrant Download page to see if a newer version is available to use instead. First, update the Ubuntu package index using the commands below. Then download the Vagrant package using the curl command below with the download link to version 2.2.18. Once the .deb file is downloaded, install it by typing: Now that Vagrant is installed let’s go and create a development environment on your Ubuntu Linux machine. The first step is to create a directory to be used as our project directory to hold Vagrant files. The vagrant file is a Ruby file that describes how to configure and provision the virtual machine. With your Vagrant project folder created, run the commands below to initialize a new Vagrant file using the vagrant init command and specify the Linux box to use. For this tutorial, we’re going to be using Ubuntu Linux 20.04 64bit. When you run the commands above, you’ll get a similar message as below with some details of the configuration settings. Next, run the vagrant up command to create and configure the virtual machine as specified in the Vagrantfile: You should see the Vagrant build process started. It should download the Ubuntu ISO image and set up the environment for it based on its default configuration settings for Ubuntu 20.04. Wait for the setup to complete and start using your environment. To ssh into the virtual machine, run: You can stop the virtual machine with the following command: To completely delete or destroy the virtual machine, run the commands below: That should do it! Conclusion: This post showed you how to install and use Vagrant on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.