在Centos 中 systemctl  是设置系统服务的命令,即 service  ,   它融合之前service和chkconfig的功能于一体。

可以使用它永久性或只在当前会话中启用/禁用服务。

CentOS 7 的 /etc/rc.d/rc.local 是没有执行权限的, 系统建议创建 systemd service 启动服务。

 

查看服务列表状态:

systemctl list-units --type=service

systemctl   list-unit-files       列出所有已经安装的  服务  及  状态      (可为人所读,  内容简略、清晰):

systemctl 可以列出正在运行的服务状态,如图:(基本不为人所读, 内容复杂、全面)

systemd-cgls   以树形列出正在运行的进程,它可以递归显示控制组内容。如图:

2、如何启动/关闭、启用/禁用服务?

启动一个服务:

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

查看已启动的服务列表:   systemctl list-unit-files | grep enabled


查看启动失败的服务列表:   systemctl --failed

PS:使用命令 systemctl is-enabled postfix.service 得到的值可以是enable、disable或static,这里的 static 它是指对应的 Unit 文件中没有定义[Install]区域,因此无法配置为开机启动服务。

说明:启用服务就是在当前“runlevel”的配置文件目录   /etc/systemd/system/multi-user.target.wants  里,建立  /usr/lib/systemd/system   里面对应服务配置文件的软链接;

禁用服务就是删除此软链接,添加服务就是添加软连接。

如图:

打开某个  service  文件, 查看一下其中内容:

Centos7 服务 service 设置命令 systemctl 用法 (替代service 和 chkconfig)的更多相关文章

  1. nginx启动报错:Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' fo

    一.背景 这个错误在重启nginx或者启动nginx的时候,经常会出现.我之前也一直认为出现这个错误是因为有程序占用了nginx的进程.但是知其然不知其所以然.每次报错都有点懵逼,所以这边一步步排查错 ...

  2. linux开机自启动服务优化设置命令

    1.设置成英文字符,避免出现乱码[root@xuegod62 ~]# LANG=en2.两种配置linux开机自启动服务命令:1)[root@xuegod62 ~]# ntsysv2)[root@xu ...

  3. Centos7 环境下开机 自启动服务(service) 设置的改变 (命令systemctl 和 chkconfig用法区别比较)

    参考文章:  <Linux 设置程序开机自启动 (命令systemctl 和 chkconfig用法区别比较)> http://blog.csdn.net/kenhins/article/ ...

  4. Linux 设置程序开机自启动 (命令systemctl 和 chkconfig用法区别比较)

    之前在Linux centos 7 上安装了apache 和mysql,当时并没有设置开机自动启动. 最近又重新练习网页,每次开机总是要手动启动httpd和mysqld,不方便,就想设置成开机自动启动 ...

  5. RHEL 7 中 systemctl 的用法(替代service 和 chkconfig)

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

  6. Linux CentOS7.0 (04)systemctl vs chkconfig、service

    CentOS 7.0中已经没有service命令,而是启用了systemctl服务器命令 systemctl 是系统服务管理器命令,它实际上将 service 和 chkconfig 这两个命令组合到 ...

  7. 对比centos7的systemctl和其他service+chkconfig

    syetemctl就是service和chkconfig这两个命令的整合,在CentOS 7就开始被使用了.systemctl 是系统服务管理器命令,它实际上将 service 和 chkconfig ...

  8. systemctl 命令的用法

    对比表,以 apache / httpd 为例 任务 旧指令 新指令 使某服务自动启动 chkconfig --level 3 httpd on systemctl enable httpd.serv ...

  9. centos7当中的systemd及systemctl(节选)

    全面进入centos7时代,这个东东是需要系统了解的. http://blog.jobbole.com/85070/?utm_source=blog.jobbole.com&utm_mediu ...

随机推荐

  1. PAT 1090 Highest Price in Supply Chain[较简单]

    1090 Highest Price in Supply Chain(25 分) A supply chain is a network of retailers(零售商), distributors ...

  2. java打印随机函数

    一 ,打印1-10的随机函数 public static void randomprint(){      for (int i=0;i<100;i++){          //打印一百次  ...

  3. 解决升级到Xcode10,react native项目运行报错问题

    今天刚升级到Xcode10,就遇到两个报错问题 错误一:Xcode 10: Build input file double-conversion cannot be found error: Buil ...

  4. The adidas NMD Singapore is one of the brands top selling

    Like pointed out, we've two adidas NMD Singapore releases using the first arriving Blue and Black as ...

  5. The same month as the adidas NMD Singapore is releasing

    Earlier this December 2017, the inaugural adidas NMD Singapore silhouette released in the first colo ...

  6. F题:等差区间(RMQ||线段树)

    原题大意:原题链接  题解链接 给定一个长为n的数组元素和q次区间[l,r]询问,判断区间[l,r]内元素排序后能否构成等差数列 #include<cmath> #include<c ...

  7. Flux 单向数据流

    Flux 的核心就是一个简单的约定:视图层组件不允许直接修改应用状态,只能触发 action.应用的状态必须独立出来放到 store 里面统一管理,通过侦听 action 来执行具体的状态操作. 所谓 ...

  8. 参考sectools,每个人至少查找5种安全工具、库等信息并深入研究至少两种并写出使用教程

    1.Nessus Nessus是免费网络漏洞扫描器,它可以运行于几乎所有的UNIX平台之上.它不仅能永久升级,还免费提供多达11000种插件(但需要注册并接受EULA-acceptance--终端用户 ...

  9. 2018-2019-1 20189215《Linux内核原理与分析》第二周作业

    本周学习了<庖丁解牛>第1章,以及<Linux内核设计与实现>第1.2.18章.通过视频和实验,学会了反汇编一个简单的C程序,也学习了Linux内核调试的一些小技巧和print ...

  10. LightOJ 1027 A Dangerous Maze(期望)

    https://cn.vjudge.net/problem/LightOJ-1027 题意:有n扇门,每扇门有个时间ti,选择正数的门可以在ti后带你走出迷宫,负数的门会在ti后带你回到起点,然后重新 ...