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. poj 3067 Japan 【树状数组】

    <题目链接> 题目大意: 有两个点集,这两个点集从上至下分别从1~n,1~m编号,现在给出n组数据,(x,y),表示左边点集编号为x的点与右边点集编号为y的点相连,现在要求计算这些线段的交 ...

  2. webpack 4.x之搭建前端开发环境

    webpack是一个现代JavaScript应用程序的静态模块打包器,借用官网的一张图,它能够将一些预处理语言,js的最新语法转换成浏览器识别的内容.现在一般的前端框架都有比较成熟的脚手架,大多数对w ...

  3. Django 学习第八天——Django模型基础第三节

    一.表关系的实现: 一对一:OneToOne(外键+唯一键) xxx = models.OneToOneField('关联的表',on_delete=models.CASCADE) 外键和一对一关系的 ...

  4. react组件通信那些事儿

    父组件是调用组件的组件.现在看来,感觉父组件就是一个壳子,定义好壳子里面会有什么,而子组件是一个具体的实现,说明,会用到什么东西,如果有这些东西,会进行什么操作.总之,父组件是材料,有水和泥,子组件告 ...

  5. jmeter使用Beanshell预处理器从指定列表中获取随机值

    变量mynation从列表{"china", "US", "UK"}中随机取值 String[] nation = new String[] ...

  6. 用户体验—微软Edge浏览器

    我现在使用的浏览器是win10自带的Edge浏览器 用户界面: 首先整体界面的话是清晰,一目了然,而且记住用户选择: 1.微软必应搜索的主题分类明确,查询简洁方便.查询语句简单: 2 .信息覆盖程度非 ...

  7. Java笔记(二)类

    类 一.类的基础 1.类---一种自定义数据类型. 2.与方法内创建局部变量不同,在创建对象的时候,所有的实例变量都会分配 一个默认值,这与创建数组的时候是类似的. 3.在{}对实例变量内赋值: in ...

  8. 2107 ACM 水题

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2107 题意:比较大小,即使简单还是没有一次过,粗心的我,终于放假了,虽然我平时课还是有点多,但是希望自己能 ...

  9. window下安装PIL

    PIL非官方库64 友情连接: https://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/ ...

  10. CSS设置文字不能被选中

    /*设置文字不能被选中     以下为css样式*/ -webkit-user-select:none; -moz-user-select:none; -ms-user-select:none; us ...