6 Useful VirtualBox Commands You Can Use to Manage Your VMs - MakeUseOf

list link on bottom

Virtualization is one of the core computing technologies today. With a virtual machine (VM), you can run almost any operating system of your choice on your PC without breaking the bank to acquire extra hardware.

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

What Is VboxManage?

VboxManage is a command-line interface (CLI) tool installed by default as part of your VirtualBox software installation.

As much as you can manage most of your virtual machine from the GUI, the VboxManage CLI gives you more functionality as it gives you direct access to the virtualization engine, allowing you to access extra features unavailable through the GUI. In addition, most Linux servers do not come with a GUI, so you will still be able to manage your VMs even in headless mode.

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

Download: VirtualBox for Windows[1] | macOS[2] | Linux[3] (Free)

1. Listing Virtual Machines

One of the most common and important VirtualBox commands is to list all the VMs that are available on your PC or server. Here is how you can view or list all VMs that are registered on your PC. From the output, you will notice that each VM is given a Universally Unique Identifier (UUID) used to uniquely identify a VM.

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

vboxmanage list vms 
Commmand outout showing registred virtual machines on a PC or server

If you want a detailed listing, add the -l or --long flag to the vboxmanage list vms command. The output shows you all the registered VMs and detailed information such as the configuration of each VM, hardware details, settings, etc.

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

vboxmanage list runningvms

2. Starting and Stopping a VM

To start a VM using VboxManage, use the startvm subcommand followed by the virtual machine's name or the UUID. For example, I would run the following command to start the VM 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 power off the VM, or you can pause it.

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

vboxmanage controlvm Windows11 poweroff

You will be shown the progress of the VM shutting down as a percentage.

If you want to stop the VM from consuming system resources but do not necessarily want to power it off, then you can pause the VM and resume it at a later time.

To pause a running VM, use the following command.

vboxmanage controlvm Window11 pause

Note that a paused VM is still listed under running VMs. To get information about the state of a VM, run a long listing using the command vboxmanage list runningvms -l. In the output, the state parameter should be equal to paused. The timestamp when the VM was paused will also be listed.

command output showing the state of a pasued virtual machine

To resume a paused VM, use the following command.

vboxmanage controlvm Windows11 resume

3. Getting VM Info

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

vboxmanage showvminfo Windows11

4. Creating a VM

Another important task when managing virtual machines is the creation of new VMs. Use the createavm subcommand to create a new VM. 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 not sure of the operating system's name to use in your VM, you can check the supported VirtualBox operating systems using the following command.

vboxmanage list ostypes
list supported operating systems

If you want to modify the newly created VM, for example, to change the memory size, name, and other relevant parameters, you can use the modifyvm subcommand.

The modifyvm subcommand syntax is followed by the name of the VM that you want to modify. Next, you specify the setting you want to change, and finally, you specify the value of the setting.

Let's assume that you want to change the name of the newly created VM above from DebianVM to Debian9 using the --name setting.

vboxmanage modifyvm DebianVM --name Debian9

You can look at the list of settings that you can modify by running the command:

vboxmanage modifyvm 

Learn More: Tips to Supercharge Your Linux VirtualBox[4]

5. Snapshots and Restoring

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

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

vboxmanage snapshot Windows11 take "Christmas eve snapshot"
progress output of taking a virtual box VM snapshot

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

vboxmanage snapshot Windows11 restore "Christmas eve snapshot"

Obviously, you can switch out the snapshot name for something that suits your VM installation.

6. Getting Help

To become better at using the VboxManage CLI, you must know how to get help or read documentation from the command terminal instead of memorizing commands. Also, there are a lot of other commands that we have not covered in this guide. Learn more about VboxManage commands and the options it provides you by running the following command:

vboxmanage

Learn More: How to Get Command Line Help on Linux[5]

Why Should You Consider Using a VM

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

Virtual machines provide you with the opportunity to run and experiment with multiple operating systems on your PC. In addition, because VMs run in a secure and isolated environment, you are assured that if the guest or VM operating crashes, it will not negatively impact your host operating system.

start-using-virtual-machine
7 Practical Reasons to Start Using a Virtual Machine

What are virtual machines used for? Here are some practical benefits and uses for virtual machines that you can try right now.

Read Next

[6] About The Author