How can we check whether the machine is a physical or virtual one in Linux?

Which command can be used?

  • 1
    Was there a reason you tagged this question redhat-enterprise-linux? Or is the linux tag more appropriate? Please edit your tags as necessary. Aug 7, 2017 at 23:50

3 Answers 3


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

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

me@vm:~$ systemd-detect-virt 

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.
  • 4
    You can also do something equivalent with dmidecode
    – davidgo
    Aug 7, 2017 at 23:48

Similar question in serverfault:

VMware Linux Server — how can you tell if you are a vm or real hardware?

And my answer :-)

hostnamectl status

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.