关于linux:每天学一个-Linux-命令92chkconfig

2次阅读

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

举荐浏览: 每天学一个 Linux 命令(91):nc

命令简介

chkconfig 命令用于治理 Linux 零碎开机启动项

语法格局

chkconfig [options] 

选项阐明

--add   #减少所指定的零碎服务
--del  #删除所指定的零碎服务
--level< 等级代号 >  #指定读零碎服务要在哪一个执行等级中开启或关毕

缺省的运行级,RHS 用到的级别如下:

  • 0:关机
  • 1:单用户模式
  • 2:无网络反对的多用户模式
  • 3:有网络反对的多用户模式
  • 4:保留,未应用
  • 5:有网络反对有 X -Window 反对的多用户模式
  • 6:从新疏导零碎,即重启

运行级文件

每个被 chkconfig 治理的服务须要在对应的 init.d 下的脚本加上两行或者更多行的正文。第一行通知 chkconfig 缺省启动的运行级以及启动和进行的优先级。如果某服务缺省不在任何运行级启动,那么应用 - 代替运行级。第二行对服务进行形容,能够用跨行正文。

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

利用举例

列出所有零碎的服务

[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

其它实例

[root@centos7 ~]# chkconfig --add httpd        #减少 httpd 服务
[root@centos7 ~]# chkconfig --del httpd        #删除 httpd 服务
[root@centos7 ~]# chkconfig --level httpd 2345 on    #设置 httpd 在运行级别为 2、3、4、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 在运行级别为 2、3、4、5 的状况下都是 on(开启)的状态

留神:减少一个服务时,这个服务启动脚本必须寄存在 /etc/init.d/ 目录下。

每天学一个 Linux 命令(90):kill/killall

每天学一个 Linux 命令(86):time

每天学一个 Linux 命令(85):watch

正文完
 0