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
add comment

4 Answers

up vote 23 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
add comment

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
add comment

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
add comment

when you call reboot command you tell kernel too reboot. reboot, halt and poweroff are a family command. but init 6 means : please go to runlevel 6, runlevel 6 reserved for rebooting system. shutdown is a flexible command, even you can run a runlevel.

NOTE: difference between shutdown and reboot : shutdown is secure!

share|improve this answer
11  
Could you please include an explanation of why shutdown is secure and reboot is not? –  N.N. Feb 9 '13 at 12:41
    
One this aspect user is user management, if you know in depth, please man page of shutdown. –  Mohsen Pahlevanzadeh Feb 9 '13 at 20:42
    
Downvoted. reboot calls shutdown unless --force is used in which case it will call init directly. EITHER WAY init is called as the last step (with the appropriate arguments) to bring the box into the specified runlevel. Only benefit of using shutdown is that it notifies logged-in users of the pending change in runlevel and allows you to set a time delay. –  h3rrmiller Feb 12 '13 at 18:21
    
In other words shutdown is no more "secure" than any of the other methods... –  h3rrmiller Feb 12 '13 at 18:28
    
Of course, it's related to user to how invoke shutdown command.You can use securely or insecurely. –  Mohsen Pahlevanzadeh Feb 12 '13 at 22:05
show 6 more comments

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.