linux chkconfig 和 systemctl 区别 & 对比

chkconfig命令

Copy主要用来更新(启动或停止)和查询系统服务(service)的运行级信息,用于维护/etc/rc[0-6].d目录的命令行工具。


chkconfig -–add httpd
	增加httpd服务

chkconfig –-del httpd
	删除httpd服务


chkconfig –-list
	列出系统所有的服务启动情况

chkconfig –-list mysqld
	列出mysqld服务设置情况


chkconfig –-level 35 mysqld on
	设定mysqld在等级3和5为开机运行服务(on表示开机启动,off表示开机不启动,reset指重置服务的启动信息)

chkconfig mysqld on
	设定mysqld在各等级为on,“各等级”包括2、3、4、5等级


等级0表示:表示关机
等级1表示:单用户模式
等级2表示:无网络连接的多用户命令行模式
等级3表示:有网络连接的多用户命令行模式
等级4表示:不可用
等级5表示:带图形界面的多用户模式
等级6表示:重新启动

systemctl(代替chkconfig和service)

Copy在 Centos 中 systemctl 是设置系统服务(service)的命令,它融合之前service和chkconfig的功能于一体。
可以使用它永久性或只在当前会话中启用/禁用服务。


启动、停止、重启、重载服务

	systemctl start name.service

	systemctl stop name.service

	systemctl restart name.service

	systemctl reload name.service


查看某个服务(单元)的状态
	systemctl status name.service


激活/禁止自动启动
	systemctl enable httpd.service
	systemctl disable httpd.service


杀死服务
	systemctl kill httpd

chkconfig 和 systemctl 区别对比

任务旧指令新指令
使某服务自动启动chkconfig --level 3 httpd onsystemctl enable httpd.service
使某服务不自动启动chkconfig --level 3 httpd offsystemctl disable httpd.service
检查服务状态service httpd statussystemctl status httpd.service(服务详细信息) / systemctl is-active httpd.service (仅显示是否 Active)
加入自定义服务chkconfig --add testsystemctl load test.service
删除服务chkconfig --del xxx停掉应用,删除相应的配置文件
显示所有已启动的服务chkconfig --listsystemctl list-units --type=service
启动某服务service httpd startsystemctl start httpd.service
停止某服务service httpd stopsystemctl stop httpd.service
重启某服务service httpd restartsystemctl restart httpd.service
  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

学亮编程手记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值