I want to know how to stop systemd-logind and not be restart or activated later ?

I know that systemd service unit file have a parameter: restart= ,when set its value is no or on-failure, stop this service like systemctl stop xxx ,and this service will not be restart or activated

but systemd-logind looks specical? I am a little puzzled

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.

Description=Login Service
Documentation=man:systemd-logind.service(8) man:logind.conf(5)
After=nss-user-lookup.target user.slice

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


# Increase the default a bit in order to allow many simultaneous
# logins since we keep one fd open per session.

To stop a service being activated, the right command to use is systemctl mask .... This will also prevent it being started at boot time.

If you only want to prevent it being started at the moment, use systemctl mask --runtime. This means the setting will be forgotten when you shut down or reboot.

logind is quite important, I would anticipate breaking boot or login - have a rescue disk handy and know how to use it :).

| improve this answer | |
  • 1
    Thanks a lot, My problem is that systemd-logind running in docker container and restart every minutes, and looks like this problem:github.com/systemd/systemd/issues/1961 this phenomenon only occured at docker container , So ,I am trying to stop systemd-logind and I think systemd-logind is not import in contianer ,What do you think about it ? – 穆阿浩 Jun 5 '17 at 8:04
  • I reallly curious that what is systemd-logind's effect? when I systemctl mask systemd-logind ,I looks normal, and I can ssh my host normally – 穆阿浩 Jun 5 '17 at 8:07

To disable systemd-logind you have to mask the service and disable the systemd PAM module (pam_systemd). You can do it with the following commands:

systemctl mask systemd-logind.service pam-auth-update

It is reasonably safe and I have done it for many years.

| improve this answer | |
  • 1
    One caveat is that restarting ssh will then kill all active ssh sessions. ssh is deliberately designed to avoid that, it's useful e.g. during upgrades. – sourcejedi Dec 2 '17 at 17:30
  • you don't need to restart ssh after disabling this "useful" systemd component. – Gabriel Samfira Sep 27 '19 at 12:04
  • After I did this in Debian 10, X11 did not start any more. – ceving Nov 28 '19 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.