linux - systemctl disable name.service 在重启后不会持续存在

标签 linux ubuntu systemd

我正在尝试找到一种在启动时在 Ubuntu 16.04 上禁用蓝牙的方法,我一直在网上绊倒的一种方法是使用 systemd

基本上

首先,停止服务:

sudo systemctl 停止蓝牙服务

然后禁用它:

sudo systemctl 禁用蓝牙服务

检查:

sudo systemctl status bluetooth.service

https://askubuntu.com/questions/744640/best-way-to-deactivate-bluetooth-on-system-startup-with-systemd-and-not-upstar

但每次我重新启动它都会重新打开,我找不到任何人在线提示 systemd disable 命令不像我的情况那样工作

即使在 ubuntu wiki 上它也说它应该工作我做错了什么?

https://wiki.ubuntu.com/SystemdForUpstartUsers

这是我运行这些命令时的输出

    mohamed@mohamed-UX330UAK:~$ sudo systemctl stop bluetooth.service
[sudo] password for mohamed: 
mohamed@mohamed-UX330UAK:~$ sudo systemctl disable bluetooth.service
Synchronizing state of bluetooth.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install disable bluetooth
insserv: warning: current start runlevel(s) (empty) of script `bluetooth' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `bluetooth' overrides LSB defaults (0 1 6).
insserv: warning: current start runlevel(s) (empty) of script `bluetooth' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `bluetooth' overrides LSB defaults (0 1 6).
mohamed@mohamed-UX330UAK:~$ sudo systemctl status bluetooth.service
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; disabled; vendor prese
   Active: inactive (dead) since Wed 2017-04-26 19:56:04 AEST; 23s ago
     Docs: man:bluetoothd(8)
 Main PID: 882 (code=exited, status=0/SUCCESS)
   Status: "Quitting"

Apr 26 19:42:19 mohamed-UX330UAK bluetoothd[882]: Endpoint registered: sender=:1
Apr 26 19:42:19 mohamed-UX330UAK bluetoothd[882]: Endpoint registered: sender=:1
Apr 26 19:42:19 mohamed-UX330UAK bluetoothd[882]: RFCOMM server failed for Heads
Apr 26 19:42:34 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=
Apr 26 19:42:34 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=
Apr 26 19:56:04 mohamed-UX330UAK systemd[1]: Stopping Bluetooth service...
Apr 26 19:56:04 mohamed-UX330UAK bluetoothd[882]: Terminating
Apr 26 19:56:04 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=
Apr 26 19:56:04 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=
Apr 26 19:56:04 mohamed-UX330UAK systemd[1]: Stopped Bluetooth service.
lines 1-17/17 (END)...skipping...
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; disabled; vendor prese
   Active: inactive (dead) since Wed 2017-04-26 19:56:04 AEST; 23s ago
     Docs: man:bluetoothd(8)
 Main PID: 882 (code=exited, status=0/SUCCESS)
   Status: "Quitting"

Apr 26 19:42:19 mohamed-UX330UAK bluetoothd[882]: Endpoint registered: sender=:1
Apr 26 19:42:19 mohamed-UX330UAK bluetoothd[882]: Endpoint registered: sender=:1
Apr 26 19:42:19 mohamed-UX330UAK bluetoothd[882]: RFCOMM server failed for Heads
Apr 26 19:42:34 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=
Apr 26 19:42:34 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=
Apr 26 19:56:04 mohamed-UX330UAK systemd[1]: Stopping Bluetooth service...
Apr 26 19:56:04 mohamed-UX330UAK bluetoothd[882]: Terminating
Apr 26 19:56:04 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=
Apr 26 19:56:04 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=
Apr 26 19:56:04 mohamed-UX330UAK systemd[1]: Stopped Bluetooth service.
~
~
~
~
~
~
~
lines 1-17/17 (END)...skipping...
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; disabled; vendor preset: enabled)
   Active: inactive (dead) since Wed 2017-04-26 19:56:04 AEST; 23s ago
     Docs: man:bluetoothd(8)
 Main PID: 882 (code=exited, status=0/SUCCESS)
   Status: "Quitting"

Apr 26 19:42:19 mohamed-UX330UAK bluetoothd[882]: Endpoint registered: sender=:1.79 path=/MediaEndpoint/A2DPSource
Apr 26 19:42:19 mohamed-UX330UAK bluetoothd[882]: Endpoint registered: sender=:1.79 path=/MediaEndpoint/A2DPSink
Apr 26 19:42:19 mohamed-UX330UAK bluetoothd[882]: RFCOMM server failed for Headset Voice gateway: rfcomm_bind: Address already in use (98)
Apr 26 19:42:34 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=:1.43 path=/MediaEndpoint/A2DPSource
Apr 26 19:42:34 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=:1.43 path=/MediaEndpoint/A2DPSink
Apr 26 19:56:04 mohamed-UX330UAK systemd[1]: Stopping Bluetooth service...
Apr 26 19:56:04 mohamed-UX330UAK bluetoothd[882]: Terminating
Apr 26 19:56:04 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=:1.79 path=/MediaEndpoint/A2DPSource
Apr 26 19:56:04 mohamed-UX330UAK bluetoothd[882]: Endpoint unregistered: sender=:1.79 path=/MediaEndpoint/A2DPSink
Apr 26 19:56:04 mohamed-UX330UAK systemd[1]: Stopped Bluetooth service.

最佳答案

也许该服务是由依赖项启动的。有一个 third level of "off" with systemd你可以试试,叫做“掩蔽”:

systemctl mask bluetooth.service

一旦被屏蔽,服务就根本无法启动,即使手动启动也是如此。您可以稍后“揭开”它。

关于linux - systemctl disable name.service 在重启后不会持续存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43630934/

相关文章:

linux - kill一个进程,等待进程退出

linux - 什么是 xsession 错误?

java - 无法执行基本的 Hadoop Mapreduce Wordcount 示例

linux - 如何从 Linux (ubuntu) 中的 bash 脚本运行 exec bash 命令?

linux - 如何使用列表生成配置文件

Linux: "fstab"有额外的挂载选项吗?

php - Ubuntu Server - PHP curl 在服务器上查找地址,即使指定了其他网站

mysql - 在 AWD 服务器上安装 MySQL 出现错误

docker - 使 systemctl 在 debian 拉伸(stretch)图像中的容器内部工作

java - Systemd:添加 logback 后无法启动 spring boot