Generally, one uses the shutdown
command. It allows a time delay and warning message before shutdown or reboot, which is important for system administration of multiuser shell servers; it can provide the users with advance notice of the downtime.
As such, the shutdown command has to be used like this to halt/switch off the computer immediately (on Linux and FreeBSD at least):
shutdown -h now
Or to reboot it with a custom, 30 minute advance warning:
shutdown -r +30 "Planned software upgrades"
After the delay, shutdown
tells init
to change to runlevel 0 (halt) or 6 (reboot). (Note that omitting -h
or -r
will cause the system to go into single-user mode (runlevel 1), which kills most system processes but does not actually halt the system; it still allows the administrator to remain logged in as root.)
Once system processes have been killed and filesystems have been unmounted, the system halts/powers off or reboots automatically. This is done using the halt
or reboot
command, which syncs changes to disks and then performs the actual halt/power off or reboot.
On Linux, if halt
or reboot
is run when the system has not already started the shutdown process, it will invoke the shutdown
command automatically rather than directly performing its intended action. However, on systems such as FreeBSD, these commands first log the action in wtmp
and then will immediately perform the halt/reboot themselves, without first killing processes or unmounting filesystems.
Best Answer
There is no difference in them. Internally they do exactly the same thing:
reboot
uses theshutdown
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 theSIGKILL
signal (still found in sources, can be invoked with-f
option), in most recent distros it defaults to the more graceful and init friendlyinit 1 -> shutdown -r
. This ensures that daemons clean up themselves before shutdown.init 6
tells theinit
process to shutdown all of the spawned processes/daemons as written in the init files (in the inverse order they started) and lastly invoke theshutdown -r now
command to reboot the machineToday 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 belowThere is a small explanation taken from manpages of why the
reboot -f
is not safe:Edit:
Forgot to mention, in upcoming RHEL distributions you should use the new
systemctl
command to issue poweroff/reboot. As stated in the manpages ofreboot
andshutdown
they are "a legacy command available for compatibility only." and thesystemctl
method will be the only one safe.