virt-what
Detect virtual machine environment
TLDR
Detect if you are running in a virtual machine
Log output of virt-what into a file
Display version
SYNOPSIS
virt-what
DESCRIPTION
The virt-what command is a small shell script that attempts to detect if the current system is running inside a virtual machine and, if so, which hypervisor it is using. It outputs a list of detected hypervisors, one per line, to standard output. This tool is essential for scripts and applications that need to adapt their behavior based on whether they are running on physical hardware or within a virtualized environment. It probes various system characteristics, including DMI information, CPU flags, kernel modules, and device presence, to identify common virtualization platforms such as KVM, VMware, VirtualBox, Xen, Hyper-V, OpenVZ, and LXC.
CAVEATS
virt-what makes a best effort to detect virtualization. While generally reliable, it may not be foolproof and could occasionally produce false positives or negatives, especially with newer or less common hypervisors, or heavily customized environments. Its accuracy depends on the underlying system exposing sufficient virtualization indicators. Although virt-what itself doesn't explicitly require root privileges for basic operation, some of the underlying system checks it performs (e.g., reading DMI tables) might benefit from or implicitly rely on elevated permissions for complete information and access.
OUTPUT INTERPRETATION
The command outputs one hypervisor name per line if detected. If multiple hypervisors are detected (e.g., a nested virtualization scenario, or a container running within a VM), all will be listed. If no virtualization is detected, the command outputs nothing to standard output and exits with a zero status. Possible outputs include: kvm, vmware, virtualbox, xen, microsoft, hyperv, openvz, lxc, qemu, ibm-systemz, oracle-vm, parallels, bhyve, etc. The output is designed to be easily parsable by scripts and automation tools.
EXIT STATUS
virt-what exits with status 0 if it runs successfully (whether or not a hypervisor is detected). A non-zero exit status indicates an error during execution, such as missing required binaries or inability to access necessary system information.
HISTORY
virt-what is part of the libvirt project's client utilities, though it's often packaged separately in various Linux distributions. It was developed to provide a simple, reliable, and standardized way for scripts and applications to determine the virtualization status of a system without needing complex parsing of various system files or proprietary APIs. Its development reflects the increasing prevalence of virtualization and the need for applications to be aware of their execution environment, often used in cloud computing and data center automation.
SEE ALSO
virt-who(1), dmidecode(8), lscpu(1), hostnamectl(1), lsmod(8)