How can we check whether the machine is a physical or virtual one in Linux?
Which command can be used?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
If you've got systemd installed, it comes with
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.
lshw will give you system information:
sudo apt-get install lshw
sudo lshw -class system
Similar question in serverfault:
And my answer :-)