When you login using SSH, pam_systemd module automatically launches a systemd --user instance when the user logs in for the first time. We can mask the [email protected] to deactivate this. Even when we deactivate the [email protected], there is no noticeable impact.
Is there a impact when we mask the service ?
disable
and mask
are different things.
disable
means the [Install]
section of a unit is ignored. This typically means WantedBy=multi-user.target
will be ignored, preventing the unit from starting on boot.mask
means the unit cannot be activated. That includes when another unit Wants=
it, or even if you try to start it manually. mask
ing will certainly prevent [email protected]
from starting.When you sudo systemctl mask [email protected]
, you are disabling the --user
bus of systemd
. unmask
and start
the unit, then see systemctl --user status
to see what will be unavailable.
On my desktop with a desktop environment, this looks something like:
$ systemctl --user status
● desktop
State: running
Jobs: 0 queued
Failed: 0 units
Since: Sun 2022-02-13 13:09:28 CET; 3 days ago
CGroup: /user.slice/user-1000.slice/[email protected]
├─app.slice
│ ├─at-spi-dbus-bus.service
│ ├─dbus.service
│ ├─dconf.service
│ ├─dunst.service
│ ├─gvfs-afc-volume-monitor.service
│ ├─gvfs-daemon.service
│ ├─gvfs-goa-volume-monitor.service
│ ├─gvfs-gphoto2-volume-monitor.service
│ ├─gvfs-metadata.service
│ ├─gvfs-mtp-volume-monitor.service
│ ├─gvfs-udisks2-volume-monitor.service
│ ├─vnc.service
│ ├─xdg-desktop-portal-gnome.service
│ ├─xdg-desktop-portal-gtk.service
│ └─xdg-permission-store.service
├─background.slice
│ ├─plasma-kglobalaccel.service
│ └─tracker-miner-fs-3.service
├─init.scope
└─session.slice
├─pipewire-media-session.service
├─pipewire.service
├─pulseaudio.service
├─xdg-desktop-portal.service
└─xdg-document-portal.service
On a headless server with no desktop environment, this includes effectively nothing.
$ systemctl --user status
● server
State: running
Jobs: 0 queued
Failed: 0 units
Since: Wed 2022-02-16 13:29:30 CET; 3s ago
CGroup: /user.slice/user-1000.slice/[email protected]
└─init.scope
├─581 /lib/systemd/systemd --user
└─583 (sd-pam)
If I were to systemctl mask [email protected]
:
In both cases, I'll loose the ability to define user-bus units if I need them. user
units can be useful for things like:
Edit: I almost forgot about some mounts. systemd
create $XDG_RUNTIME_DIR
when a user logs in. If you mask [email protected]
, that runtime user directory will not be created on login. Anything that depends on it may have a problem.
See systemctl --user list-units
for more units that get loaded on the user bus.