At the beginning of the last year, I wrote about VirtualBox image conversion. Today, I will continue this topic further and describe how to control the virtual machine using the command line.

How to list virtual machines

List virtual machines and their UUID.

$ VBoxManage list vms
"Debian - "Kolab dev"" {7ccf631e-a792-4aa3-b09c-96298ab41ff2}
"Crunchbang" {d485f4a1-7794-4502-8775-e6f67a16c8dc}
"Deepin" {6ce34e63-3632-42a4-8f6c-216c691c96b2}

Pretty print virtual machines.

$ VBoxManage list vms | sed "s/\"\(.*\)\".*/\1/"
Debian - "Kolab dev"
Crunchbang
Deepin

How to print virtual machine states

Print running virtual machines and their UUID.

$ VBoxManage list runningvms
"Crunchbang" {d485f4a1-7794-4502-8775-e6f67a16c8dc}

List virtual machines and their corresponding states.

$ VBoxManage list vms -l | grep -e ^Name: -e ^State | sed s/\ \ //g | cut -d: -f2- 
Debian - "Kolab dev"
 powered off (since 2013-07-19T21:17:55.000000000)
Crunchbang
 paused (since 2013-07-20T10:13:07.771000000)
Deepin
 powered off (since 2013-06-29T15:56:04.000000000)

Slightly different solution.

$ VBoxManage list vms -l | grep -e ^Name: -e ^State  | sed "s/Name:[ ]*\(.*\)/\1 \//;s/State:[\ ]*//" | paste -d " " - -
Debian - "Kolab dev" / powered off (since 2013-07-19T21:17:55.000000000)
Crunchbang / paused (since 2013-07-20T10:13:07.771000000)
Deepin / powered off (since 2013-06-29T15:56:04.000000000)

How to start a virtual machine

You are not forced to use VirtuaBoxManager GUI as it is not desirable in every case. It is also not very ergonomic to use a mouse all the time.

Standard GUI

Start the virtual machine Crunchbang using standard GUI.

$ VBoxManage startvm Crunchbang --type gui

You can safely omit type parameter in the above-mentioned command as the standard GUI is used by default.

$ VBoxManage startvm Crunchbang

Simple GUI

Use a simple GUI without controls.

$ VBoxSDL --startvm Crunchbang

Start the virtual machine using a simple GUI without controls in the background.

$ VBoxManage startvm Crunchbang --type sdl

Headless

Start a virtual machine without GUI in the background.

$ VBoxManage startvm Crunchbang --type headless

Start a virtual machine without a GUI.

$ VBoxHeadless --startvm Crunchabang

Headless with VNC

Start a virtual machine without GUI but enabled VNC service.

$ VBoxHeadless --startvm Crunchbang --vnc --vncport 5901 --vncpass passw

How to pause virtual machine

Pause the virtual machine.

$ VBoxManage controlvm Crunchbang pause

How to resume paused virtual machine

Resume the virtual machine.

$ VBoxManage controlvm Crunchbang resume

How to reset virtual machine

Reset the virtual machine.

$ VBoxManage controlvm Crunchbang reset

How to power off virtual machine

Power off the virtual machine.

$ VBoxManage controlvm Crunchbang poweroff

How to save state and then stop virtual machine

Save the state of the virtual machine and then stop it.

$ VBoxManage controlvm Crunchbang savestate

Notes

Please note that I have not installed VirtualBox Extension Pack as I am not using VRDP.

I suggest you read the VirtualBox manual and Debian wiki – VirtualBox.