Skip to content

Instantly share code, notes, and snippets.

Last active July 14, 2024 11:45
Show Gist options
  • Save wpscholar/a49594e2e2b918f4d0c4 to your computer and use it in GitHub Desktop.
Save wpscholar/a49594e2e2b918f4d0c4 to your computer and use it in GitHub Desktop.
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
  • vagrant resume -- resume a suspended machine (vagrant up works just fine for this as well)
  • vagrant provision -- forces reprovisioning of the vagrant machine
  • vagrant reload -- restarts vagrant machine, loads new Vagrantfile configuration
  • vagrant reload --provision -- restart the virtual machine and force provisioning

Getting into a VM

  • vagrant ssh -- connects to machine via SSH
  • vagrant ssh <boxname> -- If you give your box a name in your Vagrantfile, you can ssh into it with boxname. Works from any directory.

Stopping a VM

  • vagrant halt -- stops the vagrant machine
  • vagrant suspend -- suspends a virtual machine (remembers state)

Cleaning Up a VM

  • vagrant destroy -- stops and deletes all traces of the vagrant machine
  • vagrant destroy -f -- same as above, without confirmation


  • vagrant box list -- see a list of all installed boxes on your computer
  • vagrant box add <name> <url> -- download a box image to your computer
  • vagrant box outdated -- check for updates vagrant box update
  • vagrant box remove <name> -- deletes a box from the machine
  • vagrant package -- packages a running virtualbox env in a reusable box

Saving Progress

-vagrant snapshot save [options] [vm-name] <name> -- vm-name is often default. Allows us to save so that we can rollback at a later time


  • vagrant -v -- get the vagrant version
  • vagrant status -- outputs status of the vagrant machine
  • vagrant global-status -- outputs status of all vagrant machines
  • vagrant global-status --prune -- same as above, but prunes invalid entries
  • vagrant provision --debug -- use the debug flag to increase the verbosity of the output
  • vagrant push -- yes, vagrant can be configured to deploy code!
  • vagrant up --provision | tee provision.log -- Runs vagrant up, forces provisioning and logs all output to a file


  • vagrant-hostsupdater : $ vagrant plugin install vagrant-hostsupdater to update your /etc/hosts file automatically each time you start/stop your vagrant box.


  • If you are using VVV, you can enable xdebug by running vagrant ssh and then xdebug_on from the virtual machine's CLI.
Copy link

gerroon commented Apr 24, 2020

Is there a way to search vagrant apps on the command line hosted by hashicorp's pp database?

Copy link

Very useful. Thank you!

Copy link

Thanks for this nice cheat-sheet. Sometimes cheat-sheet are more user friendly than some documentation.

Copy link

thank you!!!

Copy link


Copy link

Good one

Copy link

Great resource! thank you.

Copy link

kipio commented Sep 28, 2021


Copy link

M41R40 commented Sep 29, 2021

Obrigadaa !!

Copy link

Thanks so much. This helped a great deal

Copy link

Thanks so much buddy

Copy link

vagrant boxes remove ... should be: vagrant box remove ...

Copy link

vagrant boxes remove ... should be: vagrant box remove ...

Updated. Thanks!

Copy link

Thank you very much!!

Copy link

Thank you very much for this.

I have been trying to clone my GitHub in command line but it keeps asking for password. I have tried using PAT and my GitHub sign in password, but both didn’t work.

Any suggestions on how I can resolve this?

Copy link

Useful resource.Thanks!

Copy link

what does "provision" mean in Vagrant?
As i understand, provision mean that you can setup the vm you just created using vagrant, for my use case, i can run ansible playbook in those VM that i want to create, and a fun fact it vagrant allow you to declare the playbook inside the vagrantfile, i do not know it until my co-worker tell me. Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment