0

If I do:

sudo systemctl --user daemon-reload

It fails with:

Failed to connect to bus: No such file or directory

Being the "sudo" necessary, as this belongs to a package installation.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

1 Answers1

0

With sudo, you're running systemctl --user as root... but if root is not logged in at the time, there is no active per-user D-Bus instance for root.

Only actual logged-in users have a user-specific D-Bus instance running. Using su or sudo may not necessarily be fully equivalent to a real login in this particular sense. If your Linux distribution has the loginctl command, use it without any parameters to see which users have active sessions (in the sense that they have an active per-user D-Bus instance).

The --global option is only meaningful with systemctl enable or systemctl disable.

If you want to run systemctl --user daemon-reload on all currently active users' sessions, you might want to do something like this:

#!/bin/sh
for reloaduser in $(loginctl --no-legend list-users | awk '{print $2;}')
do
    sudo -u $reloaduser systemctl --user daemon-reload
done
telcoM
  • 96,466