Data Centers

How to run VirtualBox virtual machines from the command line

VirtualBox virtual machines can be run without working with the GUI. See how to take advantage of the VBoxManage command to start, pause, and power down your VMs.

Image: Jack Wallen

If you're using VirtualBox as a virtual machine (VM) server in your data center, chances are you're going to want to know how to run those VMs without having to rely on the VirtualBox GUI. This makes it much easier to run your VMs without having to be at the host machine (you can ssh into the host and then manage the VMs) or without having a number of GUI windows open to clutter your server desktops (or be readily available for prying eyes).

To make this happen, you'll use a very powerful command that comes with VirtualBox called VBoxManage; it allows you to manage a number of aspects of your VMs. I'll show how to use VBoxManage to start, stop, and pause your VMs. I assume you have VirtualBox installed, and your VMs are ready to run on the host machine.

SEE: Building the Software Defined Data Center (ZDNet/TechRepublic special feature)

Before you fire up a VM

If you go directly to the VBoxManage command and fire up a VM, you'll probably find that VM isn't reachable via network—this renders the VM worthless, especially if it is a server.

In order to get the networking of your headless VM up and running, you have to install the VirtualBox extension pack. Here's how.

  1. Download the extension pack that matches your VirtualBox release.
  2. Open the VirtualBox GUI.
  3. Click File | Preferences.
  4. Go to the Extensions section.
  5. Click the downward-pointing arrow (Figure A).
  6. Navigate to where you saved the Extension Pack and select the .vbox-extpack file.
  7. Click Open.
  8. When prompted, type your admin password for the host machine.
  9. Click OK.

Figure A

Figure A
Image: Jack Wallen
Installing the VirtualBox Extension Pack

You're ready to run your VMs, which will include the ability to reach them via network.

Starting/stopping/pausing a VM

Now the fun begins. First, you must know the name of the VM you want to run. To find a list of the VMs, issue the command VBoxManage list vms. This command will display all the VMs, as well as their unique IDs, in a form that you can use (Figure B).

Figure B

Figure B
Image: Jack Wallen
All of my available VMs

Say we want to run the "Ubuntu Server" VM as a headless instance. To do this, you would issue the command:

VBoxManage startvm "Ubuntu Server" --type headless

The VM will start up and hand you back your bash prompt. Your virtual server (if that's how you're using the VM) is now available to you.

If you need to pause that VM, issue the command:

VBoxManage controlvm "Ubuntu Server" pause --type headless

To restart that paused VM, issue the command:

VBoxManage controlvm "Ubuntu Server" resume --type headless

To shut down the VM, issue the command:

VBoxManage controlvm "Ubuntu Server" poweroff --type headless

You have the capability to start, stop, and pause your VMs...all from the command line.

A very handy feature

The ability to run VMs from the command line is incredibly handy. When you have a host running numerous guests, and you don't want every guest visible on the host platform, or you want to be able to manage the VMs remotely, you'll be glad to have the VBoxManage command at the ready.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website

Editor's Picks

Free Newsletters, In your Inbox