使用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. LCN解决分布式事务原理解析+项目实战(原创精华版)

    写在前面: 原创不易,如果觉得不错推荐一下,谢谢! 由于工作需要,公司的微服务项目需解决分布式事务的问题,且由我进行分布式事务框架搭建和整合工作. 那么借此机会好好的将解决分布式事务的内容进行整理一下 ...

  2. 工作5年了还说不清bean生命周期?大厂offer怎么可能给你!

    第一,这绝对是一个面试高频题. 比第一还重要的第二,这绝对是一个让人爱恨交加的面试题.为什么这么说?我觉得可以从三个方面来说: 先说会不会.看过源码的人,这个不难:没看过源码的人,无论是学.硬背.还是 ...

  3. MAC下安装Fiddler抓包工具

    需求 我们都知道在Mac电脑下面有一个非常好的抓包工具:Charles.但是这个只能抓代理的数据包.但是有时候想要调试本地网卡的数据库 Charles 就没办法了.就想到了在windows下面的一个F ...

  4. 聊聊order by的工作机制

    总结写在前面: 1. 介绍了orderBy的两种算法流程:全字段排序 和 rowid排序. 2. rowid排序 相比 全字段排序,参与排序字段较少,耗内存较少,多一步回表,如果内存够的情况下MySQ ...

  5. stm32的hall库新建模板编译错误: #error "Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)"的处理

    在stm32f1xx.h file文件中找到如下代码: /* Uncomment the line below according to the target STM32L device used i ...

  6. Go语言之Go语言变量

    GO 语言变量 Go语言是静态类型语言,因此变量(variable)是有明确类型的,编译器也会检查变量类型的正确性. 标识符 在编程语言中标识符就是程序员定义的具有特殊意义的词,比如变量名.常量名.函 ...

  7. java 为什么重写equals一定要重写hashcode?

    前言 最近复习,又看到了这个问题,在此记录和整理,通过例子来说明这种情况的原因,使大家可以清晰明白这个问题. 初步探索 首先我们要了解equals方法是什么,hashcode方法是什么. equals ...

  8. linux-manjaro下添加Yahei Hybrid Consola字体

    1.下载地址 http://www.win10zhijia.net/soft/20160921/3217.html 2.解压 unzip xxx 3.安装 sudo mkdir /usr/share/ ...

  9. intern()方法的使用

    intern() intern方法的作用是:如果字符串常量池中已经包含一个字符串等于此String对象的字符串,则返回常量池中的这个String对应的对象, 否则将其添加到常量池并返回常量池中的引用. ...

  10. 强化学习之七:Visualizing an Agent’s Thoughts and Actions

    本文是对Arthur Juliani在Medium平台发布的强化学习系列教程的个人中文翻译,该翻译是基于个人分享知识的目的进行的,欢迎交流!(This article is my personal t ...