10.24 chkconfig工具
时间:2022-04-27
本文章向大家介绍10.24 chkconfig工具,主要内容包括Linux系统服务管理-chkconfig、chkconfig命令、chkconfig命令,指定某一级别开启/关闭、将一个脚本加入到服务列表中、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。
Linux系统服务管理-chkconfig
- chkconfig --list
- chkconfig --level 3 network off
- chkconfig --level 345 network off
- chkconfig --del network
- chkconfig --add network
chkconfig工具
- crond、iptables、firewalld、nginx、httpd、mysql等等,都属于服务。
- chkconfig工具,在centos6和之前的版本中,控制服务的启动;但在centos7中很少使用了,但为了兼容之前的版本,依然可以使用,但在未来的趋势中, 有可能就会被遗弃了,现在就是过度的作用。
- chkconfig --list //列出所有的系统服务
- 表示chkconfig工具在centos6或之前的版本中,使用的服务的管理的机制叫 SysV,而centos7的版本中,使用的是 systemd 服务
[root@hf-01 ~]# chkconfig --list //列出所有的系统服务
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@hf-01 ~]#
chkconfig命令
- 服务的脚本存放在 /etc/init.d/ 下面
- 启动脚本存放该目录下
[root@hf-01 ~]# ls /etc/init.d/
functions netconsole network README
[root@hf-01 ~]#
- chkconfig --list //列出所有的服务
- chkconfig network off //将network服务关闭
[root@hf-01 ~]# chkconfig network off
[root@hf-01 ~]# chkconfig --list //会看到2,3,4级别关闭了
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:关 3:关 4:关 5:关 6:关
[root@hf-01 ~]# chkconfig network on
[root@hf-01 ~]# chkconfig --list //会看到2,3,4级别又开启了
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@hf-01 ~]#
- 在系统中有七个级别等级列表:
- 等级0表示:表示关机
- 等级1表示:单用户模式
- 等级2表示:多用户模式,少nfs服务
- 等级3表示:多用户模式,不带图形
- 等级4表示:是一种保留的级别
- 等级5表示:带图形界面的多用户模式
- 等级6表示:重新启动
- 在centos6中的 /etc/inittab 中定义开机的级别
- 在centos7中,已经没有用了,不需要定义开机的级别了
chkconfig命令,指定某一级别开启/关闭
- chkconfig --level 3 network off //指定network中的3级别关闭
[root@hf-01 ~]# chkconfig --level 3 network off //指定network中的3级别关闭
[root@hf-01 ~]# chkconfig --list //列出所有服务
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:关 4:开 5:开 6:关
[root@hf-01 ~]#
- chkconfig --level 345 network on //指定network中的3,4,5级别开启
[root@hf-01 ~]# chkconfig --level 345 network on //指定network中的3,4,5级别开启
[root@hf-01 ~]# chkconfig --list
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@hf-01 ~]#
- 0和1和6级别不能设置成开
- 0级别在关机状态是不可能开启的
- 1级别是单用户模式,服务是不可能开启的
- 6级别在重启的时候,是不可能开启的——>重启相当于先关闭在启动(重启的那一刻是先关闭才对)。
将一个脚本加入到服务列表中
- 首先将启动脚本放入到 /etc/init.d 这个目录下——>只有在这个目录下,才可以添加到服务列表中去
- 文件名称无所谓,但内容有格式要求
- 首先是是一个shell脚本
- 然后chkconfig指定运行级别启动顺序,第10位启动,第90位关闭
- 下面代码为它的固定格式,必须要有的!!!
# chkconfig: 2345 10 90
# description: Activates/Deactivates all network interfaces configured to
# start at boot time.
- 例子:
[root@hf-01 ~]# cd /etc/init.d
[root@hf-01 init.d]# ls
functions netconsole network README
[root@hf-01 init.d]# cp network 123
[root@hf-01 init.d]# ls -l
总用量 40
-rwxr-xr-x 1 root root 7293 12月 5 05:27 123
-rw-r--r--. 1 root root 17500 5月 3 2017 functions
-rwxr-xr-x. 1 root root 4334 5月 3 2017 netconsole
-rwxr-xr-x. 1 root root 7293 5月 3 2017 network
-rw-r--r--. 1 root root 1160 10月 20 11:07 README
[root@hf-01 init.d]# chkconfig --list
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@hf-01 init.d]# chkconfig --add 123 //将123加入到服务列表中
[root@hf-01 init.d]# chkconfig --list
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
123 0:关 1:关 2:开 3:开 4:开 5:开 6:关
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@hf-01 init.d]# chkconfig --del 123 //删除服务列表中的脚本
[root@hf-01 init.d]# chkconfig --list
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@hf-01 init.d]#
- chkconfig --del network //删除服务列表中的脚本
- chkconfig --add network //增加服务列表中的脚本
- 破解验证,让爬取更随心所欲!
- Visual Studio Code v0.9.1 发布
- (39) 剖析LinkedList / 计算机程序的思维逻辑
- 我的Android进阶之旅------>Android采用AES+RSA的加密机制对http请求进行加密
- 看到那个Edward 了吗?对!其实它是个Python库
- (35) 泛型 (上) - 基本概念和原理 / 计算机程序的思维逻辑
- 将linux下的rm命令改造成mv到指定的目录下
- (36) 泛型 (中) - 解析通配符 / 计算机程序的思维逻辑
- Python优化第一步: 性能分析实践
- Python云计算框架:OpenStack源码分析之RabbitMQ(二)
- 编程获得CPU的主频
- Python多进程并行编程实践:以multiprocessing模块为例
- 由函数clock想到的
- (34) 随机 / 计算机程序的思维逻辑
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 第二天:创建型模式--抽象工厂模式
- 第三天:创建型模式--建造者模式
- JavaScript 进阶教程(2)---面向对象实战之贪吃蛇小游戏
- python api链接数据库
- MySQL 的可重复读
- 第四天:创建型模式--原型模式
- Ubuntu16升级Python3
- JavaScript 进阶教程(3)---让你彻底搞懂原型链和继承
- 第五天:结构型模式--适配器模式
- 第六天:结构型模式--修饰器模式
- 第一章--第二节:我的第一个Python项目
- 第二章--第一节:变量、字符串与数字
- 第二章--第二节:注释
- 骚操作 | 用 Python 实现 GIF 倒放
- TensorFlow学习笔记--CIFAR-10 图像识别