服务控制、服务的自启

2.服务控制
问题
1)查看autofs服务是否启动
2)停止autofs服务,再次查看服务的运行状态
3)查看network服务支持哪几种控制方式
4)重启bluetooth、network服务
5)开启rsync临时服务(需要安装xinetd服务)
方案
对于服务大家要记得首先要分清的是这个服务是独立服务还是临时服务。
独立服务的启动脚本一般会放在/etc/init.d/。
临时服务的配置文件一般会放在/etc/xinetd.d/。
步骤
实现此案例需要按照如下步骤进行。
步骤一:查看autofs服务是否启动
命令操作如下所示:
[root@localhost ~]# rpm -ql autofs | grep init //可以看出autofs为独立服务
/etc/rc.d/init.d/autofs
[root@localhost ~]# /etc/init.d/autofs status //查看服务运行状态
automount (pid 1433) 正在运行…
[root@localhost ~]#
步骤二:停止autofs服务,再次查看服务的运行状态
命令操作如下所示:
[root@localhost ~]# /etc/init.d/autofs stop
停止 automount:[确定]
[root@localhost ~]# /etc/init.d/autofs status
automount 已停
[root@localhost ~]#
步骤三:查看network服务支持哪几种控制方式
命令操作如下所示:
[root@localhost ~]# /etc/init.d/network //直接敲Enter,会有提示
用法:/etc/init.d/network {start|stop|status|restart|reload|force-reload}
[root@localhost ~]#
步骤四:重启bluetooth、network服务
命令操作如下所示:
[root@localhost ~]# /etc/init.d/bluetooth restart //根据提示它没有restart参数
用法:/etc/init.d/bluetooth {start|stop}
[root@localhost ~]# /etc/init.d/bluetooth stop //停止bluetooth服务
Stopping Bluetooth services:
[root@localhost ~]# /etc/init.d/bluetooth start //开启bluetooth服务
启动蓝牙设备:
[root@localhost ~]# /etc/init.d/network restart //重启network服务
正在关闭接口 eth0: [确定]
关闭环回接口: [确定]
弹出环回接口: [确定]
弹出界面 eth0: Determining if ip address 192.168.1.1 is already in use for device eth0…
[确定]
[root@localhost ~]#
步骤五:开启rsync临时服务(需要安装xinetd服务)
分析: 首先rsync为临时服务,系统默认安装rsync服务。但是没有安装管家xinetd服务。需要搭建yum安装xinetd服务,在更改rsync配置文件重启xinetd服务即可。
命令操作如下所示:
[root@localhost /]# yum -y install xinetd //利用yum安装xinetd服务
[root@localhost /]# vim /etc/xinetd.d/rsync //编辑rsync配置文件
[root@localhost /]# grep disable /etc/xinetd.d/rsync
disable = no
[root@localhost /]# /etc/init.d/xinetd restart //重启xinetd服务
停止 xinetd:[失败]
正在启动 xinetd:[确定]
3.服务的自启
问题
1)查看所有系统服务在不同运行级别的自启状态
2)查看autofs服务的自启状态
3)将autofs服务在运行级别3、5自启状态设为关闭
4)将autofs服务在所有运行级别的自启状态设为关闭
5)将autofs服务运行级别3、5的自启状态设为开启
方案
chkconfig是Linux中定义服务自启状态命令。
在Linux中定义了7个运行级别,各运行级别含义:
0:关机
1:单用户模式
2:字符界面的多用户模式(不支持网络)
3:字符界面的完整多用户模式
4:未分配使用
5:图形界面的多用户模式
6:重启
chkconfig不指定级别默认影响的是2、3、4、5级别的状态。
对于独立服务来说,chkconfig影响的是系统下次开机服务的状态,与当前服务的运行状态无关。
步骤
实现此案例需要按照如下步骤进行。
步骤一:查看所有系统服务在不同运行级别的自启状态
命令操作如下所示:
[root@localhost ~]# chkconfig --list
步骤二:查看autofs服务的自启状态
命令操作如下所示:
[root@localhost ~]# chkconfig --list autofs
autofs 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
[root@localhost ~]#
步骤三:将autofs服务在运行级别3、5自启状态设为关闭
命令操作如下所示:
[root@localhost ~]# chkconfig --list autofs
autofs 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
[root@localhost ~]# chkconfig --level 35 autofs off //记得加上–level选项
[root@localhost ~]# chkconfig --list autofs
autofs 0:关闭 1:关闭 2:关闭 3:关闭 4:启用 5:关闭 6:关闭
[root@localhost ~]#
步骤四:将autofs服务在所有运行级别的自启状态设为关闭
命令操作如下所示:
[root@localhost ~]# chkconfig --list autofs
autofs 0:关闭 1:关闭 2:关闭 3:关闭 4:启用 5:关闭 6:关闭
[root@localhost ~]# chkconfig --level 012356 autofs off
[root@localhost ~]# chkconfig --list autofs
autofs 0:关闭 1:关闭 2:关闭 3:关闭 4:启用 5:关闭 6:关闭
[root@localhost ~]#
步骤五:将autofs服务运行级别3、5的自启状态设为开启
命令操作如下所示:
[root@localhost ~]# chkconfig --list autofs
autofs 0:关闭 1:关闭 2:关闭 3:关闭 4:启用 5:关闭 6:关闭
[root@localhost ~]# chkconfig --level 35 autofs on
[root@localhost ~]# chkconfig --list autofs
autofs 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
[root@localhost ~]#

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

董筱杰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值