使用systemctl工具

8.1问题

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

重启httpd、crond、bluetooth服务,查看状态

禁止bluetooth服务开机自启,并停用此服务

设置默认级别为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、bluetooth

[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

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

使用systemctl工具的更多相关文章

  1. Service系统服务(三):查看进程信息、进程调度及终止、系统日志分析、使用systemctl工具

    一.查看进程信息 目标: 本例要求掌握查看进程信息的操作,使用必要的命令工具完成下列任务: 找出进程 gdm 的 PID 编号值 列出由进程 gdm 开始的子进程树结构信息 找出进程 sshd 的父进 ...

  2. 【MySQL】CentOS7中使用systemctl工具管理启动和停止MySQL

    centos7以前版本,可以使用这个/etc/init.d/mysqld start 来启动mysql 但是centos7之后,通过systemctl start mysqld.service 这个要 ...

  3. centos7也支持service命令启动服务吗,对于centos7 中的systemctl和旧的service命令的区别和联系

    一.centos7也支持service命令启动服务吗 CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服 ...

  4. Rabbitmq集群升级方案

    升级Rabbitmq 3.6.3版本至3.6.6版本,升级过程中的一些关键步骤记录 Step 1: 顺序关闭集群所有节点,这里注意最后一个关闭的节点必须保证为硬盘节点,而非RAM节点: centOS ...

  5. CentOS7关闭防火墙方法

    在之前的版本中关闭防火墙等服务的命令是 service iptables stop /etc/init.d/iptables stop 在RHEL7中,其实没有这个服务 [root@rhel7 ~]# ...

  6. RedHat Enterprise Linux 7关闭防火墙方法

    systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起 在之前的版本中关闭防火墙等服务的命令是 service iptables stop ...

  7. CentOS 7 service systemnctl

    在之前的版本中关闭防火墙等服务的命令是 service iptables stop /etc/init.d/iptables stop 在RHEL7中,其实没有这个服务 [root@rhel7 ~]# ...

  8. Linux Systemd——在RHEL/CentOS 7中启动/停止/重启服务

    RHEL/CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Li ...

  9. CentOS 7.0 systemd代替service

    CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Linux标准 ...

随机推荐

  1. 利用Python爬取OPGG上英雄联盟英雄胜率及选取率信息

    一.分析网站内容 本次爬取网站为opgg,网址为:” http://www.op.gg/champion/statistics” 由网站界面可以看出,右侧有英雄的详细信息,以Garen为例,胜率为53 ...

  2. 关于.NET中的控制反转及AutoFac的简单说明

    目录 1.控制反转 1.1 什么是依赖? 1.2 什么是控制反转? 1.3 什么是依赖注入? 1.4 简单总结 2.控制反转容器 2.1 IOC容器说明 2.2 使用AutoFac的简介示例 3 使用 ...

  3. Chrome调试工具常用功能

    一.打开的快捷键 windows: ctrl + shift + i/F12 1.Elements 1.选中 元素 切换至 Event… Tab可以查看这个元素绑定的事件 2.在 Element 选项 ...

  4. 服务发现组件之 — Eureka

    前言 现在流行的微服务体系结构正在改变我们构建应用程序的方式,从单一的单体服务转变为越来越小的可单独部署的服务(称为微服务),共同构成了我们的应用程序.当进行一个业务时不可避免就会存在多个服务之间调用 ...

  5. php 数据库 操作

    header.php <?php error_reporting(0);//加上error_reporting(0);就不会弹出警告了 // header("Content-type: ...

  6. python关于字典如何格式化地写入文件之中

    1.python关于字典如何式化地写入文件之中 如何写入:https://blog.csdn.net/qq_15642411/article/details/79943741 (推荐使用json包) ...

  7. Journal of Proteome Research | Proteomic Profiling of Rhabdomyosarcoma-Derived Exosomes Yield Insights into Their Functional Role in Paracrine Signaling (解读人:孙国莹)

    文献名:Proteomic Profiling of Rhabdomyosarcoma-Derived Exosomes Yield Insights into Their Functional Ro ...

  8. Spring Boot入门系列(九)如何实现异步执行任务

    前面介绍了Spring Boot 如何整合定时任务,不清楚的朋友可以看看之前的文章:https://www.cnblogs.com/zhangweizhong/category/1657780.htm ...

  9. PU Learning简介:对无标签数据进行半监督分类

    当只有几个正样本,你如何分类无标签数据 假设您有一个交易业务数据集.有些交易被标记为欺诈,其余交易被标记为真实交易,因此您需要设计一个模型来区分欺诈交易和真实交易. 假设您有足够的数据和良好的特征,这 ...

  10. 用c写的简单的日历(学习模块划分)

    简单日历 ​ 主要目的是学习函数模块划分,成品大概是这样,加了一些花里胡哨的东西(/▽\) ​ 分三个模块,主函数.c 显示.c 计算.c 与.h 文件 有两种实现方式,区别在于是否以数组在模块之间传 ...