Linux command to tell if the machine is physical or virtual

If you've got systemd installed, it comes with systemd-detect-virt.

me@real-machine:~$ systemd-detect-virt 
none

me@vm:~$ systemd-detect-virt 
qemu

Can detect many different types of virtualization and containers, too.

If don't have systemd, there is also virt-what which has a package at least on Debian (and considering where it comes from, unsurprisingly for RedHat too).

See also “Easy way to determine virtualization technology” on Unix & Linux for a bunch more approaches.


Using lshw will give you system information:

  1. Run the command: sudo apt-get install lshw
    • NOTE: This command may vary depending on the Linux distribution.
  2. Run the command: sudo lshw -class system
  3. This will show information about the system. For example, if the machine is a Dell or HP, that will be the product. In the case of a virtual machine, the product will be the name of the emulator.