天天學一個 Linux 命令(92):chkconfig

推薦閱讀:天天學一個 Linux 命令(91):ncredis

命令簡介

chkconfig 命令用於管理Linux系統開機啓動項centos

語法格式

chkconfig [options]

選項說明

--add   #增長所指定的系統服務
--del  #刪除所指定的系統服務
--level<等級代號>  #指定讀系統服務要在哪個執行等級中開啓或關畢

缺省的運行級,RHS用到的級別以下:網絡

  • 0:關機
  • 1:單用戶模式
  • 2:無網絡支持的多用戶模式
  • 3:有網絡支持的多用戶模式
  • 4:保留,未使用
  • 5:有網絡支持有X-Window支持的多用戶模式
  • 6:從新引導系統,即重啓

運行級文件centos7

每一個被chkconfig管理的服務須要在對應的init.d下的腳本加上兩行或者更多行的註釋。第一行告訴chkconfig缺省啓動的運行級以及啓動和中止的優先級。若是某服務缺省不在任何運行級啓動,那麼使用-代替運行級。第二行對服務進行描述,能夠用跨行註釋。3d

# chkconfig: 2345 10 90
# description: Activates/Deactivates all network interfaces configured to 
#       start at boot time.

應用舉例

列出全部系統的服務code

[root@centos7 ~]# chkconfig --list
Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.
      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.
netconsole      0:off 1:off 2:off 3:off 4:off 5:off 6:off
network         0:off 1:off 2:on 3:on 4:on 5:on 6:off

其它實例ip

[root@centos7 ~]# chkconfig --add httpd        #增長httpd服務
[root@centos7 ~]# chkconfig --del httpd        #刪除httpd服務
[root@centos7 ~]# chkconfig --level httpd 2345 on    #設置httpd在運行級別爲二、三、四、5的狀況下都是on(開啓)的狀態
[root@centos7 ~]# chkconfig --list httpd       #列出httpd服務設置狀況
[root@centos7 ~]# chkconfig --level 35 httpd on #設定httpd在等級3和5爲開機運行服務
[root@centos7 ~]# chkconfig httpd on    #設定httpd在各等級爲on
 
[root@centos7 ~]# chkconfig –level redis 2345 on #把redis在運行級別爲二、三、四、5的狀況下都是on(開啓)的狀態

注意:增長一個服務時,這個服務啓動腳本必須存放在 /etc/init.d/目錄下。ci

天天學一個 Linux 命令(90):kill/killallget

天天學一個 Linux 命令(86):timeit

天天學一個 Linux 命令(85):watch

相關文章
相關標籤/搜索