Usually, I just do a sudo /sbin/shutdown now when in my VM and wait for it to logout into the bash shell. Then after that I just go to Power > Power Off. Is this the right way to shutdown my CentOS VM?
3 Answers
Presuming VMware: if you have the vmware-tools installed in your VM, you should be able to issue the shutdown -h now
command and it will power-off the VM for you. This works for me with C4 and C5 VMs, on Server-1 and -2, Workstation 6.x, and ESX/ESXi.
-
If you are impatient, you can force a few disk flushes and hit the deck: sync;sync;sync;halt Commented Feb 12, 2011 at 22:07
-
shutdown -h now
works on many virtualisation platforms, not just vmware. Also in vmware you don't even need vmware-tools installed for the command (run on the guest) to power off the VM if the OS is recent and not too minimal like some router Linux distros. Usually hypervisors emulate a motherboard with ACPI features so shutdown requires ACPI enabled in the guest. I've noticed that if you do a minimal CentOS install, it does not enable this for you. Commented Apr 22, 2014 at 13:02 -
With CentOS you can ensure the ACPI daemon is installed with
yum install acpid
Then ensure the daemon starts at boot withchkconfig acpid on
and start the service now withservice acpid start
Commented Apr 22, 2014 at 13:18
You're close; the proper command is:
sudo /sbin/shutdown **-h** now
- Assuming that the
sudo
package is installed; otherwise, usesu
or similar. - Without the asterisks, of course.
This will shutdown then halt the computer.
-
unixhelp.ed.ac.uk/CGI/man-cgi?shutdown+8 shutdown manual page... also look at the
-r
method to restart your computer. These are basic linux commands and really have nothing 'special' to do with a VM Commented Jan 16, 2011 at 4:20 -
Yes, I can confirm this works on CentOS 5.6 (Final) running as a VM on Win7 with VirtualBox.– crmpiccoCommented Apr 4, 2014 at 17:01
Without using VMWare Tools, On a VM CentOS machine the following command works fine.
shutdown
-
1
system has halted
, then yes.