How to execute "systemctl --user" as a different user
Issue
-
Trying to execute
systemctl --useras a different user fails withFailed to connect to bus: No such file or directory# systemctl --user list-units Failed to connect to bus: No such file or directory -
Trying to execute
systemctl --userafter setting the environment variableXDG_RUNTIME_DIRfor the target user fails withFailed to connect to bus: Operation not permitted# id -u user1 1000 # export XDG_RUNTIME_DIR=/run/user/1000 # systemctl --user list-units Failed to connect to bus: Operation not permitted
Environment
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
- Red Hat Enterprise Linux 10
- systemd (user instance)
- sudo / su
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.