Is reboot the same as init 6 for ubuntu?
I'm running Ubuntu 12.04 on Amazon EC2. When ssh'ed into the box I can type runlevel
and I get:
N 2
Looking at man reboot
I see that:
When called with --force or when in runlevel 0 or 6, this tool invokes the reboot(2) system call itself and directly reboots the system. Otherwise this simply invokes the shutdown(8) tool with the appropriate arguments.
If I read man shutdown 8
I see:
shutdown arranges for the system to be brought down in a safe way. All logged-in users are notified that the system is going down and, within the last five minutes of TIME, new logins are prevented.
My basic understanding about the difference between reboot
and init 6
is:
- On other distros and perhaps older distros
reboot
would just unmount the disks and basically flick the power switch without running any shutdown scripts init 6
will run all of the shutdown scripts in/etc/init/rc.*
as it reduces system's runlevel- On newer versions of Ubuntu the
reboot
command without--force
or-f
will run the shutdown command which does would basically do the same thing asinit 6
- It's probably better to get in the habit of using
init 6
instead ofreboot
as it is safer and would work better cross-distro, but the default behavior ofreboot
has been changed to try and prevent errors / dataloss if someone does use it.
Is that about right? If not, what am I missing?
There is really never any compelling reason to use
init 6
instead ofreboot
, unless:reboot
executable, orreboot
(so long as you don't runreboot --force
) is actually the "softer" way to shut down.Consider:
But the
reboot
command, called without the--force
flag, only directly reboots the system (via thereboot
system call) when one of these two situations applies:init 6
does it to put the system in runlevel 6. Again, there's nothing runninginit 6
will do that running thereboot
command won't do.Otherwise,
sudo reboot
is equivalent tosudo shutdown -r now
. This does all the nice thingssudo init 6
does, but also:sudo init 6
.If you're on a system with only you logged in, and only local logins, there is nothing wrong with using
init 6
to reboot. If that's how you prefer to reboot, then by all means, go ahead--you're not harming anything by doing so. But there's also nothing objectively preferable about doing it this way.init
's own documentation says it's not the normal way to shut down or reboot the system. Consider that wheninit
is run by the user (like when you runsudo init 6
), it actually runstelinit
(seeman init
).telinit
is what actually changes runlevels. Andman telinit
tells us: