What is the difference between the "shutdown" and "reboot" commands?
Problem Description
What is the difference between the "shutdown" and "reboot" commands?
Solution
Both /etc/shutdown and /etc/reboot can be used to either halt or reboot
your system. Which command to use depends upon several factors, including
how many users are on the system, how quickly you need to shut down the
system and what run-level the system is operating in.
"shutdown" is generally used when the system is in a multi-user state
such as run-level 2. It uses "kill -15" to terminate running processes,
which allows them to terminate naturally within a grace period (default
of 60 seconds), ensuring the integrity of the file system.
"shutdown" also performs these tasks:
* changes the current working directory to /
* updates all superblocks
* shuts down the accounting subsystem
* halts all daemon processes
* writes the contents of all I/O buffers to disk
* unmounts all file systems
Finally, the system is put into single-user mode (run-level s) and
/etc/reboot is called if applicable.
"shutdown" allows the superuser to warn all users currently logged into
the system, that it will be shut down and the superuser can specify a
grace period for users to log out, before the shut down process
commences.
The system administrator has the ability to customise the shut down
procedure through the use of user-supplied scripts placed in the
/etc/shutdown.d directory. This exists for users who have specialised
shutdown procedure requirements, such as shutting down databases prior
to the system shutting down.
One further functionality associated with the "shutdown" command is the
ability of the system administrator to authorise certain users to
execute "shutdown". This is done by editing the /etc/shutdown.allow
file accordingly. However, even though other users may be privileged to
use "shutdown" to halt or reboot the system, only the superuser may put
the system into single-user mode.
"reboot" is generally used to reboot or halt the system once in
single-user mode. It's default action is to "sync" all disks and then
reboot the system.
To terminate currently running processes, it uses "kill -9" which
terminates them immediately. This is dangerous, as processes are not
allowed to terminate naturally and it may have undesirable
repercussions, such as loss of data.
As all processes are terminated without a grace period, "reboot" is
faster than "shutdown" and, therefore, may be used when the system
administrator needs to bring the system down very quickly.
"reboot" also allows the superuser to specify a certain time to halt or
reboot the system, and to send a message to users currently logged on,
to inform them of the system's impending halt or reboot.
For a full explanation of "shutdown" and "reboot", refer to the manual
pages for shutdown(1m) and reboot(1m), respectively.
Problem Description
What is the difference between the "shutdown" and "reboot" commands?
Solution
Both /etc/shutdown and /etc/reboot can be used to either halt or reboot
your system. Which command to use depends upon several factors, including
how many users are on the system, how quickly you need to shut down the
system and what run-level the system is operating in.
"shutdown" is generally used when the system is in a multi-user state
such as run-level 2. It uses "kill -15" to terminate running processes,
which allows them to terminate naturally within a grace period (default
of 60 seconds), ensuring the integrity of the file system.
"shutdown" also performs these tasks:
* changes the current working directory to /
* updates all superblocks
* shuts down the accounting subsystem
* halts all daemon processes
* writes the contents of all I/O buffers to disk
* unmounts all file systems
Finally, the system is put into single-user mode (run-level s) and
/etc/reboot is called if applicable.
"shutdown" allows the superuser to warn all users currently logged into
the system, that it will be shut down and the superuser can specify a
grace period for users to log out, before the shut down process
commences.
The system administrator has the ability to customise the shut down
procedure through the use of user-supplied scripts placed in the
/etc/shutdown.d directory. This exists for users who have specialised
shutdown procedure requirements, such as shutting down databases prior
to the system shutting down.
One further functionality associated with the "shutdown" command is the
ability of the system administrator to authorise certain users to
execute "shutdown". This is done by editing the /etc/shutdown.allow
file accordingly. However, even though other users may be privileged to
use "shutdown" to halt or reboot the system, only the superuser may put
the system into single-user mode.
"reboot" is generally used to reboot or halt the system once in
single-user mode. It's default action is to "sync" all disks and then
reboot the system.
To terminate currently running processes, it uses "kill -9" which
terminates them immediately. This is dangerous, as processes are not
allowed to terminate naturally and it may have undesirable
repercussions, such as loss of data.
As all processes are terminated without a grace period, "reboot" is
faster than "shutdown" and, therefore, may be used when the system
administrator needs to bring the system down very quickly.
"reboot" also allows the superuser to specify a certain time to halt or
reboot the system, and to send a message to users currently logged on,
to inform them of the system's impending halt or reboot.
For a full explanation of "shutdown" and "reboot", refer to the manual
pages for shutdown(1m) and reboot(1m), respectively.
编辑回复