考试首页 | 考试用书 | 培训课程 | 模拟考场 | 考试论坛  
  当前位置:Linux认证 > 红帽认证 > 红帽认证辅导 > 文章内容
  

RHCE7认证学习笔记:控制服务和后台进程

来源:Linux社区 [ 2016年2月13日 ] 【

1、控制服务(services and daemons)

RHEL7以前的版本控制服务使用service XX start|stop|status:
[root@linuxidc ~]# service sshd status

RHEL7控制服务使用systemctl start|stop|status|restart  XX服务,查看服务的当前运行状态使用is-active:
[root@linuxidc ~]# systemctl status sshd

[root@linuxidc ~]# systemctl is-active sshd
active

[root@linuxidc ~]# systemctl sart|stop|restart sshd

查看某项服务是否会开机自动启动使用is-enable,相对应的是disable:
[root@linuxidc ~]# systemctl is-enabled sshd
enabled

    禁用某项服务使用mask,相对应的是unmask:

    下面总结一下systemctl命令常用控制服务的选项:

  start [NAME...]                Start (activate) one or more units 启动服务
  stop [NAME...]                  Stop (deactivate) one or more units 停止服务
  reload [NAME...]                Reload one or more units 重新加载
  restart [NAME...]              Start or restart one or more units 重新启动
 
  kill [NAME...]                  Send signal to processes of a unit 杀死进程
  is-active [NAME...]            Check whether units are active 是否启动
  is-failed [NAME...]            Check whether units are failed 是否失败
  status [NAME...|PID...]        Show runtime status of one or more units 状态

  enable [NAME...]                Enable one or more unit files 开机启动
  disable [NAME...]              Disable one or more unit files 开机不启动
  reenable [NAME...]              Reenable one or more unit files 重新设置开机启动

 is-enabled [NAME...]            Check whether unit files are enabled 是否开机启动
  mask [NAME...]                  Mask one or more units 禁用服务
  unmask [NAME...]                Unmask one or more units 不禁用服务

查看系统所有服务:systemctl list-units-all或system ctl list-units-files:
[root@linuxidc ~]# systemctl list-units

[root@linuxidc ~]# systemctl list-unit-files

加上type选项可以查看所有服务:
[root@linuxidc ~]# systemctl list-unit-files --type service
UNIT FILE                                  STATE   
abrt-ccpp.service                          enabled 
abrt-oops.service                          enabled 
abrt-pstoreoops.service                    disabled

本文纠错】【告诉好友】【打印此文】【返回顶部
将考试网添加到收藏夹 | 每次上网自动访问考试网 | 复制本页地址,传给QQ/MSN上的好友 | 申请链接 | 意见留言 TOP
关于本站  网站声明  广告服务  联系方式  站内导航  考试论坛
Copyright © 2007-2013 中华考试网(Examw.com) All Rights Reserved