6

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
  • 2
    If you see the message on the screen saying something like system has halted, then yes.
    – user3463
    Commented Jan 16, 2011 at 0:33
  • Wait... you go to Power > Power Off in the shell?
    – Hello71
    Commented Feb 12, 2011 at 21:55
  • No, after issuing the shutdown command via the shell, I wait for the system to halt, and then in the VM player GUI go to Power > Power Off
    – stevebot
    Commented Feb 12, 2011 at 22:09

3 Answers 3

7

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.

3
  • If you are impatient, you can force a few disk flushes and hit the deck: sync;sync;sync;halt
    – Linker3000
    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 with chkconfig acpid on and start the service now with service acpid start Commented Apr 22, 2014 at 13:18
4

You're close; the proper command is:

sudo /sbin/shutdown **-h** now
  1. Assuming that the sudo package is installed; otherwise, use su or similar.
  2. Without the asterisks, of course.

This will shutdown then halt the computer.

2
  • 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
    – g19fanatic
    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.
    – crmpicco
    Commented Apr 4, 2014 at 17:01
0

Without using VMWare Tools, On a VM CentOS machine the following command works fine.

shutdown
1
  • 1
    OP has stated that this is what he is already doing.
    – Patrick R.
    Commented Jan 30, 2017 at 16:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .