How do you confirm through SSH if you're using a virtual server or physical/metal server?
There are multiple ways to find out through terminal / SSH.
Method 1: systemd-detect-virt command
Simply run the below command:
systemd-detect-virt
This will return the name of hypervisor (virtualization environment) - for example, kvm, vmware, microsoft, oracle, xen etc.
If you're using a physical server then, of course, it will return nothing.
Method 2: hostnamectl command (General Info)
Above command displays a high-level summary of your system, including a specific line for virtualization.
Method 3: hostnamectl command
Result: Look for the "Virtualization:" field. If it's missing or says none, the machine is physical.
Method 4: dmidecode command (Hardware Level)
This tool reads the system's Desktop Management Interface (DMI) table to find hardware manufacturer details.
Method 5: sudo dmidecode -s system-product-name command
Physical: Returns a brand model like PowerEdge R640 or ThinkPad X1.
Virtual: Returns names like VirtualBox, VMware Virtual Platform, or KVM.
Method 6: dmidecode command (Hardware Level)
This tool reads the system's Desktop Management Interface (DMI) table to find hardware manufacturer details.
Method 7: sudo dmidecode -s system-product-name command
Physical: Returns a brand model like PowerEdge R640 or ThinkPad X1.
Virtual: Returns names like VirtualBox, VMware Virtual Platform, or KVM.
Method 8: lscpu (CPU Flags)
Useful for seeing if a hypervisor is managing the processor.
Method 9: lscpu | grep Hypervisor
Result: If you see Hypervisor vendor: KVM (or similar), it's a VM. If the command returns nothing, it is likely physical.
Method 10: virt-what (Detailed Script)
If you need high accuracy (especially for detecting specific clouds or rare hypervisors), use the virt-what script.
Install: sudo apt install virt-what or sudo yum install virt-what
Run: sudo virt-what
Physical: Returns nothing (empty output).
Virtual: Returns a list of "facts" about the VM environment.