跳转至

CentOS 7 新命令 systemctl


2015-03-17 by dongnan

环境

操作系统: CentOS 7.0 amd64

功能

systemctl 将是最主要的工具,它融合 servicechkconfig的功能于一体,可以使用它永久性或只在当前会话中启用/禁用服务。

举个栗子

启动网络服务

systemctl start network.service

关闭网络服务

systemctl stop network.service

重启网络服务

systemctl restart network.service

服务的状态

systemctl status network.service

开机时启用一个服务

systemctl enable network.service

在开机时禁用一个服务

systemctl disable network.service

查看服务开机是否启动

systemctl is-enabled network.service;echo $?

列出失败的服务名称

systemctl --failed
UNIT            LOAD   ACTIVE SUB    DESCRIPTION
network.service loaded failed failed LSB: Bring up/down networking

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

1 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

systemctl 更多详细信息请参考手册页(man systemctl)

systemctl 服务状态

查看docker服务开机是否启动

systemctl list-unit-files | grep docker

docker-storage-setup.service                disabled
docker.service                              disabled

设置docker服务开机启动

systemctl enable docker.service

再次查看

systemctl list-unit-files | grep docker

docker-storage-setup.service                disabled
docker.service                              enabled

注意,enabled 状态。

欢迎关注微信公众号: 运维录

Back to top