CentOS, Fedora and RedHat are Linux distributions of the same family. These distributions provides different ways and command in order to restart. In this tutorial we will look different ways to restart CentOS, Fedora and RedHat and their affect to the system.
CentOS,Fedora和RedHat是同一家族Linux发行版。 这些发行版提供了不同的方式和命令以重新启动。 在本教程中,我们将寻找重启CentOS,Fedora和RedHat及其对系统的影响的不同方法。
用关机命令重新启动 (Restart with Shutdown Command)
shutdown
command is the most common way to stop or restart the system. Without providing an option shutdown will shutdown the system but will not restart. We will provide -r
option in order to restart the system like below.
shutdown
命令是停止或重新启动系统的最常用方法。 如果不提供选项,则关闭将关闭系统,但不会重新启动。 我们将提供-r
选项以重启系统,如下所示。
$ shutdown -r
在指定时间使用关机命令重新启动 (Restart with Shutdown Command At Specified Time)
By default shutdown operation starts immediately. But we have the option to reboot at specified time in the future. We generally use minutes after to reboot. In this example we will restart the system after 5
minutes by providing +5
option.
默认情况下,关闭操作会立即开始。 但是我们可以选择在将来的指定时间重新启动。 我们通常在几分钟后重新启动。 在此示例中,我们将通过提供+5
选项在5
分钟后重新启动系统。
$ shutdown -r +5
![Restart with Shutdown Command At Specified Time](https://img-blog.csdnimg.cn/img_convert/165bd3e0dbff27b9942f8ab7c111ad2a.png)
使用重新启动命令重新启动(Restart with Reboot Command)
Reboot is actually not a command. reboot
is a script which is alias for shutdown -r
. So their affect will be the same. We can use reboot
command like below. reboot
also does some hard disk maintenance like sync etc.
重新启动实际上不是命令。 reboot
是一个脚本,它是shutdown -r
别名。 因此,它们的影响将是相同的。 我们可以使用如下所示的reboot
命令。 reboot
还会执行一些硬盘维护,例如同步等。
$ reboot
用停止命令重新启动 (Restart with Halt Command)
We can use halt
command with --reboot
option. halt
command provides some log to the utmp
. Most init scripts call halt
for logging options. We can restart system like below with halt
command.
我们可以将halt
命令与--reboot
选项一起使用。 halt
命令向utmp
提供一些日志。 大多数初始化脚本都会调用halt
来halt
日志记录选项。 我们可以使用halt
命令重启系统,如下所示。
$ halt --reboot
从初始化级别重新启动 (Restart with Init Level)
Linux uses init levels in order to specify current working mode. Level 6 is used to specify the reboot state. We can use init
command in order to change Level 6 which will reboot the system. By using init related init files will be executed and invoked.
Linux使用初始化级别来指定当前的工作模式。 级别6用于指定重新引导状态。 我们可以使用init
命令来更改Level 6,它将重新启动系统。 通过使用init,相关的init文件将被执行和调用。
$ init 6