使用systemctl工具

8案例8:使用systemctl工具

8.1问题

本例要求掌握systemctl控制工具的基本操作,完成下列任务:

  1. 重启httpd、crond、bluetooth服务,查看状态
  2. 禁止bluetooth服务开机自启,并停用此服务
  3. 设置默认级别为multi-user.target并确认

8.2方案

systemd是一个更高效的系统&服务管理器,其相关特性如下:

  • 开机服务并行启动,个系统服务间的精确依赖
  • 配置目录:/etc/systemd/system/
  • 服务目录:/lib/systemd/system/

systemctl是systemd的管理工具,将相关资源组织为unit配置单元进行管理。

不同unit决定了一组相关的启动任务,Service和target是最常用的配置单元:

  • Service:后台独立服务
  • target:一套配置单元的组合,类似于传统“运行级别”

8.3步骤

实现此案例需要按照如下步骤进行。

步骤一:重启httpd、crond、bluetooth服务、查看状态

1)重启系统服务httpd、crond、bluetoodh

[root@svr7 ~]# systemctl restart httpd crond bluetooth

2)查看上述服务的状态 

[root@svr7 ~]# systemctl  status  httpd  crond  bluetooth 
* httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2017-01-06 18:18:20 CST; 18s ago
.. ..
* crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-01-06 18:18:19 CST; 19s ago
.. ..
* bluetooth.service - Bluetooth service
   Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-01-06 18:18:19 CST; 19s ago
.. ..

步骤二:禁止bluetooth服务开机自启,并停用此服务

1)停用bluetooth服务

[root@svr7 ~]# systemctl  stop  bluetooth

2)禁止bluetooth服务开机自启

[root@svr7 ~]# systemctl  disable  bluetooth
Removed symlink /etc/systemd/system/dbus-org.bluez.service.
Removed symlink /etc/systemd/system/bluetooth.target.wants/bluetooth.service.
[root@svr7 ~]# systemctl  is-enabled  Bluetooth             //检查结果
disabled

 步骤三:设置默认级别为multi-user.target并确认

1)查看默认运行级别

[root@svr7 ~]# systemctl  get-default 
graphical.target

2)将默认运行级别设置为multi-user.target

[root@svr7 ~]# systemctl  set-default  multi-user.target 
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.

3)确认配置结果

[root@svr7 ~]# systemctl  get-default 
multi-user.target

根据此处的设置,重启此虚拟机后图形桌面将不可再用。 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值