systemctl  -- 系统服务管理器

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

直接运行命令可以列出所有正在运行的服务,输出列表具有更详细的信息,比如:

[root@beyes   command]# systemctl
... ...
sendmail.service          loaded active exited        LSB: start and stop sendmail
sshd.service              loaded active running       LSB: Start up the OpenSSH server daemon
udev.service              loaded active running       udev Kernel Device Manager
... ...

这里,还有一个 systemd-cgls 命令可以以树状的形式列出正在运行的进程信息。

如果要启动 httpd 服务,那么运行下面命令:

[root@beyes   command]# systemctl start httpd.service

注意,上面的 httpd 后面的 .service 是不能少的。

同理,停止服务和重启服务可以分别如下运行命令:

# systemctl stop httpd.service       #停止服务
# systemctl restart httpd.service              #重启服务

如果我们要查看服务的运行状态,那么如下运行:

[root@beyes   command]# systemctl status httpd.service
httpd.service - LSB: start and stop Apache HTTP Server
      Loaded: loaded (/etc/rc.d/init.d/httpd)
      Active: active (running) since Wed, 22 Feb 2012 10:37:30 +0800; 2s ago
     Process: 2573 ExecStop=/etc/rc.d/init.d/httpd stop (code=exited, status=0/SUCCESS)
     Process: 2589 ExecStart=/etc/rc.d/init.d/httpd start (code=exited, status=0/SUCCESS)
    Main PID: 2594 (httpd)
      CGroup: name=systemd:/system/httpd.service
          ├ 2594 /usr/sbin/httpd
          ├ 2596 /usr/sbin/httpd
          ├ 2597 /usr/sbin/httpd
          ├ 2598 /usr/sbin/httpd
          ├ 2599 /usr/sbin/httpd
          ├ 2600 /usr/sbin/httpd
          ├ 2601 /usr/sbin/httpd
          ├ 2602 /usr/sbin/httpd
          └ 2603 /usr/sbin/httpd

如果我们打算让服务可以随机启动,那么如下运行:

[root@beyes   command]# systemctl enable httpd.service
httpd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig httpd on

用 chkconfig 命令检测一下服务是否运行成功

[root@beyes   command]# chkconfig --list |grep httpd

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

httpd              0:off    1:off    2:on    3:on    4:on    5:on    6:off

可见服务已经在 第2 到 第5 运行等级打开。

同理禁止服务随机启动可以如下运行:

[root@beyes   command]# systemctl disable httpd.service
httpd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig httpd off

用 chkconfig 检测一下:

[root@beyes   command]# chkconfig --list |grep httpd

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

httpd              0:off    1:off    2:off    3:off    4:off    5:off    6:off

已经关闭成功。

此外,我们还可以直接检测服务是否随机启动或否,如下运行命令:

[root@beyes   command]# systemctl is-enabled httpd.service; echo $?
httpd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig httpd --level=5
0

上面,0 表示该服务已经使能随机启动;如果返回 1 那么表示该服务不随机启动

ref:http://www.groad.net/bbs/simple/?t6224.html

