Cyberithub

VBoxManage - An Introduction to VirtualBox CLI with Examples

Advertisements

In this article, we will discuss about VirtualBox CLI tool called VBoxManage which is available for both Windows and Linux OS. This tool is available with the installation of Oracle VirtualBox in your System. As you might be aware, Oracle VirtualBox is a virtualization software which allows us to run multiple operating systems which includes Microsoft Windows, Linux, Oracle Solaris and Mac OS X at the same time. Developers and Professionals usually prefers VirtualBox for development and testing as it saves both time and resources.

VirtualBox VMs can be managed by both GUI as well as Command Line. Those who love using command line will definitely appreciate the usage of Virtualbox CLI tool called VBoxManage. Although you can use this tool in any of the OS you have but here we will see the usage in Windows 10 OS. In Windows, the executable will be found under C:\Program Files\Oracle\VirtualBox folder so to use this tool you need to change your folder path. More about VBoxManage.

VBoxManage - An Introduction to VirtualBox CLI with Examples

VBoxManage - An Introduction to VirtualBox CLI with Examples

Also Read: How to Share Folder Between Windows 10 Host OS and Ubuntu 20.04 Guest OS

Example 1: Check VBoxManage Version

If you want to check the version of current installed Virtualbox,  then you need to run VBoxManage --version command as shown below.

NOTE:

Please note that you need to have administrator access to go inside VirtualBox folder and run all the below given VBoxManage commands.
C:\Program Files\Oracle\VirtualBox>VBoxManage --version
6.1.18r142142

 

Example 2: List All Running VMs

If you want to know about all the running VMs then you need to use VBoxManage list runningvms command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage list runningvms
"Ubuntu 20.04" {591ea63f-5219-4883-bebc-a8d9254435c1}

 

Example 3: List all VMs

To list all the registered VMs, you need to use VBoxManage list vms command as shown below. As you can see from the output, we have below VMs currently registered in the VirtualBox.

C:\Program Files\Oracle\VirtualBox>VBoxManage list vms
"CentOS 8" {03336d89-5996-4240-acf1-ca8d923f00b2}
"OpenSUSE" {fad2e2e4-59df-4048-aee2-9d945fc742bd}
"CentOS 7" {e751fa86-ffb2-4c29-8665-d65c1ab53342}
"Rocky Linux" {0d53d384-536c-46ce-a9e5-91351cd1913c}
"Debian" {640d6a5f-ac72-4dde-9777-34e0dfee62ee}
"Ubuntu 20.04" {591ea63f-5219-4883-bebc-a8d9254435c1}

 

Example 4: Enable Nested VT-x/AMD-v of a VM

If you want to enable Nested VT-x/AMD-V setting of a VM then you need to use VBoxManage modifyvm <vmname | UUID> --nested-hw-virt on syntax. In this example we are enabling the setting of Ubuntu 20.04 VM using VBoxManage modifyvm "Ubuntu 20.04" --nested-hw-virt on command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage modifyvm "Ubuntu 20.04" --nested-hw-virt on

 

Example 5: Show VM Info

If you want to check complete information about a VM then you need to use VBoxManage showvminfo <vmname | UUID> syntax. In this example, we are checking the details of CentOS 7 VM using VBoxManage showvminfo "CentOS 7" command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage showvminfo "CentOS 7"
Name: CentOS 7
Groups: /
Guest OS: Red Hat (64-bit)
UUID: e751fa86-ffb2-4c29-8665-d65c1ab53342
Config file: D:\Virtualbox\CentOS 7\CentOS 7\CentOS 7.vbox
Snapshot folder: D:\Virtualbox\CentOS 7\CentOS 7\Snapshots
Log folder: D:\Virtualbox\CentOS 7\CentOS 7\Logs
Hardware UUID: e751fa86-ffb2-4c29-8665-d65c1ab53342
Memory size 10000MB
Page Fusion: disabled
VRAM size: 16MB
CPU exec cap: 100%
......................................................................

 

Example 6: Modify the amount of RAM assigned to a VM

If you want to modify the amount of RAM assigned to a VM then you need to VBoxManage modifyvm <vmname | UUID> --memory <RAM_in_MB> syntax. In this example we are modifying the RAM size of CentOS 8 VM to 1024M by using VBoxManage modifyvm "CentOS 8" --memory 1024 command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage modifyvm "CentOS 8" --memory 1024

You can verify the same by checking Memory size from the output of VBoxManage showvminfo "CentOS 8" command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage showvminfo "CentOS 8" | findstr "Memory size"
Memory size 1024MB
VRAM size: 16MB
Configured memory balloon size: 0MB

 

Example 7: Modify the number of Virtual CPUs assigned to a VM

To modify the number of virtual cpus assigned to a VM, you need to use VBoxManage modifyvm <vmname|UUID> --cpus <num_of_cpus> syntax. In this example, we are modifying the number of Virtual cpus of CentOS 8 VM to 2 by using VBoxManage modifyvm "CentOS 8" --cpus 2 command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage modifyvm "CentOS 8" --cpus 2

You can verify the same by querying number of cpus from VBoxManage showvminfo "CentOS 8" output as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage showvminfo "CentOS 8" | findstr /I "cpus"
Number of CPUs: 2

 

Example 8: Start a VM

To start a VM, you need to use VBoxManage startvm <vmname|UUID> syntax. In this example, we are starting CentOS 8 VM by using VBoxManage startvm "CentOS 8" command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage startvm "CentOS 8"
Waiting for VM "CentOS 8" to power on...
VM "CentOS 8" has been successfully started.

 

