When I issue the following:
sudo shutdown now
..my newly commissioned Ubuntu 14.04 server doesn't shut down. It stops with the following message:
* Stopping System V runlevel compatibility
Give root password for maintenance:
(or type Control-D to continue):
If I type in the root password, the machine simply sits there at the shell prompt.
Best Answer
Traditionally, the command
sudo shutdown now
will take you to the runlevel 1 (recovery mode); this will happen for both Upstart and SysV init. To get what you want, i.e., to shut down the computer properly, you need to give the-h
switch toshutdown
.One thing to note here is that
halt
will close all the processes, turn off the CPUs and return the control to a ROM monitor of the mainboard needing the user to press the power button to get the power supply turned off, whereaspoweroff
after turning off the CPUs will simply turn off the power supply resulting in a proper shutdown.The
-h
switch ofshutdown
will eitherhalt
orpoweroff
the computer, the decision will be taken by the system although in Ubuntu I have seen that it would normallypoweroff
the machine. To be sure of that, you can use the-P
switch withshutdown
topoweroff
the computer.To summarize, here are the commands available to
poweroff
(nothalt
) a computer:The
poweroff
andhalt
commands basically invokeshutdown
(except for thepoweroff -f
).sudo poweroff
andsudo halt -p
are exactly likesudo shutdown -P now
. The commandsudo init 0
will take you to the runlevel 0 (shutdown).Now what if you want to shut down forcefully, i.e., you don't want to wait for processes to close normally? In that case you can use:
This will not use
shutdown
. Rather, it will invoke thereboot(2)
system call (used for reboot, poweroff & halt) to power off the computer instantly.