How can I tell if a virtual machine is up from the command line?

How can I tell from the command line if a specific virtual machine is up and running from the command line?


vboxmanage list vms

Dos not (anymore?) tells if the vm is runing or not. It list also not running ones.

vboxmanage showvminfo "your_vm_name" | grep -c "running (since"

Will returns 1 if it's running, or 0 if not.


If you want a list of all VMs to see if they are running or not use this command:

vboxmanage list vms --long | grep -e "Name:" -e "State:"

This will show the VMs name in one line and its status in the following line such as in

Name:            windows10pro
State:           running (since 2017-06-09T09:16:46.593000000)
Name:            ubuntu16LTS
State:           powered off (since 2017-02-09T19:11:33.000000000)
Name:            zammad
State:           running (since 2017-06-09T09:08:13.871000000)

This command outputs the list of running vms (tested on Virtualbox 5.1)

VBoxManage list runningvms

To know if a vm is running, this command should do the job (return 1 if running, 0 otherwise) :

VBoxManage list runningvms | sed -r 's/^"(.*)".*$/\1/' | grep 'VM Name' | wc -l

I believe you can get this information using VBoxManage (command-line interface to VirtualBox).

You can use The showvminfo command for show information about a particular virtual machine.

This is the same information as VBoxManage list vms would show for all virtual machines.