LinuxCommandLibrary

vagrant-global-status

List global Vagrant machine statuses

TLDR

Display the state of all machines

$ vagrant global-status
copy

Prune any stale entries from the output
$ vagrant global-status --prune
copy

SYNOPSIS

vagrant global-status [options]

PARAMETERS

--prune
    Removes stale entries from the global status list. Stale entries are machines that are no longer running or tracked by Vagrant but still appear in the global list, usually due to unexpected shutdowns or manual file deletions. This ensures the list accurately reflects active environments.

--machine-id <ID>
    Filters the output to show only the machine with the specified unique ID. This ID is the one displayed in the first column of the global-status output.

--status <STATUS>
    Filters the output based on the machine's current state (e.g., 'running', 'saved', 'poweroff', 'not created'). This allows you to quickly find machines in a particular state.

--path <PATH>
    Filters the output to show only machines whose Vagrant project directory matches the given path.

--help
    Displays the help message for the global-status subcommand, listing available options and their usage.

DESCRIPTION

The vagrant global-status command provides a comprehensive overview of all active Vagrant environments across your entire system. Instead of navigating into each project directory to check its status, this command consolidates information from all tracked Vagrant machines.

For each active environment, it displays a unique machine ID, the machine's name (often derived from the Vagrantfile configuration), the provider (e.g., virtualbox, vmware_fusion), its current state (e.g., running, saved, poweroff), and the absolute path to the Vagrant project directory where the machine is defined.

This command is invaluable for developers working on multiple projects, allowing them to quickly identify which VMs are running, their states, and their locations. The displayed machine ID is particularly useful as it can be used with other Vagrant commands (like vagrant ssh or vagrant destroy) from any directory, providing a flexible way to interact with your VMs.

CAVEATS

The global-status command only tracks Vagrant environments that have been started via vagrant up and haven't been fully destroyed. If Vagrant's internal state files become corrupted, the displayed list might be inaccurate or incomplete. The --prune option can take a significant amount of time to execute if there are many entries to check.

OUTPUT FORMAT

The output of vagrant global-status is structured into several columns:
ID: A unique identifier for the Vagrant machine.
Name: The name of the machine, as defined in the Vagrantfile or automatically assigned.
Provider: The virtualization provider being used (e.g., VirtualBox, VMware, Hyper-V).
State: The current operational state of the machine (e.g., running, saved, poweroff, not created).
Path: The absolute path to the Vagrant project directory where the machine is defined.

USING MACHINE IDS

One of the most powerful features of global-status is the machine ID. This ID allows you to interact with a specific Vagrant machine from any directory on your system. For example, to SSH into a machine with ID 'abcdefg', you can simply run vagrant ssh abcdefg. Similarly, to destroy it, use vagrant destroy abcdefg. This eliminates the need to cd into the machine's project directory for common operations.

HISTORY

The global-status command was introduced early in Vagrant's development by Mitchell Hashimoto to address a common need for managing multiple virtual machine environments. As Vagrant's adoption grew, so did the number of projects users managed, making a system-wide overview crucial. This command filled that gap, providing a centralized way to monitor and interact with all active Vagrant instances without the need to traverse directories.

SEE ALSO

vagrant up, vagrant halt, vagrant suspend, vagrant destroy, vagrant ssh, vagrant status

Copied to clipboard