systemctl和service、chkconfig常用命令对比

前言

  • systemctl 是RHEL 7的系统服务管理器指令,它融合之前 service 和 chkconfig 的功能于一体,是 service 命令和 chkconfig 命令的集合和代替。可以使用它永久性或只在当前会话中启用/禁用服务
  • CentOS是基于 RHEL (RedHat Enterprise Linux) 的Linux发行版本之一,CentOS 7也是使用systemctl,取代了service 和 chkconfig,在CentOS 7中使用后两个命令时会被重定向到使用等价的 systemctl 命令
  • 以 sshd.service 服务为例

systemctl 常用命令

列出所有服务:systemctl list-unit-files --type=service
列出服务层级和依赖关系:systemctl list-dependencies sshd.service

显示服务状态:systemctl status sshd.service
启动服务:systemctl start sshd.service
关闭服务:systemctl stop sshd.service
重启服务:systemctl restart sshd.service

设置服务开机自启动:systemctl enable sshd.service
禁止服务开机自启动:systemctl disable sshd.service

查看服务是否自启动:systemctl is-enabled sshd.service
列出系统所有服务的启动情况:systemctl list-units --type=service
列出所有自启动服务:systemctl list-unit-files|grep enabled

service、chkconfig 常用命令

显示服务状态:service sshd status
启动服务:service sshd start
关闭服务:service sshd stop
重启服务:service sshd restart

设置服务自启动:chkconfig --level 3 sshd on
禁止服务自启动:chkconfig --level 3 sshd off

查看服务是否自启动:chkconfig --list sshd
列出系统所有服务的启动情况:chkconfig --list

参考资料:

Linux - 利用systemctl命令管理服务
Linux下systemctl命令和service、chkconfig命令的区别


End~

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-21 13:38
8月实习会变多吗现在还没找到实习该怎么办...回复的hr好少
码农索隆:3-4月就要开始找,基本上6月份就发offer,7月初已经开始暑期实习了。
点赞 评论 收藏
分享
小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务