每天学一个 Linux 命令(92):chkconfig
发布日期:2021-07-01 03:54:46
浏览次数:2
分类:技术文章
本文共 1609 字,大约阅读时间需要 5 分钟。
点击下方“民工哥技术之路”,选择“设为星标”
回复“1024”获取独家整理的学习资料!
推荐阅读:
命令简介
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 --listNote: 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:offnetwork 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/目录下。
推荐阅读 点击标题可跳转
转载地址:https://mingongge.blog.csdn.net/article/details/115343589 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月27日 00时29分43秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
spark 笔记1
2019-05-01
shell dirname basename
2019-05-01
未来已至,5G加持下的云游戏将走向何方?
2019-05-01
计算机网络 —— 网络层 1.
2019-05-01
Android 之 ContentProvider 与 ContentResolver
2019-05-01
【接口自动化】
2019-05-01
推荐一位川大零基础转行 Python 的人生勇士
2019-05-01
Python解惑之:True与False
2019-05-01
你要的微信小程序终于来了
2019-05-01
有了这些 Chrome 插件,效率提升10倍(建议收藏)
2019-05-01
只有1%的程序员搞懂过浮点数陷阱
2019-05-01
一名 Google 工程师的大数据处理经验
2019-05-01
命名难,难于上青天
2019-05-01
没钱没公司,怎么做一款付费产品
2019-05-01
代码整洁之道-编写 Pythonic 代码
2019-05-01
树莓派程序开机自启动
2019-05-01
连锁门店无线通信方案
2019-05-01
配置Lotus Domino集群视频详解
2019-05-01
Linux软件万花筒
2019-05-01