systemctl -- 系统服务管理器 【转】的更多相关文章

  1. Atitit.木马病毒的操作注册表原理 系统服务管理器 atiSysService

    Atitit.木马病毒的操作注册表原理 系统服务管理器 atiSysService 1. atiSysService1 2. atiSysService  原理1 3. Java code1 4. 参 ...

  2. Atitit.跨语言系统服务管理器api兼容设计

    Atitit.跨语言系统服务管理器api兼容设计 1. Common api,兼容sc ,service control??1 1.1. 服务创建,use sc1 1.2. 服务delete ,use ...

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

    1.centos 检查服务是否开机自启  (ntpd是原生的服务,mysql是注册的服务) 参考:1.http://man.linuxde.net/systemctl

  4. Linux - 利用systemctl命令管理服务

    systemctl命令是系统服务管理器指令,融合了service和chkconfig的功能,可以查看和设置服务. 这里以docker服务为例. 利用systemctl命令管理 显示服务状态:syste ...

  5. Android提供的系统服务之--TelephonyManager(电话管理器)

    Android提供的系统服务之--TelephonyManager(电话管理器) 转载请注明出处--coder-pig TelephonyManager的作用: 用于管理手机通话状态,获取电话信息(设 ...

  6. CentOS7系统服务管理systemctl

    目录 一.systemctl介绍 二.systemctl常用命令 1.启动服务 2.停止服务 3.重启服务 4.查看服务是否已启动 5.查看服务的状态 6.启用开机自启动服务 7.停用开机自启动服务 ...

  7. centos7系统服务管理

    systemd是RH7系列操作系统开始启用新的系统和服务管理器.它被设计为与sysv init脚本向后兼容,并提供了一些功能,例如在引导时并行启动系统服务,按需激活守护程序或基于依赖关系的服务控制逻辑 ...

  8. “连接配置中心失败,将无法进行正常管理”--腾讯通RTX管理器

    [故障现象]: 腾讯通RTX管理器提示“连接配置中心失败,将无法进行正常管理” [解决办法]: 在系统服务中启动“RTX_ConfigCenter”服务即可. 文章收集自网络

  9. Windows Server 2012 R2 服务器管理器介绍和配置使用

    1. 服务管理器是用于管理系统服务的管理工具.一般常用于windows系统,使用这个工具你可以启动.停止服务:设置服务是自动.手动启动或禁用:查看某个服务的相关信息:设置服务以什么用户启动等等(一般包 ...

随机推荐

  1. HDU 4135 Co-prime (容斥+分解质因子)

    <题目链接> 题目大意: 给定区间[A,B](1 <= A <= B <= 10 15)和N(1 <=N <= 10 9),求出该区间中与N互质的数的个数. ...

  2. Java常用的九种排序方法及代码实现

    package com.algorithm.Demo; import java.util.ArrayList; import java.util.Arrays; import java.util.Li ...

  3. RFC2616-HTTP1.1-Status Code(状态码规定部分—译文)

    part of Hypertext Transfer Protocol -- HTTP/1.1 RFC 2616 Fielding, et al. 10 状态码规定(Status Code Defin ...

  4. Android视图动画集合AndoridViewAnimations

    Android视图动画集合AndoridViewAnimations Android视图动画是针对视图对象的动画效果,包括对象平移.旋转.缩放和渐变四种类型.通过组合这四种类型,可以创建出无数种动画效 ...

  5. 在Android中调用USB摄像头

    在网上找了很长时间,网上的资料基本都是说用外国人写的库,但实际上这个库的案例都是不能直接用的(因为权限问题),并不适合学习. 之后偶然发现有国人把这个库重新封装了,并且有源代码以及中文教程: http ...

  6. 2018 EC-Final 部分题解 (A,J)

    目录 The 2018 ICPC Asia-East Continent Final A.Exotic - Ancient City(思路 并查集) J.Philosophical - Balance ...

  7. Codeforces.954I.Yet Another String Matching Problem(FFT)

    题目链接 \(Description\) 对于两个串\(a,b\),每次你可以选择一种字符,将它在两个串中全部变为另一种字符. 定义\(dis(a,b)\)为使得\(a,b\)相等所需的最小修改次数. ...

  8. 克罗内克符号kronecker_delta

    Kronecker delta 克罗内克函数 Wiki 维基百科 Kronecker delta 定义 \[\delta _{{ij}}={\begin{cases}0&{\text{if } ...

  9. Book Sharing

    到现在还不知道为什么我设置的背景图片为什么没有效果,明明是按照网上的教程来的,但...........好气哦,,,,,,,,,嗯哼嗯哼嗯哼 说实话:自己写的网页真丑   .....真丑 index.h ...

  10. (Android系统目录结构)目录预览

    Android系统进入设备后,查看根目录下文件系统,如下: 重要目录和文件说明:mnt 挂载点目录etc 系统主要配置文件system Android 系统文件sys Linux 内核文件proc 运 ...