CentOS 7 上systemctl 的用法

简介:

我们对service和chkconfig两个命令都不陌生,systemctl 是管制服务的主要工具, 它整合了chkconfig 与 service功能于一体。


systemctl is-enabled iptables.service

systemctl is-enabled servicename.service #查询服务是否开机启动

systemctl enable *.service #开机运行服务

systemctl disable *.service #取消开机运行

systemctl start *.service #启动服务

systemctl stop *.service #停止服务

systemctl restart *.service #重启服务

systemctl reload *.service #重新加载服务配置文件

systemctl status *.service #查询服务运行状态

systemctl --failed #显示启动失败的服务


注:*代表某个服务的名字,如http的服务名为httpd


例如在CentOS 7 上安装http


[root@CentOS7 ~]# yum -y install httpd

启动服务(等同于service httpd start)

systemctl start httpd.service

停止服务(等同于service httpd stop)

systemctl stop httpd.service

重启服务(等同于service httpd restart)

systemctl restart httpd.service

查看服务是否运行(等同于service httpd status)

systemctl status httpd.service

开机自启动服务(等同于chkconfig httpd on)

systemctl enable httpd.service

开机时禁用服务(等同于chkconfig httpd on)

systemctl disable httpd.service

查看服务是否开机启动 (等同于chkconfig --list)



本文转自 Mr_sheng 51CTO博客,原文链接:http://blog.51cto.com/sf1314/1980567

相关文章
|
关系型数据库 MySQL Linux
Linux部署实战前言,MySQL在CentOS安装【单机软件】,MySQL的安装需要root权限,yum install mysql,systemctl enable mysqld开机自启的意思
Linux部署实战前言,MySQL在CentOS安装【单机软件】,MySQL的安装需要root权限,yum install mysql,systemctl enable mysqld开机自启的意思
|
NoSQL Linux Redis
centos7 systemctl 启动 Redis 失败
转自:http://sloger.info/posts/systemd-failed-to-start-redis-in-gentoo 今天启动 Redis 时阻塞很长时间,之后显示启动失败,启动状态如下。
6163 0
|
Java Linux 网络安全
Centos7 systemctl 启动 Java 应用
本文主要记录在 Centos7 系统上部署启用 Java 的 jar 包应用服务,包含开放防火墙的指定端口,配置脚本自启动等。
1033 0
|
Java Linux 数据库连接
CentOS7中systemctl的使用
CentOS7中systemctl的使用
588 0
|
Linux 虚拟化
安装centos7 报错[FAILED] Failed to start Switch Root. see 'systemctl status initrd-switch-root.service' for details
安装centos7 报错[FAILED] Failed to start Switch Root. see 'systemctl status initrd-switch-root.service' for details
25292 0
|
Shell Linux 开发工具
CentOS编译和yum安装Beanstalkd及service和systemctl管理
本篇笔记记录了CentOS中编译和yum两种方式安装Beanstalkd的过程,以及在CentOS6中创建服务脚本,使用service管理;CentOS7中创建服务脚本,使用systemctl管理Beanstalkd的过程
3895 0
|
Web App开发 关系型数据库 应用服务中间件
CentOS7源码编译安装nginx+php7.2+mysql5.7并使用systemctl管理
这篇笔记记录了在CentOS7.6中通过源码编译的方式安装nginx1.14,php7.2和mysql5.7的过程,以及使用systemctl管理服务,mysql5.7并未使用官网的二进制包,而是从源码开始自己编译的,要提醒的是mysql5.
5750 0