6 useful VirtualBox commands to manage virtual machines

All VirtualBox installations come with the command line tool VBoxManage, a powerful and flexible utility for managing virtual machines.

Virtualization is one of the core computing technologies today. With a virtual machine (VM), you can run almost any desired operating system on your PC without spending money on additional hardware.

This tutorial explores how to use the command line terminal in managing VirtualBox virtual machines, regardless of whether the operating system you are using is Windows, macOS, or Linux. All VirtualBox installations come with the command line tool VBoxManage, a powerful and flexible utility for managing virtual machines.

What is VboxManage?

VboxManage is a command line tool (CLI) that comes by default as part of the VirtualBox software installation.

You can manage most of your VMs from the GUI, VboxManage CLI gives you more functionality as it gives you direct access to the virtualization engine, allowing you to access additional features without available through the GUI. Also, most Linux servers don't come with a GUI, so you can still manage your virtual machines even in headless mode.

All VboxManage commands begin with the word vboxmanage and are usually followed by a subcommand such as list, controlvm, etc. Usually, you are asked to provide the name of the VM you want to configure or control.

6 useful VirtualBox commands to manage virtual machines

1. List virtual machines

One of the most common and important VirtualBox commands is to list all the virtual machines available on your PC or server. This is how you can view or list all the virtual machines that are registered on your PC. From the output you will notice that each virtual machine is assigned a unique identifier (UUID) that is used to identify a virtual machine.

To list the virtual machines installed on the computer, use the following command:

vboxmanage list vms

6 useful VirtualBox commands to manage virtual machines Picture 16 useful VirtualBox commands to manage virtual machines Picture 1

If you want a detailed list, add the -l or --long flag to the vms list vboxmanage command. The results show you all registered virtual machines and detailed information like configuration of each virtual machine, hardware details, settings, etc.

Sometimes you are only interested in listing the currently running VMs. In that case, you can use the list subcommand with the runningvms option as follows.

vboxmanage list runningvms

2. Start and stop a virtual machine

To start a virtual machine using VboxManage, use the startvm subcommand followed by the virtual machine name or UUID. For example, run the following command to start the virtual machine with the name Window11 listed in the previous section.

vboxmanage startvm Windows11

When it comes to stopping a virtual machine, you have several options available. You can shutdown the virtual machine or suspend it.

To stop a virtual machine by powering off, you use the controlvm subcommand followed by the name of the virtual machine and then the poweroff option as follows.

vboxmanage controlvm Windows11 poweroff

You will be shown the virtual machine shutdown progress in percentage.

If you want to prevent the virtual machine from consuming system resources but not necessarily shutting it down, you can pause the virtual machine and resume it later.

To suspend a running virtual machine, use the following command.

vboxmanage controlvm Window11 pause

Note that the suspended virtual machine is still listed in the running virtual machine. To get information about the state of a virtual machine, run a long list using the command:

vboxmanage list runningvms -l

In the output, the state parameter should be paused. Timestamps when the VM was paused will also be listed.

6 useful VirtualBox commands to manage virtual machines Picture 26 useful VirtualBox commands to manage virtual machines Picture 2

To resume a paused virtual machine, use the following command.

vboxmanage controlvm Windows11 resume

3. Get virtual machine information

To view information related to a specific virtual machine instead of listing all virtual machines, use the showvminfo subcommand. For example, you can run the following command to get detailed information about the Windows11 virtual machine, including hardware and other configuration details, network status, etc.

vboxmanage showvminfo Windows11

4. Create a virtual machine

Another important task when managing virtual machines is creating new virtual machines. Use the createeavm subcommand to create a new virtual machine. For example, to create a virtual machine named "DebianVM" running on the Debian Linux operating system, you can run the following command.

vboxmanage createvm --name DebianVM --ostype Debian Debian_64 --register

If you are unsure about the operating system name to use in your virtual machine, you can check the supported VirtualBox operating systems with the following command.

vboxmanage list ostypes

6 useful VirtualBox commands to manage virtual machines Picture 36 useful VirtualBox commands to manage virtual machines Picture 3

For example, if you want to modify the newly created virtual machine to change the memory size, name, and other relevant parameters, you can use the modvm subcommand.

Following the modvm subcommand syntax is the name of the virtual machine you want to modify. Next, you specify the setting you want to change, and finally the value of the setting.

Assume that you want to change the name of the newly created virtual machine above from DebianVM to Debian9 using the --name setting.

vboxmanage modifyvm DebianVM --name Debian9

You can see a list of settings that you can modify by running the command:

vboxmanage modifyvm

5. Snapshot and restore

Backups are an important component of maintaining a robust IT system. VirtualBox gives you the ability to keep the state of your virtual machine so you can restore it if something goes wrong.

To take a snapshot of a specific virtual machine, you can run the following command, where Christmas eve snapshot is the name given to your virtual machine snapshot.

vboxmanage snapshot Windows11 take "Christmas eve snapshot"

6 useful VirtualBox commands to manage virtual machines Picture 46 useful VirtualBox commands to manage virtual machines Picture 4

To restore the above virtual machine with the newly created snapshot, first stop the virtual machine if it is running, then restore the snapshot with the following command.

vboxmanage snapshot Windows11 restore "Christmas eve snapshot"

Obviously, you can convert the snapshot name to something else that matches your virtual machine settings.

6. Get help

To become better at using VboxManage CLI, you must know how to get help or read documentation from the terminal instead of memorizing commands. In addition, there are many other commands that have not been covered in this tutorial. Learn more about the VboxManage commands and the options it gives you by running the following command:

vboxmanage

This tutorial explored some important commands for managing VirtualBox virtual machines with VboxManage, a powerful and lightweight CLI tool. In addition, you can easily create automation scripts based on VboxManage to manage virtual machines easily.

Virtual machines give you the opportunity to run and experiment with multiple operating systems on your PC. Additionally, because the virtual machine runs in a secure and isolated environment, you can rest assured that if a client or virtual machine crashes, it won't negatively affect the host operating system.

5 ★ | 1 Vote