Suppose I have logged in through ssh
to a given Linux machine, knowing nothing about it.
How can I quickly check what virtual environment (VMWare, VirtualBox, LXC, etc., if any) is currently running on this machine?
If you're logging into a Virtual Machine, some of the hardware listed should be related to that Virtual Machine. Using a command like dmidecode | grep VMware
should let you see if you're logged into a VM from VMware.
If you're not sure about what VM are you looking for, you could use just dmidecode | head -n 40
just to take a look at the system manufacturer, which should be a VM name if the system is running on one.
I like virt-what, which encapsulates a lot of this in an easy interface:
# virt-what # VMware
vmware
# virt-what # KVM/Qemu (libvirt)
kvm
# virt-what # A real physical server
# virt-what # VirtualBox
virtualbox
There are multiple ways to test it.
1) dmesg |grep -i hypervisor detected
==> Hypervisor detected: VMware
2) dmidecode -s system-product-name
==> VMware Virtual Platform
These should work on most of the linux kernels
dmesg
to view hardware type of, for example, the harddrive. Trydmesg|egrep -i 'vmware|vbox'