Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 as init 6
  • It's probably better to get in the habit of using init 6 instead of reboot as it is safer and would work better cross-distro, but the default behavior of reboot has been changed to try and prevent errors / dataloss if someone does use it.

Is that about right? If not, what am I missing?

share|improve this question
add comment

1 Answer 1

up vote 15 down vote accepted

There is really never any compelling reason to use init 6 instead of reboot, unless:

  • For some reason you are missing the reboot executable, or
  • You are deliberately trying to avoid notifying users that the system is going down.

reboot (so long as you don't run reboot --force) is actually the "softer" way to shut down.

Consider:

init 6 will run all of the shutdown scripts in /etc/init/rc.* as it reduces system's runlevel

But the reboot command, called without the --force flag, only directly reboots the system (via the reboot system call) when one of these two situations applies:

  • The system is in runlevel 0 (single user mode), so there is no reduction of runlevel that can occur, so no shutdown scripts are automatically run.
  • The system is in runlevel 6. What init 6 does it to put the system in runlevel 6. Again, there's nothing running init 6 will do that running the reboot command won't do.

Otherwise, sudo reboot is equivalent to sudo shutdown -r now. This does all the nice things sudo init 6 does, but also:

  • notifies users that the system is going down.
  • prevents new logins (though they probably wouldn't succeed anyway).
  • is more intuitive and self-documenting than 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 when init is run by the user (like when you run sudo init 6), it actually runs telinit (see man init). telinit is what actually changes runlevels. And man telinit tells us:

Normally you would use the shutdown(8) tool to halt or reboot the system, or to bring it down to single-user mode.

share|improve this answer
    
I have Alienware X51 dell pc, where i have installed Ubuntu 13.04 and kernel 3.11. When i do $ init 6 , it reboots and sometimes BIOS keep showing forever. IS it because i am using init 6 and not reboot command? –  YumYumYum Sep 8 '13 at 8:49
1  
@YumYumYum I don't see why using init 6 would cause this. When you use reboot instead of init 6, does it always get past the BIOS? –  Eliah Kagan Sep 8 '13 at 17:23
1  
I have updated the BIOS firmware from A00 to A02, since then my reboot or init 6 both works so it seems like BIOS issue was. Thank you. –  YumYumYum Sep 10 '13 at 21:54
add comment

Your Answer

 
discard

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.