Manage VMs with VirtualBox CLI
Delving deeper into the capabilities of Oracle VM VirtualBox, we find that VBoxManage serves as the command-line gateway, as introduced in greater detail in Section 1.18, “Alternative Front-Ends”. Positioned as the command-line interface to Oracle VM VirtualBox, VBoxManage empowers users to exercise comprehensive control over the virtualization platform directly from the command line of their host operating system.
While the graphical user interface provides a user-friendly interface for managing Oracle VM VirtualBox, VBoxManage transcends these boundaries, offering not only parity with GUI features but extending its support to a myriad of additional functionalities. Unveiling the full spectrum of the virtualization engine’s capabilities, VBoxManage becomes the conduit to features that lie beyond the reach of the graphical interface, providing users with a robust and versatile toolset for virtualization management.
Unlock the full potential of VBoxManage when you find yourself needing to:
- Employ an alternative user interface, such as the VBoxHeadless server, for a different VirtualBox experience.
- Take command of advanced and experimental configuration settings for your virtual machines, surpassing the limits imposed by the graphical interface.
Embrace the command line for a richer, more versatile VirtualBox experience, where VBoxManage becomes your gateway to unparalleled control and configuration.
Setup
Interesting enough, VBoxManage comes pre-installed with Oracle VM VirtualBox, so there’s no need to install anything extra. Simply launch the command-line interface of your host operating system and you’re ready to go.
However, for the command to be recognized, you’ll need to add the path to the VBoxManage executable to your system’s PATH environment variable. This will allow you to execute the command from any directory on your system.
VBoxManage can actually be found in the same directory as the VirtualBox executable, which is typically located in the following directory:
1
C:\Program Files\Oracle\VirtualBox
To add the path to the VBoxManage executable to your system’s PATH environment variable, follow these steps:
- Press Windows Key + R to open the Run dialog.
- Type
sysdm.cpl
and press Enter to open the System Properties dialog. - Navigate to the Advanced tab.
- Click the Environment Variables button.
- Under System variables, select the Path variable and click Edit.
- Click New and enter the path to the VBoxManage executable, which is typically located in the following directory:
1
C:\Program Files\Oracle\VirtualBox
- Click OK to save your changes.
- Click OK to close the Environment Variables dialog.
- Click OK to close the System Properties dialog.
Now you can launch the command-line interface of your host operating system and execute the VBoxManage command from any directory on your system.
1
2
PS C:\Users\User> vboxmanage --version
7.0.8r156879
Usage
The VBoxManage command is structured as follows:
1
vboxmanage [options]
The VBoxManage command accepts a variety of options, which can be found in the VBoxManage Command Reference. For example, the following command displays the version of Oracle VM VirtualBox:
1
vboxmanage --version
List All VMs:
1
vboxmanage list vms
List Running VMs:
1
vboxmanage list runningvms
Start a VM:
1
vboxmanage startvm <vm-name or uuid>
Start a VM in Headless Mode (No GUI):
1
vboxmanage startvm <vm-name or uuid> --type headless
Power Off a VM:
1
vboxmanage controlvm <vm-name or uuid> poweroff
Power Button a VM (ACPI Shutdown):
1
vboxmanage controlvm <vm-name or uuid> acpipowerbutton
Reset a VM:
1
vboxmanage controlvm <vm-name or uuid> reset
Pause a VM:
1
vboxmanage controlvm <vm-name or uuid> pause
Resume a VM:
1
vboxmanage controlvm <vm-name or uuid> resume
Save a VM State:
1
vboxmanage controlvm <vm-name or uuid> savestate
Take a Snapshot of a VM:
1
vboxmanage snapshot <vm-name or uuid> take <snapshot-name>
Restore a VM to a Snapshot:
1
vboxmanage snapshot <vm-name or uuid> restore <snapshot-name>
Delete a Snapshot of a VM:
1
vboxmanage snapshot <vm-name or uuid> delete <snapshot-name>
Change the VM’s Memory:
1
vboxmanage modifyvm <vm-name or uuid> --memory <memory-in-mb>
Change the VM’s CPU Count:
1
vboxmanage modifyvm <vm-name or uuid> --cpus <cpu-count>
Change the VM’s Boot Order:
1
vboxmanage modifyvm <vm-name or uuid> --boot1 dvd --boot2 disk --boot3 none --boot4 none
Change the VM’s Network Adapter Type:
1
vboxmanage modifyvm <vm-name or uuid> --nic1 bridged --bridgeadapter1 "Intel(R) Ethernet Connection (7) I219-V"
Change the VM’s Network Adapter MAC Address:
1
vboxmanage modifyvm <vm-name or uuid> --macaddress1 <mac-address>
Change the VM’s Network Adapter Cable Connected State:
1
vboxmanage modifyvm <vm-name or uuid> --cableconnected1 on
Change the VM’s Network Adapter Promiscuous Mode:
1
vboxmanage modifyvm <vm-name or uuid> --nicpromisc1 allow-all
Conclusion
VBoxManage is a powerful command-line interface that empowers users to exercise comprehensive control over the virtualization platform directly from the command line of their host operating system. Unlock the full potential of VBoxManage when you find yourself needing to employ an alternative user interface, such as the VBoxHeadless server, for a different VirtualBox experience or take command of advanced and experimental configuration settings for your virtual machines, surpassing the limits imposed by the graphical interface.