(RHCE)备考 Linux入门到精通系列之 服务管理

 

服务管理
============================================
RHEL6: init     ====== /etc/init.d/network(管理脚本)
RHEL7: systemd    ====== systemctl

2.管理服务(unit)

systemctl 提供了一组子命令来管理单个的 unit,其命令格式为:

systemctl [command] [unit]

 

command 主要有:

start:立刻启动后面接的 unit。

stop:立刻关闭后面接的 unit。

restart:立刻关闭后启动后面接的 unit,亦即执行 stop 再 start 的意思。

reload:不关闭 unit 的情况下,重新载入配置文件,让设置生效。

enable:设置下次开机时,后面接的 unit 会被启动。

disable:设置下次开机时,后面接的 unit 不会被启动。

status:目前后面接的这个 unit 的状态,会列出有没有正在执行、开机时是否启动等信息。

is-active:目前有没有正在运行中。

is-enable:开机时有没有默认要启用这个 unit。

kill :不要被 kill 这个名字吓着了,它其实是向运行 unit 的进程发送信号。

show:列出 unit 的配置。

mask:注销 unit,注销后你就无法启动这个 unit 了。

unmask:取消对 unit 的注销

1. 查看服务状态
# systemctl status sshd.service


2. 对服务进行管理
# systemctl stop sshd
# systemctl start sshd
# systemctl restart sshd.service
# systemctl reload sshd.service

# systemctl disable sshd
# systemctl enable sshd
# systemctl mask sshd
# systemctl unmask sshd


# systemctl            //查看所有UNIT(单元),例如service,mount,device,path,socket,swap,target
# systemctl --type service    //查看所有service UNIT,仅活动的单元
# systemctl --type service --all
# systemctl --type target

# systemctl get-default
# systemctl set-default multi-user.target

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值