关于linux:Linux系统中有关机命令有哪些呢

6次阅读

共计 8407 个字符,预计需要花费 22 分钟才能阅读完成。

<section id=”nice” data-tool=”mdnice 编辑器 ” data-website=”https://www.mdnice.com” style=”font-size: 16px; color: black; padding: 0 10px; line-height: 1.6; word-spacing: 0px; letter-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, ‘PingFang SC’, Cambria, Cochin, Georgia, Times, ‘Times New Roman’, serif;”><p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>Linux 零碎 关机命令有哪些呢?良许教程网为您解答!相熟 linux 的敌人应该晓得咱们在 linux 零碎中罕用到的关机命令有:shutdownhaltpoweroffinit;重启命令有:reboot。上面本文就次要介绍一些罕用的关机命令以及各种关机命令之间的区别和具体用法。
以下是比拟罕用的一些关机命令
1、halt 立即关机
2、poweroff 立即关机
3、shutdown -h now 立即关机 (root 用户应用)
4、shutdown -h 10 10 分钟后自动关机
注:如果是通过 shutdown 命令设置关机的话,能够用 shutdown -c 命令勾销重启。</p>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”> 重启命令:</p>
<pre class=”custom” data-tool=”mdnice 编辑器 ” style=”margin-top: 10px; margin-bottom: 10px;”>2、shutdown -r now 立即重启 (root 用户应用)
3、shutdown -r 10 过 10 分钟主动重启(root 用户应用)
4、shutdown -r 20:35 在工夫为 20:35 时候重启(root 用户应用)
</pre>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”> 注:如果是通过shutdown 命令设置重启的话,能够用 shutdown -c 命令勾销重启。
上面咱们追随良许教程网的小编来看看 linux 的这些具体的关机命令之间的区别以及各自的用法
1.shutdown 平安的关机命令
对于 shutdown 命令,它是大家都举荐的一个平安的命令,通过参数 - h 或 - r 的配合来实现关机或重启。不过在 linux 零碎中只有领有 root 权限才能够应用这个命令。所以,尽管大家都举荐用这个命令,然而这个命令用起来真的不太不便:想要用这个命令吗?先去取得 root 权限吧。shutdown 执行关机,是送信号给 init,要求它扭转运行级别,以此来关机。关机或重启实际上是运行级别的调整,所以咱们也能够用 init 间接调整运行级别来进行关机或重启。应用这个命令时,机器立刻关机或重启。它也须要 root 权限。
那么为什么说 shutdown 命令是平安地将零碎关机呢?
<img src=”https://pic.downk.cc/item/5fe1dcd63ffa7d37b37c87a5.jpg” alt=”linux 零碎 ” style=”margin: 0 auto; max-width: 100%; width: 100%; border-radius: 5px; display: block; margin-bottom: 15px; height: auto;”>
理论中有些用户会应用间接断掉电源的形式来敞开 linux,这是非常危险的。因为 linux 与 windows 不同,其后盾运行着许多过程,所以强制关机可能会导致过程的数据失落使零碎处于不稳固的状态。甚至在有的零碎中会损坏硬件设施。而在零碎关机前应用 shutdown 命令,系统管理员会告诉所有登录的用户零碎将要敞开。并且 login 指令会被解冻,即新的用户不能再登录。间接关机或者提早肯定的工夫才关机都是可能的,还有可能是重启。这是由所有过程〔process〕都会收到零碎所送达的信号〔signal〕决定的。
shutdown 执行它的工作是送信号〔signal〕给 init 程序,要求它扭转 runlevel。runlevel 0 被用来停机〔halt〕,runlevel 6 是用来从新激活〔reboot〕零碎,而 runlevel 1 则是被用来让零碎进入管理工作能够进行的状态,这是预设的。假设没有 - h 也没有 - r 参数给 shutdown。要想理解在停机〔halt〕或者从新开机〔reboot〕过程中做了哪些动作?你能够在这个文件 /etc/inittab 里看到这些 runlevels 相干的材料。</p>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>shutdown 参数阐明:</p>
<ul data-tool=”mdnice 编辑器 ” style=”margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: disc;”>
<li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”><p style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>[-t] 在扭转到其它 runlevel 之前,通知 init 多久当前关机。</p>
</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”><p style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>[-r] 重启计算器。</p>
</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”><p style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>[-k] 并不真正关机,只是送正告信号给每位登录者〔login〕。</p>
</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”><p style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>[-h] 关机后关闭电源〔halt〕。</p>
</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”><p style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>[-n] 不必 init 而是本人来关机。不激励应用这个选项,而且该选项所产生的结果往往不总是你所预期失去的。</p>
</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”><p style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>[-c] cancel current process 勾销目前正在执行的关机程序。所以这个选项当然没有工夫参数,然而能够输 </p>
</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”><p style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”> 一个用来解释的讯息,而这信息将会送到每位使用者。</p>
</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”><p style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>[-f] 在重启计算器〔reboot〕时疏忽 fsck。</p>
</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”><p style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>[-F] 在重启计算器〔reboot〕时强制 fsck。</p>
</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”><p style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>[-time] 设定关机〔shutdown〕前的工夫。</p>
</section></li></ul>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>2.halt 最简略的关机命令 </p>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”> 用 halt 命令来关机时,理论调用的是 shutdown -h。halt 执行时将杀死利用过程,执行 sync 零碎调用文件系统写操作实现后就会进行内核。
halt 参数阐明:</p>
<ul data-tool=”mdnice 编辑器 ” style=”margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: disc;”>
<li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”>[-n] 避免 sync 零碎调用,它用在用 fsck 修补根分区之后,以阻止内核用老版本的超级块〔superblock〕笼罩修补过的超级块。</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”>[-w] 并不是真正的重启或关机,只是写 wtmp〔/var/log/wtmp〕纪录。</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”>[-d] 不写 wtmp 纪录〔已蕴含在选项 [-n] 中〕。</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”>[-f] 没有调用 shutdown 而强制关机或重启。</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”>[-i] 关机〔或重启〕前关掉所有的网络接口。</section></li><li><section style=”margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;”>[-p] 该选项为缺省选项。就是关机时调用 poweroff。</section></li></ul>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>3.poweroff 罕用的关机命令 </p>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”> 对于 poweroff,网上说它是 halt 命令的链接,根本用法和 halt 差不多,这里就不多说了。</p>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>4.init</p>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>init 是所有过程的先人,他是 Linux 零碎操作中不可短少的程序之一。它的过程号始终为 1,所以发送 TERM 信号给 init 会终止所有的用户过程,守护过程等。shutdown 就是应用这种机制。init 定义了 8 个运行级别 (runlevel),init 0 为关机,init 1 为重启。</p>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>5.reboot 重启命令 </p>
<p data-tool=”mdnice 编辑器 ” style=”font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0 0 20px; padding: 0; line-height: 1.8em; color: #3a3a3a;”>reboot 的工作过程差不多跟 halt 一样。不过它是引发主机重启,而 halt 是关机。它的参数与 halt 相差不多。
以上就是良许教程网为各位朋友分享的对于 Linux 零碎关机命令之间的区别和各自的用法。想要理解更多 Linux 相干常识记得关注公众号“良许 Linux”,或扫描下方二维码进行关注,更多干货等着你!
<img src=”https://lxlinux.superbed.verylink.top/item/5fe1af843ffa7d37b353b15f.jpg” alt=” 公众号 ” style=”margin: 0 auto; max-width: 100%; width: 100%; border-radius: 5px; display: block; margin-bottom: 15px; height: auto;”></p>
</section>

正文完
 0