Hamsa K
Editor
6 min read | 3 years ago

How to Install Vagrant on Ubuntu 20 04

Install vagrant on ubuntu 20.04

Vagrant is an open-source software product for building and maintaining portable virtual software development environments. For example VirtualBox, KVM, Hyper-V, Docker containers, VMware, and AWS. It tries to simplify the software configuration management of virtualization in order to increase development productivity.

This article describes on how to install Vagrant on an Ubuntu 20.04 system.

First we will update the packages by using apt.

sudo apt update

Next, we will install VirtualBox in the Ubuntu 20.04 system.

sudo apt install virtualbox

once it is installed, we will install vagrant with the following commands.

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install vagrant

Also Read -> How to Install CouchDB on Ubuntu 20 04

output:

Reading state information... Done
The following NEW packages will be installed:
  vagrant
0 upgraded, 1 newly installed, 0 to remove and 194 not upgraded.
Need to get 40.9 MB of archives.
After this operation, 115 MB of additional disk space will be used.
Get:1 https://apt.releases.hashicorp.com focal/main amd64 vagrant amd64 2.2.16 [40.9 MB]
Fetched 40.9 MB in 5min 33s (123 kB/s)
Selecting previously unselected package vagrant.
(Reading database ... 92635 files and directories currently installed.)
Preparing to unpack .../vagrant_2.2.16_amd64.deb ...
Unpacking vagrant (2.2.16) ...
Setting up vagrant (2.2.16) ...

you can check vagrant version with the following command.

vagrant --version

output:

Vagrant 2.2.16

Also Read -> How to Install Wine on Ubuntu 20 04

creating vagrant project

First, we will create a new folder where the Vagrant project will be hosted and access newly created folder as below.

mkdir myvagrantproject
cd myvagrantproject

Now, we need to initialize a new Vargantfile using vagrant init command.Once, you have selected a name of your choice, enter the following command 

vagrant init centos/8

output:

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.

you can also create a Vagrantfile that you can modify and revise as your wish.

Now you can start virual machine with following command.

vagrant up

sample output:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'centos/8'
    default: URL: https://vagrantcloud.com/centos/8
==> default: Adding box 'centos/8' (v2011.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/centos/boxes/8/versions/2011.0/providers/virtualbox.box
Download redirected to host: cloud.centos.org
    default: progress 1% (Rate: 240k/s, Estimated time remaining: 2:18:35)

Also Read -> How to Install Atom Text Editor on Ubuntu 20 04

Vagrant will then mount your newly created project directory at /vagrant path of Ubuntu 20.04 virtual machine.

Now you have successfully installed vagrant on ubuntu 20.04 system.

useful commands:

To ssh in the virtual machine,use the following command.

vagrant ssh

To stop the virtual machine use halt.

vagrant halt

To remove virtual machine,use below command.

vagrant destroy

That's it. you have successfully learned how to install vagrant on ubuntu system

Also Read -> How to Install Python 3 9 on Ubuntu 20 04



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy