VirtualBox is one of the most popular open source virtualization systems for Windows and Linux. Due to the free distribution, the program has gained immense popularity, and the developers have added many useful features. Ordinary users, including myself, are used to using VirtualBox in a graphical interface.

It’s simple and convenient. However, if you install VirtualBox on a server, there will be no GUI. But you can do all the same and more with VirtualBox console commands. There are a lot of these commands. In this article, we will look at the most useful VirtualBox console commands. By the end of the article, you will have a fully configured and working virtual machine.

Basic VirtualBox Commands

Virtual machines are managed in the terminal using the VBoxManage command. It has a pretty simple syntax:

$ VBoxManage general_options command options_commands

I will not go over all the options and commands of VirtualBox here, we will consider them in the process. By default, all virtual machines are located in the .config/VirtualBox/Machines directory. However, you can change this path with the setproperty command. For example /home/virtualbox/:

VBoxManage setproperty machinefolder /home/virtualbox/

1. Create a virtual machine

The first step is to create a new virtual machine with which we will work. Each virtual machine is nothing more than an XML file with settings. Creating a VirtualBox virtual machine is done using the VBoxManage createvm command . Here are its main options:

  • –name – machine name;
  • –ostype – operating system type;
  • –register – registers the virtual machine, otherwise an XML file with settings will be simply created.

The list of available types of operating systems can be viewed with the command:

VBoxManage list ostypes

VirtualBox Console Commands

Let’s create a virtual machine for Ubuntu and register it in the system:

VBoxManage createvm --name "Ubuntu1804" --ostype "Ubuntu_64" --default --register

VirtualBox Console Commands

The virtual machine has been successfully created and added.

2. Adding an existing machine

If you have migrated a virtual machine from another system, you may want to add it. This is an analogue of the item open in the menu of the graphical interface. Use the VBoxManage registervm command, which must pass the path to the virtual machine file as an argument:

VBoxManage registervm /home/sergiy/VirtualBox VMs/Ubuntu1804/Ubuntu1804.vbox

3. List of virtual machines

To make sure everything works you may want to look at the list of virtual machines. This can be done with the command:

VBoxManage list vms

VirtualBox Console Commands

Or you can see the list of running virtual machines:

VBoxManage list runningvms

To see more detailed information about virtual machines, use the –long option:

VBoxManage list vms --long

VirtualBox Console Commands

4. Set up machine storage

By default, only the virtual machine configuration is created. It does not have any storage that will host the operating system. Now we will add it. First you need to create a hard disk in a folder next to the virtual machine file:

VBoxManage createhd --filename "/home/sergiy/VirtualBox VMs/Ubuntu1804/Ubuntu1804.vdi" --size 10000 --format VDI

VirtualBox Console Commands

Here you need to pass the path to the file of the future disk and its size in megabytes. I’m creating a 10 gigabyte drive. This should be enough to run the test system. Then, using the storagectl and storageattach commands , add a SATA controller and connect this drive to it:

VBoxManage storagectl "Ubuntu1804" --name "SATA Controller" --add sata --controller IntelAhci

VBoxManage storageattach "Ubuntu1804" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "/home/sergiy/VirtualBox VMs/Ubuntu1804/Ubuntu1804.vdi"

VirtualBox Console Commands

In the –medium parameter, you must pass the path to the disk file that you are going to mount. If you want the machine to boot from an ISO image, then you will also need an IDE controller:

VBoxManage storagectl "Ubuntu1804" --name "IDE Controller" --add ide --controller PIIX4

Then you can connect your image to it:

VBoxManage storageattach "Ubuntu1804" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium ~/ubuntu.iso

VirtualBox Console Commands

5. Remote access

Since the virtual machine is on the server, there is no access to the graphical interface, but we need to access the machine itself. To do this, we can use the RDP protocol. To enable remote access, use the command:

VBoxManage modifyvm "Ubuntu1804" --vrde on

You can also change the RDP port to the one you want, for example, 33891:

VBoxManage modifyvm "Ubuntu1804" --vrdeport 33891

