systemd

1. list service 

 列出正在运行的 Unit
$ systemctl list-units

# 列出所有Unit,包括没有找到配置文件的或者启动失败的
$ systemctl list-units --all

# 列出所有没有运行的 Unit
$ systemctl list-units --all --state=inactive

# 列出所有加载失败的 Unit
$ systemctl list-units --failed

# 列出所有正在运行的、类型为 service 的 Unit
$ systemctl list-units --type=service

Example

 

root@localhost:~#  systemctl list-units --all  |grep gett
  getty-static.service                                                                              loaded    inactive dead      getty on tty2-tty6 if dbus and logind are not available
  serial-getty@ttyS0.service                                                                        loaded    active   running   Serial Getty on ttyS0
  system-serial\x2dgetty.slice                                                                      loaded    active   active    system-serial\x2dgetty.slice
  getty-pre.target                                                                                  loaded    inactive dead      Login Prompts (Pre)
  getty.target                                                                                      loaded    active   active    Login Prompts
root@localhost:~#

2. restart

 

# 立即启动一个服务
$ sudo systemctl start apache.service

# 立即停止一个服务
$ sudo systemctl stop apache.service

# 重启一个服务
$ sudo systemctl restart apache.service

# 杀死一个服务的所有子进程
$ sudo systemctl kill apache.service

 

3.  Enable/disable 

 


$ sudo systemctl enable clamd@scan.service
# 等同于
$ sudo ln -s '/usr/lib/systemd/system/clamd@scan.service' '/etc/systemd/system/multi-user.target.wants/clamd@scan.service'
root@Ubuntu 18.04 LTS

ls -l   /etc/systemd/system/getty.target.wants/
total 0
lrwxrwxrwx 1 root root 34 Jan  8  2020 getty@tty1.service -> /lib/systemd/system/getty@.service
lrwxrwxrwx 1 root root 34 Jan  8  2020 getty@ttyAMA0.service -> /lib/systemd/system/getty@.service

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值