systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

任务 旧指令 新指令
使某服务自动启动 chkconfig --level 3 httpd on systemctl enable httpd.service
使某服务不自动启动 chkconfig --level 3 httpd off systemctl disable httpd.service
检查服务状态 service httpd status

systemctl status httpd.service (服务详细信息)

systemctl is-active httpd.service (仅显示是否 Active)

显示所有已启动的服务 chkconfig --list systemctl list-units --type=service
启动某服务 service httpd start systemctl start httpd.service
停止某服务 service httpd stop systemctl stop httpd.service
重启某服务 service httpd restart systemctl restart httpd.service

实例

1.启动nfs服务

systemctl start nfs-server.service

2.设置开机自启动

systemctl enable nfs-server.service

3.停止开机自启动

systemctl disable nfs-server.service

4.查看服务当前状态

systemctl status nfs-server.service

5.重新启动某服务

systemctl restart nfs-server.service

6.查看所有服务是否开机启动

systemctl list-unit-files 

开启防火墙22端口

iptables -I INPUT -p tcp --dport 22 -j accept

如果仍然有问题,就可能是SELinux导致的

关闭SElinux:

修改/etc/selinux/config文件中的SELINUX=””为disabled,然后重启。

彻底关闭防火墙:

sudo systemctl status firewalld.service
sudo systemctl stop firewalld.service          
sudo systemctl disable firewalld.service ######################################### centos 6 与 centos 7开关服务区别#######################################

centos 6 :使用chkconfig命令即可。

我们以apache服务为例:

#chkconfig --add apache 添加nginx服务

#chkconfig apache on 开机自启nginx服务

#chkconfig apache off 关闭开机自启

#chkconfig --list | grep apache 查看

centos 7 :使用systemctl中的enable、disable 即可。
示例:

#systemctl enable apache.service 开机自启apache服务

#systemctl disable apache.service 关闭开机自启


转自------------------------------http://man.linuxde.net/systemctl

CentOS systemctl命令的更多相关文章

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

    systemctl是RHEL 7 的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体.可以使用它永久性或只在当前会话中启用/禁用服务,下面来看CentOS 7.X 中 ...

  2. Docker容器Centos不能使用systemctl命令问题

    注:本文出自博主 Chloneda:个人博客 | 博客园 | Github | Gitee | 知乎 本文源链接:https://www.cnblogs.com/chloneda/p/bug-dock ...

  3. Docker的centos镜像内无法使用systemctl命令的解决办法

    在Docker官方的centos镜像内无法使用systemctl命令的解决办法, 使用该命令docker报错 Failed to get D-Bus connection: Operation not ...

  4. (转)systemctl 命令完全指南

    场景:在使用chkconfig查看vsftpd是否看机启动时候看不到启动项,用systemctl 才看到自己想要的结果 1 总结 from:https://linux.cn/article-5926- ...

  5. Linux服务器,服务管理--systemctl命令详解,设置开机自启动

    Linux服务器,服务管理--systemctl命令详解,设置开机自启动 syetemclt就是service和chkconfig这两个命令的整合,在CentOS 7就开始被使用了. 摘要: syst ...

  6. CentOS Bash 命令补全增强软件包 bash-completion

    引言 之前安装的 CentOS 7 是最小化安装,在使用 systemctl 命令进行服务的管理时,经常手动输入相关服务名.如果对一个服务名称不熟悉,这样可以迫使我们记住它,但如果对一个服务名已经很熟 ...

  7. 【转载】systemctl命令完全指南

    Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器. Systemd是一个系统管理守护进程.工具和库的集合,用于取代System V初始进程.Systemd的功能是 ...

  8. Centos7下的systemctl命令与service和chkconfig

    博主使用的操作系统是最新的CentOS 7,所以可能和网上一些老的博文有一定出入,那是因为版本更新的原因. 这里写图片描述1 service service命令用于对系统服务进行管理,比如启动(sta ...

  9. Docker下构建centos7容器无法使用systemctl命令的解决办法

    最近在使用docker 构建centos7 容器时,发现无法使用systemctl 命令.后来万能的百度解决了问题,随记之以备后用. 解决办法: docker run --privileged -it ...

随机推荐

  1. 4.高级js--(面向对象js)_2

    1.创建对象的三种方式: l第一种构造法:new  Object var a = new Object(); a.x = 1, a.y = 2; l第二种构造法:对象直接量 var b = { x : ...

  2. Vim 常用命令和编辑方法

    命令模式 :e <path/to/file> → 打开一个文件 :w → 存盘 :wq → 存盘 + 退出 (:w 存盘, :q 退出)   (陈皓注::w 后可以跟文件名) :savea ...

  3. java配置slf4j日志系统

    首先要导入的包: import: 每个类中加入下面,其中 RdiFtpDownload.class 是当前的类名.class 然后就可以打日志了: 配置 log4j.properties log4j. ...

  4. html 基础之a标签的属性target解析

    学习前端,有很多标签其实有很多不同的功能,但是用到的不多,所以就没有发现:当发现的时候,觉得很不可思议,有耳目一新的感觉.例如a 标签,之前只是知道,使用a标签,可以打开一个链接,然后访问一个新的页面 ...

  5. js 正则函数初级之二

    1. 小括号在正则中: 1.1 小括号:表示分组 1.2 分组之后,,每个组都有一个序号,从左到右,依次为1,2,3.......:可以使用 RegExp.$1,RegExp.$2,RegExp.$3 ...

  6. RabbitMQ系列教程之三:发布/订阅(Publish/Subscribe)(转载)

    RabbitMQ系列教程之三:发布/订阅(Publish/Subscribe) (本教程是使用Net客户端,也就是针对微软技术平台的) 在前一个教程中,我们创建了一个工作队列.工作队列背后的假设是每个 ...

  7. node-sass:npm install node-sass --save

    从git上拉下来的项目,要先安装依赖, 再运行. 缺少node-sass:npm install node-sass --save

  8. 如何用java读取properties文件

    1.Properties类与Properties配置文件 Properties类继承自Hashtable类并且实现了Map接口,也是使用一种键值对的形式来保存属性集.不过Properties有特殊的地 ...

  9. webkit内核自定义隐藏滚动条

    1,在主页面可以拿到iframe,也可以为iframe注册onload等事件.document.getElementById('iframeId').onload 2,在主页面操作其中的iframe的 ...

  10. ANg-基础概念

    分类 机器学习可以分为两类:监督学习(Supervised Learning)和无监督学习(Unsupervised Learning) 监督学习 Supervised Learning 监督学习是从 ...