CentOS 7 上systemctl 的用法

简介:


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)






      本文转自独弹古调  51CTO博客,原文链接:http://blog.51cto.com/hunkz/1565970,如需转载请自行联系原作者



相关文章
|
5月前
|
Ubuntu 安全 Linux
su,su -,su - root,sudo,sudo -i,sudo su - 有何不同,在ubuntu和centos上用法有什么异同?
sudo -i命令:在Ubuntu和CentOS中,sudo -i命令可以启动一个新的shell会话,并将环境变量设置为root用户的环境变量。在使用该命令时同样需要输入当前用户的密码进行身份验证。
58 0
|
NoSQL Linux Redis
centos7 systemctl 启动 Redis 失败
转自:http://sloger.info/posts/systemd-failed-to-start-redis-in-gentoo 今天启动 Redis 时阻塞很长时间,之后显示启动失败,启动状态如下。
5589 0
|
Shell Linux 开发工具
CentOS编译和yum安装Beanstalkd及service和systemctl管理
本篇笔记记录了CentOS中编译和yum两种方式安装Beanstalkd的过程,以及在CentOS6中创建服务脚本,使用service管理;CentOS7中创建服务脚本,使用systemctl管理Beanstalkd的过程
3441 0