linux重启网络命令实例
Shutting down the Linux systems can be done in different ways. We can use provided GUI like KDE, GNOME, Unity ect. to shutdown system. But what will we do if we have only console access to the system. We can use shutdown
command to shutdown and reboot system.
关闭Linux系统可以通过不同的方式完成。 我们可以使用KDE,GNOME,Unity等提供的GUI。 关闭系统。 但是,如果我们只有控制台访问系统,我们将怎么办。 我们可以使用shutdown
命令关闭并重启系统。
句法 (Syntax)
shutdown [OPTIONS...] [TIME] [MESSAGE...]
关机系统 (Shutdown System)
We can use shutdown
command without providing any option or parameter to simply shutdown the system. We need required privileges like root to shutdown a linux system.
我们可以使用shutdown
命令,而无需提供任何选项或参数来简单地关闭系统。 我们需要像root这样的必需特权才能关闭linux系统。
$ shutdown
在指定时间关机 (Shutdown At Specified Time)
Sometimes we need more time before shutting down the system. We can provide some interval before the shutdown command take effect with the time value
有时我们需要更多时间才能关闭系统。 我们可以在关闭命令生效之前提供一些时间间隔
In this example we will shutdown the system after 5 minutes now.
在此示例中,我们将在5分钟后关闭系统。
$shutdown -h 5
重启系统 (Restart System)
We can restart the Linux system with shutdown command. This will first shutdown system and then restart. We should provide -r
option which means restart.
我们可以使用shutdown命令重新启动Linux系统。 这将首先关闭系统,然后重新启动。 我们应该提供-r
选项,这意味着重新启动。
$shutdown -r
在指定时间重启 (Restart At Specified Time)
We can also restart the system at specified time. We will use -r
option again by adding the interval value we want to wait. In this example we want to restart the system after 10 minutes.
我们也可以在指定时间重新启动系统。 我们将通过添加要等待的间隔值来再次使用-r
选项。 在此示例中,我们要在10分钟后重新启动系统。
$ shutdown -r 10
重新启动时跳过文件系统检查(fsck) (Skip File System Check (fsck) at Reboot)
Linux operating systems generally check a file system at start if there is some problems. This file system check may take some time. We can skip this file system check with -f
option.
Linux操作系统通常在启动时会检查文件系统是否存在问题。 此文件系统检查可能需要一些时间。 我们可以使用-f
选项跳过此文件系统检查。
$ shutdown -r -f
向系统用户发送消息 (Send Message To System Users)
Linux operating system is designed to work multi user. At given time there may be more than one user connected to the Linux system. Shutting down will interrupt their connection and work too. We can send some message with shutdown
command. As stated in syntax the message it the last part of the shutdown command.
Linux操作系统旨在用于多用户。 在给定的时间,可能有多个用户连接到Linux系统。 关机将中断他们的连接并正常工作。 我们可以使用shutdown
命令发送一些消息。 如语法中所述,消息是关闭命令的最后一部分。
In this example we will send message This system will shutdown in 5 minutes
在此示例中,我们将发送消息This system will shutdown in 5 minutes
$shutdown 5 "This system will shutdown in 5 minutes"
重启系统 (Reboot System)
We have alternative command to reboot the Linux system. We can simply use reboot
command for this.
我们有替代命令来重新引导Linux系统。 我们可以简单地使用reboot
命令。
$ reboot
重启权限 (Permissions For Reboot)
In Linux system root
is the highest privileged administrator account. In order to reboot or shutdown we need root privileges. If we try to reboot without this privileges we will get errors like following.
在Linux系统中, root
是特权最高的管理员帐户。 为了重新引导或关闭,我们需要root特权。 如果我们尝试在没有此特权的情况下重新启动,则会收到类似以下的错误。
- Failed to set wall message, ignoring: Interactive authentication required. 无法设置墙消息,忽略:需要交互式身份验证。
- Failed to reboot system via logind: Interactive authentication required. 无法通过登录重新启动系统:需要交互式身份验证。
- Failed to open /dev/initctl: Permission denied 无法打开/ dev / initctl:权限被拒绝
- Failed to talk to init daemon.无法与init守护进程对话。
So we have provide root
privileges with the sudo
command like below.
因此,我们通过sudo
命令提供了root
特权,如下所示。
$ sudo reboot
翻译自: https://www.poftut.com/linux-shutdown-reboot-command-tutorial-examples/
linux重启网络命令实例