Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

Is there any way to find out if the OS i'm running (actually installing) is running in a VMWare machine. I need to disable ntp settings if the automated install is done on a virtual machine but keep them enabled if not. VMWare tools are not installed when this check is done.

share|improve this question
up vote 1 down vote accepted
 count=$(lshw | grep -i vmware | wc -l) ; if [ "$count" -gt 0 ] ; then echo "disable ntp" ; else echo "enable ntp" ; fi

Obviously change the echo's to the commands you want.

Note: this will only work for VMware. You'll need to make that grep -i "vmware\|virtualbox\|xen" or something similar (look at the lshw output on virtualbox or xen to see what the exact strings are) if you're using different virtualisation systems.

share|improve this answer
May also work to just look at /proc/cpuinfo with a similar grep statement (less processing than lshw). – Kees Cook Nov 1 '10 at 17:43
@Kees-Cook: nah, /proc/cpuinfo on my VMware claims to be an Intel Xeon. – maco Nov 1 '10 at 19:24

For VMWare, the vmware-checkvm tool can help. It's part of the open-vm-tools package.

share|improve this answer

Can you determine this post-installation? If so, I'd write a script to run after installing VMware tools and adjust system daemons then. Pre-installation, it could be difficult to come up with a universal solution to the problem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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