VirtualBox Commands Cheat Sheet

• Updated July 21, 2016

VirtualBox has always been the go-to piece of software to spin up virtual machines on your workstation.

More often than not, you will work with VirtualBox using its GUI. However, for those occasions where you are SSH’ing into a remote workstation running VirtualBox, it is often easier to work with it using the command line instead of forwarding X.

This post will be an ever growing list of useful VirtualBox commands.

Import Virtual Machine

Import a virtual machine file into VirtualBox:

vboxmanage import <FILE>

In certain scenarios, you may not want virtual machine file you are importing should to regenerate its virtual NIC MAC addresses. In that case, pass the keepallmacs flag:

vboxmanage import --options keepallmacs <FILE>

Start Virtual Machine

Start one virtual machine:

vboxmanage startvm <NAME>

Start many virtual machines:

for i in <VM1> <VM2> <VM3>; do vboxmanage startvm $i; done

Stop Virtual Machine

Stop one virtual machine:

vboxmanage controlvm <NAME> poweroffip

Stop many virtual machines:

for i in <VM1> <VM2> <VM3>; do vboxmanage controlvm $i poweroff; done

List OS Types

When using vboxmanage or tools like packer, you might need to reference a list of all the supported ostypes - operating system types - when creating virtual machines.

To see a list of valid ostypes, run the following command:

vboxmanage list ostypes | grep ^ID

Create hostonlyif Network Adapter

Create host only network interface adapter:

vboxmanage hostonlyif create

Remove hostonlyif Network Adapter

Remove host only network interface adapter:

vboxmanage hostonlyif remove vboxnet0

NAT SSH to Virtual Machine

By default, a VirtualBox virtual machine will use an IP address you cannot route to. If you want to SSH to that virtual machine without adding another host only network interface, you will need to setup a NAT to port 22.

NAT SSH to virtual machine:

vboxmanage modifyvm "vm1" --natpf1 "guestssh,tcp,,22111,,22"

Delete NAT SSH on virtual machine:

VBoxManage modifyvm "vm1" --natpf1 delete "guestssh"

If you found this post useful and would like to help support this site - and get something for yourself - sign up for any of the services listed below through the provided links.

The following links are part of affiliate programs, and I will receive a referral payment from any of the services you sign-up for.

  • Get Faster Shipping: About to order some stuff on Amazon but want to get more value out of the money you would normally pay for shipping? Sign-up for a free, 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.
  • Start Investing Now: Looking to start investing some of your saved income? Get started by opening an account with Webull, where upon sign-up and opening a brokerage account with an initial deposit of $100 or more you will receive free stock(s). The promotions are always changing, so be sure to click the link to see the latest.

Thanks for reading and take care.