百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>数据库> CentOS 7.X 中systemctl命令用法详解
分享文章到:

CentOS 7.X 中systemctl命令用法详解

发布时间:01/15 来源: 浏览: 关键词:
systemctl是RHEL 7 的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。可以使用它永久性或只在当前会话中启用/禁用服务,下面来看CentOS 7.X 中systemctl命令用法详解.

从linux系统版本centos 6.x到centos 7.x变化整体不大,不过还是有很多地方需要我们注意的,最为直观的当属服务管理命令,之前centos 7.x之前的系统我们使用service和chkconfig来管理服务器,而到了centos 7.x 这个版本的linux中,systemctl 一个命令就搞定了,它集成了service和chkconfig 的功能于一身。这里今天简单说明一下:

systemctl start *.service #启动某服务
systemctl stop *.service #停止某服务
systemctl restart *.service #重启某服务
systemctl reload *.service #重载某服务配置文件
systemctl status *.service #查询某服务运行状态
systemctl is-enabled *.service #查看某服务是否开机启动
systemctl enable *.service #设置开机启动
systemctl disable *.service #取消开机启动
systemctl –failed #查看启动失败的服务

注:*指服务的名字,比如重启、iptables,我们就会这样操作:

[root@21yunwei network-scripts]# systemctl stop  iptables.service
[root@21yunwei network-scripts]# systemctl start iptables.service
[root@21yunwei network-scripts]# systemctl restart  iptables.service
[root@21yunwei network-scripts]# systemctl status  iptables.service
● iptables.service - IPv4 firewall with iptables
  Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
  Active: active (exited) since Fri 2016-06-17 17:52:05 CST; 16s ago
  Process: 48807 ExecStop=/usr/libexec/iptables/iptables.init stop (code=exited, status=0/SUCCESS)
  Process: 48870 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
  Main PID: 48870 (code=exited, status=0/SUCCESS)
 
Jun 17 17:52:05 21yunwei systemd[1]: Starting IPv4 firewall with iptables...
Jun 17 17:52:05 21yunwei iptables.init[48870]: iptables: Applying firewall rules: [  OK  ]
Jun 17 17:52:05 21yunwei systemd[1]: Started IPv4 firewall with iptables.
[root@21yunwei network-scripts]# systemctl is-enabled iptables.service
enabled
补充一点小技巧:systemctl 默认没有服务器名不全,原因是最小化安装没有进行安装包bash-completion,需要执行下边命令后重新登录系统就可以看到命令补全了。

yum install -y bash-completion

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有1人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板