修改CentOS7系統預設運行層級

來源:互聯網
上載者:User

修改CentOS7系統預設運行層級

  1. CentOS系統有7個運行層級(runlevel)

    運行層級0:系統停機狀態,系統預設運行層級不能設為0,否則不能正常啟動
    運行層級1:單使用者工作狀態,root許可權,用於系統維護,禁止遠程登陸
    運行層級2:多使用者狀態(沒有NFS)
    運行層級3:完全的多使用者狀態(有NFS),登陸後進入控制台命令列模式
    運行層級4:系統未使用,保留
    運行層級5:X11控制台,登陸後進入圖形GUI模式
    運行層級6:系統正常關閉並重啟,預設運行層級不能設為6,否則不能正常啟動

  2. 修改運行層級
    Centos7中採用target概念來定義運行層級,分為3級、5級,含義如下:

    3級->multi-user.target     文本5級->graphical.target      圖形

    1)查看當前啟動並執行層級

    # runlevel  [root@chezhi chezhi]# runlevel N 3[root@chezhi chezhi]# 

    如果系統當前預設運行層級是圖形GUI模式則runlevel 顯示結果為: 5 3

    2)修改開機預設運行層級

    systemd使用連結來指向預設的運行層級,由/etc/systemd/system/default.target檔案中決定。
    切換到運行級3:
    a. 先刪除: mv /etc/systemd/system/default.target /etc/systemd/system/default.target_copy5 #將檔案重新命名即可
    b. 建立軟串連檔案: ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
    或者
    ln -sf /lib/systemd/system/runlevel3.target /etc/systemd/system/default.target
    再者也可以使用systemctl命令:
    systemctl set-default graphical.target
    systemctl isolate multi-user.target

最後順利關機並重啟系統: init 6

然後系統開機就會自動進入控制台命令模式,如果想切換回預設進入圖形GUI模式執行命令:

#先刪除檔案[root@chezhi system]# rm -rf /etc/systemd/system/default.target#重新建立軟串連檔案[root@chezhi system]# ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.