Fork me on GitHub

centos使用--软件启动关闭等操作的命令

关于centos服务的命令经常会遇到这几种
service
systemctl
/etc/init.d/

1 service和/etc/init.d/

service是一个脚本命令,分析service可知是去/etc/init.d目录下执行相关程序。service和chkconfig结合使用。
服务配置文件存放目录/etc/init.d/

命令使用:

service start nginx  
/etc/init.d/nginx  restart  

2 systemctl

centos7 上面启动服务以及关闭服务已经不是以前的service stop/start xxxx了而是systemctl命令,不过用service他会有一个提醒你用systemctl,所以大可不必担心。

列出正在运行的服务状态——systemctl

启动一个服务——systemctl start postfix.service

关闭一个服务——systemctl stop postfix.service

重启一个服务:——systemctl restart postfix.service

显示一个服务的状态——systemctl status postfix.service

在开机时启用一个服务——systemctl enable postfix.service

在开机时禁用一个服务——systemctl disable postfix.service

查看服务是否开机启动——systemctl is-enabled postfix.service;echo $?

查看已启动的服务列表——systemctl list-unit-files|grep enabled
posted @ 2017-11-07 08:59  archer-wong  阅读(3503)  评论(0编辑  收藏  举报