Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I just want to know difference between in

  • reboot
  • init 6
  • shutdown -r now

and which is the safest and the best?

share|improve this question
    
The exact behavior of these three commands varies from operating system to operating system. –  Thorbjørn Ravn Andersen Sep 11 '13 at 22:38

4 Answers 4

up vote 32 down vote accepted

There is no difference in them. Internally they do exactly the same thing:

  • reboot uses the shutdown command (with the -r switch). The shutdown command used to kill all the running processes, unmount all the file systems and finally tells the kernel to issue the ACPI power command. The source can be found here. In older distros the reboot command was forcing the processes to exit by issuing the SIGKILL signal (still found in sources, can be invoked with -f option), in most recent distros it defaults to the more graceful and init friendly init 1 -> shutdown -r. This ensures that daemons clean up themselves before shutdown.

  • init 6 tells the init process to shutdown all of the spawned processes/daemons as written in the init files (in the inverse order they started) and lastly invoke the shutdown -r now command to reboot the machine

Today there is not much difference as both commands do exactly the same, and they respect the init scripts used to start services/daemons by invoking the shutdown scripts for them. Except for reboot -f -r now as stated below

There is a small explanation taken from manpages of why the reboot -f is not safe:

  -f, --force
    Force immediate halt, power-off, reboot. Don't contact the init system.

Edit:

Forgot to mention, in upcoming RHEL distributions you should use the new systemctl command to issue poweroff/reboot. As stated in the manpages of reboot and shutdown they are a legacy command available for compatibility only. and the systemctl method will be the only one safe.

share|improve this answer
    
Sometimes my reboot hangs at the SIGTERM, is there a way to know why, and also is there a way to timeout the reboot, such that if it takes too long, it will force a reboot? –  CMCDragonkai May 28 '14 at 2:35
    
Those RHEL versions are no longer "upcoming". ☺ As explained in more detail at unix.stackexchange.com/a/196014/5132, on such systemd operating systems there's no difference at all. They aren't even different programs. –  JdeBP Apr 13 at 19:27

Long story short, if you only use them for reboot, as you said, they are equally safe. As for best...there is no such thing.

share|improve this answer
    
Are they equally safe because they are equivalent or for some other reason? –  N.N. Feb 9 '13 at 12:42
    
I meant safe in the context of unmounting filesystems safely and bringing the system down for reboot carefully. Are there extra safety precautions needed? If so, which? –  schaiba Feb 9 '13 at 12:45
2  
Unless your distribution was designed by lunatics who decided that they didn't need six runlevels and rewired the commands to, say, runlevel 3. –  Shadur Feb 9 '13 at 16:12

On traditional unices, reboot and shutdown -r now are vastly different commands. Under typical usage, reboot is only safe to use in single user mode.

shutdown -r now is the canonical method to shutdown across different *nix's and safer to use in general and is functionally equivalent to init 6.

init(8) reboot(8)

share|improve this answer

On FreeBSD there is a difference between reboot and shutdown -r now. From the reboot man page:

Normally, the shutdown(8) utility is used when the system needs to be halted or restarted, giving users advance warning of their impending doom and cleanly terminating specific programs.

share|improve this answer
    
This is not a BSD question, though, as evidenced by the tag on the question and use of a System 5 run-level in one of the commands. ☺ –  JdeBP Apr 14 at 9:51

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.