9

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. – I say Reinstate Monica Aug 7 '17 at 23:50
8

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.

| improve this answer | |
10

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.
| improve this answer | |
  • 4
    You can also do something equivalent with dmidecode – davidgo Aug 7 '17 at 23:48
0

Similar question in serverfault:

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

And my answer :-)

hostnamectl status

| improve this answer | |

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.