We can already access this machine now, but let’s set up password authorization so that no outsider can access it if the server is accessible from the Internet. First, let’s set the authorization type to external :

VBoxManage modifyvm Ubuntu1804 --vrdeauthtype external

We indicate that we need to use the VBoxAuthSimple authorization module:

VBoxManage setproperty vrdeauthlibrary VBoxAuthSimple

VirtualBox Console Commands

It remains to choose a username and password. Let’s be losst_user and losst_password. Let’s create a hash for our password:

VBoxManage internalcommands passwordhash losst_password

VirtualBox Console Commands

It remains to associate this hash with the username losst_user for our machine:

VBoxManage setextradata "Ubuntu1804" "VBoxAuthSimple/users/losst_user" 4a26e3cde3647806539e746d4b7fa27401af9198ac0da1a5122e8851648566d2

VirtualBox Console Commands

The rdp virtualbox setup is complete and the machine will now be available over the network. You can connect to it using the Reminna utility. It remains only to run it.

6. Install VirtualBox Extpack

If you want to use VirtualBox remote access, you need to install the VirtualBox extension set for your version of the program. First, check if you have these extensions installed:

VBoxManage list extpacks

VirtualBox Console Commands

The system says that I have one set of extensions installed. We will be interested in the line VRDE Module . Its value must be RDP, not VNC, or anything else.

To install the extension set, first check your version of VirtualBox:

VBoxManage --version

VirtualBox Console Commands

For my version 5.2 extension sets can be found on this page. You can easily find the right extpack using the search. Then upload it to the server and install it with the command:

VBoxManage extpack install ~/Path to the file.extpack

Once installed, it will appear in the list.

7. Hardware setup

As I said, by default, the machine is given the most minimal resources, few modern systems can work with such an amount of resources. So let’s give the virtual machine more RAM:

VBoxManage modifyvm "Ubuntu1804" --memory 2048

To increase the amount of video memory in virtualbox, run:

VBoxManage modifyvm "Ubuntu1804" --vram 128

The amount of memory must be specified in megabytes. The machine must be turned off for the changes to work. Next, let’s give the machine two processor cores:

VBoxManage modifyvm "Ubuntu1804" --cpus 2

Here, with such parameters it is already possible to work.

8. Machine status management

Use the startvm command to start the virtual machine. Since we are running it without graphics, we should use the –type headless option:

VBoxManage startvm "Ubuntu1804" --type headless

VirtualBox Console Commands

Once the machine has been started, you can open it with reminna:

VirtualBox Console Commands

Next, the controlvm command is used to control the running machine. It allows you to pause the car or stop it. To pause the machine, use the pause command:

VBoxManage controlvm "Ubuntu1804" pause

To unpause the machine:

VBoxManage controlvm "Ubuntu1804" resume

To turn off the machine completely:

VBoxManage controlvm "Ubuntu1804" poweroff

If you don’t want to turn off the machine, you can save its state:

VBoxManage controlvm "Ubuntu1804" savestate

Or you can send a click signal to the shutdown button:

VBoxManage controlvm "Ubuntu1804" acpipowerbutton

If your machine is interrupted due to a computer restart or a power outage, a situation may occur that it will remain blocked and you will not be able to start it. To resolve this issue, use the command:

VBoxManage startvm "Ubuntu1804" --type emergencystop

Our article is coming to an end, but this is not all the commands of the VirtualBox console.

9. View machine information

You can view information about the current state of the machine, as well as its equipment, using the showvminfo command:

VBoxManage showvminfo "Ubuntu1804"

VirtualBox Console Commands

If you are only interested in the state of the machine, you can filter the virtualbox cli output with the grep utility:

VBoxManage showvminfo "Ubuntu1804" | grep State

VirtualBox Console Commands


In this article, we looked at useful VirtualBox CLI commands that will allow you to fully manage virtual machines on a server. I did not go into detail about setting the disk size, you can read about all this in the article how to increase the size of the VirtualBox disk. Of course, there are many other interesting commands that do not fit in this article, such as setting up automatic installation of the system, configuring the network, changing equipment on the fly, and much more.

Source: The article is distributed under the CC-BY-SA license