VirtualBox Cheatsheet
#
VirtualBox is an open-source virtualization software that allows you to run multiple operating systems simultaneously on a single machine. The VirtualBox CLI, known as VBoxManage, provides command-line access to all VirtualBox functionalities.
General Commands
#
Command/Option | Example | Description |
---|
VBoxManage –version | VBoxManage --version | Display the version of VirtualBox installed |
VBoxManage list vms | VBoxManage list vms | List all virtual machines |
VBoxManage list runningvms | VBoxManage list runningvms | List all running virtual machines |
VBoxManage showvminfo | VBoxManage showvminfo "VM name" | Show detailed information about a virtual machine |
VM Management
#
Command/Option | Example | Description |
---|
VBoxManage createvm | VBoxManage createvm --name "MyVM" --register | Create a new virtual machine |
VBoxManage startvm | VBoxManage startvm "MyVM" --type headless | Start a virtual machine in headless mode |
VBoxManage controlvm | VBoxManage controlvm "MyVM" poweroff | Power off a virtual machine |
VBoxManage unregistervm | VBoxManage unregistervm "MyVM" --delete | Unregister and delete a virtual machine |
VM Configuration
#
Command/Option | Example | Description |
---|
VBoxManage modifyvm | VBoxManage modifyvm "MyVM" --memory 2048 --cpus 2 | Modify the configuration of a virtual machine |
VBoxManage modifyvm | VBoxManage modifyvm "MyVM" --nic1 bridged --bridgeadapter1 eth0 | Configure networking for a virtual machine |
VBoxManage storagectl | VBoxManage storagectl "MyVM" --name "SATA Controller" --add sata --controller IntelAhci | Add a storage controller to a virtual machine |
VBoxManage storageattach | VBoxManage storageattach "MyVM" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium disk.vdi | Attach a storage medium to a virtual machine |
Disk Management
#
Command/Option | Example | Description |
---|
VBoxManage createhd | VBoxManage createhd --filename disk.vdi --size 10000 | Create a new virtual hard disk |
VBoxManage clonemedium | VBoxManage clonemedium disk.vdi disk_clone.vdi | Clone a virtual hard disk |
VBoxManage closemedium | VBoxManage closemedium disk.vdi --delete | Close and delete a virtual hard disk |
Snapshots
#
Command/Option | Example | Description |
---|
VBoxManage snapshot | VBoxManage snapshot "MyVM" take "Snapshot1" | Take a snapshot of a virtual machine |
VBoxManage snapshot | VBoxManage snapshot "MyVM" list | List all snapshots of a virtual machine |
VBoxManage snapshot | VBoxManage snapshot "MyVM" restore "Snapshot1" | Restore a virtual machine to a snapshot |
VBoxManage snapshot | VBoxManage snapshot "MyVM" delete "Snapshot1" | Delete a snapshot of a virtual machine |
Network Configuration
#
Command/Option | Example | Description |
---|
VBoxManage hostonlyif create | VBoxManage hostonlyif create | Create a host-only network interface |
VBoxManage hostonlyif ipconfig | VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.56.1 --netmask 255.255.255.0 | Configure the IP address of a host-only network interface |
VBoxManage natnetwork add | VBoxManage natnetwork add --netname natnet1 --network 10.0.2.0/24 --enable --dhcp on | Add a NAT network |
VBoxManage natnetwork start | VBoxManage natnetwork start --netname natnet1 | Start a NAT network |
Miscellaneous
#
Command/Option | Example | Description |
---|
VBoxManage guestcontrol | VBoxManage guestcontrol "MyVM" run --exe "/bin/bash" --username user --password pass | Execute a command in the guest operating system |
VBoxManage setproperty | VBoxManage setproperty machinefolder /path/to/vms | Set the default folder for virtual machines |
VBoxManage metrics collect | VBoxManage metrics collect "MyVM" CPU/Load/User | Collect performance metrics for a virtual machine |
This cheatsheet covers the most commonly used VirtualBox CLI commands and options, helping you to manage virtual machines, configure settings, handle disk management, snapshots, network configurations, and more effectively.