如何禁用 systemd 中的服务?

Tre*_*ith 6 systemd services

我知道命令是什么,sytemctl disable NAME但我对NAME参数有疑问。

例如bluetoothFedora 21 上的service[1]。对于NAME参数,您应该输入bluetoothorbluetooth.servicebluetooth.target?

请注意,我以蓝牙为例,但问题是通用的(即,如果服务有许多关联的单元(即套接字、目标、服务))。


[1] 当我搜索蓝牙服务时,我发现了一些与“蓝牙”grep 字符串匹配的内容:

$ systemctl list-unit-files|grep -i bluetooth
bluetooth.service                           enabled 
bluetooth.target                            static  
Run Code Online (Sandbox Code Playgroud)

sou*_*ake 5

服务在具有后缀的单元文件中定义.service

systemctl专门用于禁用某个服务时,您应该指定单元文件的全名(例如bluetooth.service)。如果省略后缀.service,则.service假定为 then。因此,例如,以下两个命令是等效的:

带有显式.service后缀:

$ systemctl disable bluetooth.service
Run Code Online (Sandbox Code Playgroud)

使用隐式.service后缀:

$ systemctl disable bluetooth
Run Code Online (Sandbox Code Playgroud)

关于bluetooth.target文件:SysV Init Runlevels 的概念已systemd. 您应该参考man systemd.target以获取更多信息。