systemctl笔记221029

启用服务

systemctl enable xxxsystemctl enable xxx.service 启用(开机启动)某项服务

sudo systemctl enable

对应 service xxx enable , 不能用 service xxx.service

启动服务

systemctl start xxxsystemctl start xxx.service 启动某项服务

sudo systemctl start

对应 service xxx start , 不能用 service xxx.service

重启服务

systemctl restart xxxsystemctl restart xxx.service 重启某项服务

sudo systemctl restart

对应service xxx restart , 不能用 service xxx.service

停止服务

systemctl stop xxxsystemctl stop xxx.service 停止某项服务

sudo systemctl stop

对应service xxx stop , 不能用 service xxx.service

禁用服务

systemctl disable xxxsystemctl disable xxx.service 禁用某项服务(开机不启动)

sudo systemctl disable

对应service xxx disable, 不能用 service xxx.service

查看状态
服务状态信息

systemctl status xxxsystemctl status xxx.service 查看某项服务的状态信息

sudo systemctl status
  • loaded ##系统服务已经初始化完成,加载过配置

  • active(running) ##正有一个或多个程序正在系统中执行, vsftpd就是这种模式

  • atcive(exited) ##仅执行一次就正常结束的服务, 目前并沒有任何程序在系統中执行 , 在操作系统中,有某些服务只需要初始化一下就可以了;不需要在服务器中启动一个守护进程。这种服务初始化完成后就直接推出,其服务的状态就是active(exited)

  • atcive(waiting)##正在执行当中,不过还在等待其他的事件才能继续处理

  • inactive(dead) ##服务停止

  • enbaled ##服务开机启动

  • disabled ##服务开机不自启

  • static ##服务开机启动项不可被管理

  • failed ##系统配置错误

服务是否启动

systemctl is-active xxxsystemctl is-active xxx.service 服务是否启动

sudo systemctl is-active
服务是否启用

systemctl is-enabled xxxsystemctl is-enabled xxx.service 服务是否启用

sudo systemctl is-enabled
systemctl list-xxx

list-dependencies list-jobs , list-machines , list-sockets , list-timers , list-unit-files , list-units
systemctl list-units 列出单元, .service就是units中的一种
unit的类型有:

  • .automount: 用于控制自动挂载文件系统,自动挂载即当某一目录被访问时系统自动挂载该目录,这类unit取代了传统Linux系统的autofs相应功能。
  • .device: 对应/dev目录下设备,主要用于定义设备之间的依赖关系。
  • .mount: 定义系统结构层次中的一个挂载点,可以替代过去的/etc/fstab配置文件。
  • .path: 用于监控指定目录变化,并触发其他unit运行。
  • .scope: 这类unit文件不是用户创建的,而是Systemd运行时自己产生的,描述一些系统服务的分组信息。
  • .service: 封装守护进程的启动、停止、重启和重载等操作,是最常见的一种unit类型。
  • .slice: 用于描述cgroup的一些信息,极少使用到,一般用户就忽略它吧。
  • .snapshot: 这种unit其实是systemctl snapshot命令创建的一个描述Systemd unit运行状态的快照。
  • .socket: 监控系统或互联网中的socket消息,用于实现基于网络数据自动触发服务启动。
  • .swap: 定义一个用于做虚拟内存的交换分区。
  • .target: 用于对unit进行逻辑分组,引导其他unit的执行,它替代了SysV中运行级别的作用,并提供更灵活的基于特定设备事件的启动方式,例如multi-user.target相当于过去的运行级别5,而bluetooth.target在有蓝牙设备接入时就会被触发。
  • .timer: 封装由system的里面由时间触发的动作, 替代了crontab的功能。

https://man.archlinux.org/man/systemctl.1.zh_CN

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

kfepiza

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

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

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

打赏作者

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

抵扣说明:

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

余额充值