Example 9: Power Off a VM

If you want to quickly poweroff a VM without saving the data beforehand then you can use VBoxManage controlvm <vmname | UUID> poweroff syntax. In this example we are powering off CentOS 8 VM using VBoxManage controlvm "CentOS 8" poweroff command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage controlvm "CentOS 8" poweroff
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

 

Example 10: Pause a VM

If you want to put a Virtual Machine on hold then you need to use VBoxManage controlvm <vmname | UUID> pause syntax. In this example, we are putting CentOS 8 VM on temporary hold using VBoxManage controlvm "CentOS 8" pause command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage controlvm "CentOS 8" pause

 

Example 11: Resume a VM

If you want to resume a Virtual machine which was previously put on hold then you need to use VBoxManage controlvm <vmname | UUID> resume syntax. In this example we are resuming CentOS 8 VM which was previously kept on pause state. So to resume this VM, you need to use VBoxManage controlvm "CentOS 8" resume command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage controlvm "CentOS 8" resume

 

Example 12: Save the Current State of a VM

You can use VBoxManage controlvm <vmname | UUID> savestate syntax to save the current state of the virtual machine to disk and then stop the VM. In this example, we are saving the current state of CentOS 8 VM to disk and then stopping the VM by using VBoxManage controlvm "CentOS 8" savestate command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage controlvm "CentOS 8" savestate
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

 

Example 13: Reset a VM

To reset a VM, you need to use VBoxManage controlvm <vmname|UUID> reset syntax. In this example, we are resetting CentOS 8 VM by using VBoxManage controlvm "CentOS 8" reset command as shown below. Please note that this command might not give you time to save your data so always save your work before running this command.

C:\Program Files\Oracle\VirtualBox>VBoxManage controlvm "CentOS 8" reset

 

Example 14: Check Available OS Types

If you want to see the list of supported OS types then you need to use VBoxManage list ostypes command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage list ostypes
ID: Other
Description: Other/Unknown
Family ID: Other
Family Desc: Other
64 bit: false

ID: Other_64
Description: Other/Unknown (64-bit)
Family ID: Other
Family Desc: Other
64 bit: true

ID: Windows31
Description: Windows 3.1
Family ID: Windows
Family Desc: Microsoft Windows
64 bit: false

 

Example 15: Take VM Snapshot

If you want to take the snapshot of your VM then you need to use VBoxManage snapshot <vmname|UUID> take <snapshot_name> syntax. In this example, we are taking the snapshot of CentOS 8 by using VBoxManage snapshot "CentOS 8" take "21st January Snapshot" command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage snapshot "CentOS 8" take "21st January Snapshot"
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Snapshot taken. UUID: d871098d-07b6-4f62-b624-80fdb9c2d651

 

Example 16: List VM Snapshot

To list all the taken snapshots of a particular VM, you need to use VBoxManage snapshot <vmname|UUID> list syntax. In this example, we are checking all the snapshot of CentOS 8 VM by using VBoxManage snapshot "CentOS 8" list command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage snapshot "CentOS 8" list
Name: 21st January Snapshot (UUID: d871098d-07b6-4f62-b624-80fdb9c2d651) *

 

Example 17: Restore VM from a Snapshot

If you restore VM from a particular snapshot then you need to use VBoxManage snapshot <vmname|UUID> restore <snapshot_name> syntax. In this example, we are trying to restore CentOS 8 from 21st January Snapshot by using VBoxManage snapshot "CentOS 8" restore "21st January Snapshot" command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage snapshot "CentOS 8" restore "21st January Snapshot"
Restoring snapshot '21st January Snapshot' (3fd1cf99-5497-4c44-b862-daa3d8e34a16)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

 

Example 18: Delete a Snapshot

To delete a snapshot of a VM, you need to use VBoxManage snapshot <vmname|UUID> delete <snapshot_name> syntax. In this example, we are deleting 21st January Snapshot by using VBoxManage snapshot "CentOS 8" delete "21st January Snapshot" command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage snapshot "CentOS 8" delete "21st January Snapshot"
Deleting snapshot '21st January Snapshot' (d871098d-07b6-4f62-b624-80fdb9c2d651)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

 

Example 19: Delete a VM

To unregister and delete a VM, you need to use VBoxManage unregistervm --delete <vmname | UUID> syntax. In this example, we are deleting CentOS 8 VM using VBoxManage unregistervm --delete "CentOS 8" command as shown below.

C:\Program Files\Oracle\VirtualBox>VBoxManage unregistervm --delete "CentOS 8"
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

 

Example 20: Check all the Available Options

If you want to check all the options available with VBoxManage command then you need to simply run this command.

C:\Program Files\Oracle\VirtualBox>VBoxManage
Oracle VM VirtualBox Command Line Management Interface Version 6.1.18
(C) 2005-2021 Oracle Corporation
All rights reserved.

Usage:

VBoxManage [<general option>] <command>


General Options:

[-v|--version] print version number and exit
[-q|--nologo] suppress the logo
[--settingspw <pw>] provide the settings password
[--settingspwfile <file>] provide a file containing the settings password
[@<response-file>] load arguments from the given response file (bourne style)


Commands:

list [--long|-l] [--sorted|-s] vms|runningvms|ostypes|hostdvds|hostfloppies|
intnets|bridgedifs|hostonlyifs|natnets|dhcpservers|
hostinfo|hostcpuids|hddbackends|hdds|dvds|floppies|
usbhost|usbfilters|systemproperties|extpacks|
groups|webcams|screenshotformats|cloudproviders|
cloudprofiles|cloudnets
............................................................

Leave a Comment