如何停止systemd-logind并且以后不被激活?

穆阿浩*_*穆阿浩 1 systemd

我想知道如何停止 systemd-logind 并且稍后不重新启动或激活?

我知道 systemd 服务单元文件有一个参数: restart= ,当它的值设置为 no 或 on-failure 时,停止此服务,例如systemctl stop xxx,此服务将不会重新启动或激活

但是 systemd-logind 看起来很特别?我有点不解

I #systemctl cat systemd-logind
# /usr/lib/systemd/system/systemd-logind.service
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Login Service
Documentation=man:systemd-logind.service(8) man:logind.conf(5)
Documentation=http://www.freedesktop.org/wiki/Software/systemd/logind
Documentation=http://www.freedesktop.org/wiki/Software/systemd/multiseat
Wants=user.slice
After=nss-user-lookup.target user.slice

# Ask for the dbus socket. If running over kdbus, the socket will
# not be actually used.
Wants=dbus.socket
After=dbus.socket

[Service]
ExecStart=/usr/lib/systemd/systemd-logind
Restart=no
RestartSec=0
#BusName=org.freedesktop.login1
CapabilityBoundingSet=CAP_SYS_ADMIN CAP_MAC_ADMIN CAP_AUDIT_CONTROL CAP_CHOWN CAP_KILL CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE CAP_FOWNER CAP_SYS_TTY_CONFIG
WatchdogSec=1min

# Increase the default a bit in order to allow many simultaneous
# logins since we keep one fd open per session.
LimitNOFILE=16384
Run Code Online (Sandbox Code Playgroud)

sou*_*edi 5

要停止正在激活的服务,正确使用的命令是systemctl mask ...。这也将防止它在启动时启动。

如果您只想阻止它此刻启动,请使用systemctl mask --runtime. 这意味着当您关闭或重新启动时,设置将被忘记。

logind 非常重要,我预计会中断启动或登录 - 手头有一个救援磁盘并知道如何使用它:)。