Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

Is there a way to tell whether a host is a physical one or a VM and which virtual container it is running out of (e.g. VirtualBox or VMWare)? I was wondering if that info may be in /etc some place.

share|improve this question

marked as duplicate by Gilles, slm, Anthon, jasonwryan, Joseph R. Sep 11 '13 at 0:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

any chance cat /etc/issue will bring something? Or some uname variant? – vfbsilva Aug 21 '13 at 14:46
i get Ubuntu 12.04.2 LTS \n \l from /etc/issue – amphibient Aug 21 '13 at 14:47
dmesg | grep bare – innocent-world Aug 21 '13 at 18:36
up vote 1 down vote accepted

you can install the facter package, and then

facter virtual

will tell you if it is a virtual.

or you can use dmidecode to examine your system. look for Product Name in the output.

share|improve this answer
I did run facter on my machine and I get facter virtual vmware_server But this is a real ubuntu machine. I do have a vmware machine turned off here. Am I missunderstanding the usage of facter? – vfbsilva Aug 21 '13 at 14:53
yeah in this case, it is telling you that it is a virtual machine host (not a vm, which will just say vmware). what is the Product Name if you run dmidecode? In my experience, dmidecode is more intuitive to understand. – johnshen64 Aug 21 '13 at 14:56
yes, it worked on my Ubuntu VM – amphibient Aug 21 '13 at 14:57
@johnshen64 no idea: dmidecode | grep product returns empty – vfbsilva Aug 21 '13 at 14:59
use grep -i, as you are using difference cases than the string that I listed. thanks! – johnshen64 Aug 21 '13 at 15:03

There is usually no information in /etc that you can use to detect if the host is running as a VM.

But you can look at the hardware in /proc and /sys or (better) use tools like lspci.

The easiest way, however, is to use imvirt, which does exactly what you need. It supports lots of different VMs. At least in Debian-based distributions you can install it via the package manager.

share|improve this answer

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