zoukankan      html  css  js  c++  java
  • Linux—系统关机命令详解

    不管是重启系统还是关闭系统,首先要运行 sync 命令,把内存中的数据写到磁盘中。将数据由内存同步写入到硬盘中。

    [root@localhost ~]# sync
    

    一、shutdown命令

    # 立刻关机,now相当于时间为0
    [root@localhost ~]# shutdown -h now   
    # 系统在今天的20:25分关机,若在21:25才执行此命令,则隔天才关机
    [root@localhost ~]# shutdown -h 20:25
    # 系统在十分钟后关机
    [root@localhost ~]# shutdown –h +10 
    # 这个命令告诉大家,这台机器将在10分钟后关机,并且会显示在登陆用户的当前屏幕中。
    [root@localhost ~]# shutdown –h 10 'This server will shutdown after 10 mins' 
    
    # 系统立刻重启
    [root@localhost ~]# shutdown –r now 
    # 系统十分钟后重启
    [root@localhost ~]# shutdown –r +10 
    [root@localhost ~]# shutdown –r 30  ' the system will reboot after 30 mins'
    

    二、reboot命令

    # 系统立刻重启,等同于 shutdown –r now
    [root@localhost ~]# reboot

    三、halt命令

    # 立刻关闭系统,等同于 shutdown –h now 和 poweroff
    [root@localhost ~]# halt

    四、poweroff命令(网上说是halt命令的链接,基本用法和 halt 差不多)

    # 立刻关闭系统,直接关机。不像shutdown先关闭服务,再关机
    [root@localhost ~]# poweroff

    五、init命令

    # 系统关机命令:init 0 #立即将系统运行级别切换为0,即关机
    [root@localhost ~]# init 0
    
    # 系统重启命令:init 6 #立即将系统运行级别切换为6,即重启
    [root@localhost ~]# init 6

    Linux系统有7个运行级别(runlevel)
    run level 0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动。关机
    run level 1:单用户工作状态,root权限,用于系统维护,禁止远程登陆
    run level 2:多用户状态(没有NFS)
    run level 3:完全的多用户状态(有NFS),登陆后进入控制台命令行模式。纯命令行模式
    run level 4:系统未使用,保留
    run level 5:X11控制台,登陆后进入图形GUI模式。含有图形界面模式
    run level 6:系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动。重启

    https://www.runoob.com/linux/linux-system-boot.html

    https://www.cnblogs.com/zhangbing12304/p/8185346.html

  • 相关阅读:
    (二)shell中的变量
    (一)shell脚本入门
    java的动态代理机制详解
    docker学习
    一、Spring Boot 入门
    如何高效的利用博客园?
    CMake入门指南
    TortoiseSVN安装使用
    TortoiseSVN配置和使用教程
    脑电采集 地电极和参考电极的作用和区别
  • 原文地址:https://www.cnblogs.com/liuhaidon/p/11599591.html
Copyright © 2011-2022 走看看