If your team needs identical development environments across different operating systems, Vagrant is the tool that makes it effortless. Vagrant is a command-line tool by HashiCorp for building and managing virtual machines in a reproducible, shareable way. It supports multiple providers out of the box, including VirtualBox, Hyper-V, and Docker with additional providers like VMware, AWS, and Libvirt available through its plugin system. This guide walks through how to install Vagrant on Ubuntu and launch your first virtual machine in minutes.
Vagrant requires a virtualization provider. VirtualBox is the default and the simplest option to get running. If it is not already on your system, install it first:
bashsudo apt updatesudo apt install virtualbox
The Vagrant package in Ubuntu’s default repositories tends to lag behind the current release. For the latest stable version, download the official .deb package directly from HashiCorp’s release server:
bashcurl -O https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb
Once the download finishes, install it with apt:
bashsudo apt install ./vagrant_2.2.9_x86_64.deb
Verify the installation by printing the Vagrant version:
bashvagrant --version
A successful install outputs the version number; for example, Vagrant 2.2.9. Always check the official Vagrant downloads page before running the commands above to confirm you are grabbing the latest available release.
A Vagrant project lives in its own directory and is defined by a Vagrantfile, a Ruby-based configuration file that describes how your virtual machine should be built and provisioned. Create a project directory and navigate into it:
bashmkdir ~/my-vagrant-projectcd ~/my-vagrant-project
Initialize the project using a specific Vagrant box. Boxes are pre-packaged base images that Vagrant uses to spin up machines. They are provider-specific, and you can browse thousands of community and official boxes at the Vagrant box catalog. This example uses the CentOS 8 box:
bashvagrant init centos/8
This creates a Vagrantfile in your project directory. Open it to review the default settings and adjust them to your needs. When ready, bring the virtual machine online:
bashvagrant up
Vagrant downloads the box image if not already cached, boots the VM, and configures the network. It also mounts your project directory inside the VM at /vagrant automatically, any file you edit on your host machine is immediately visible inside the environment.
Once your virtual machine is running, these are the commands you will reach for most often:
| Command | What It Does |
|---|---|
vagrant ssh | Opens an SSH session directly into the running VM |
vagrant halt | Gracefully shuts down the VM, preserving its state |
vagrant destroy | Removes the VM and all associated resources |
vagrant status | Shows the current state of the VM |
Tip: Use
vagrant haltwhen you plan to resume work later.vagrant destroywipes the machine entirely, you will need to runvagrant upagain and wait for the full provisioning cycle from scratch.
Vagrant removes the friction of setting up and maintaining development environments manually. Once you have a working Vagrantfile, any team member can replicate your exact environment with a single vagrant up command, regardless of whether they are on Windows, macOS, or Linux. That consistency is invaluable on collaborative projects. From here, explore Vagrant’s provisioning support for tools like Ansible, Chef, and Shell scripts to fully automate the environment inside your VM. Questions about your setup? Drop a comment below.
The rmmod command in Linux removes a loaded module from the running kernel. Because the kernel has…
The free command in Linux gives you a quick summary of RAM and swap usage. It reads…
The diff command in Linux compares two text files line by line and shows the lines that…
DNS cache is a temporary database your OS and browser build as you browse. Each time you visit a website, the domain-to-IP mapping is saved locally, cutting out the round trip to a remote DNS server on repeat visits. Stale entries are the most common reason to flush the DNS cache: a server moves to a new IP, but your OS or browser still routes to the old address. This guide covers how to clear the DNS cache on Windows, Linux, and macOS, and how to flush the separate cache stored inside Chrome and Firefox. Flush DNS Cache on Windows The command is the same on Windows 10, Windows 11, and earlier supported releases. Open Command Prompt with administrator privileges. Type cmd in the Windows search bar, right-click Command Prompt, and select Run as…
Using a strong, unique password for every account is one of the most effective security…
Ubuntu locks the root account by default. New users often wonder what the root password…