How to execute "systemctl --user" as a different user
Issue
-
Trying to execute
systemctl --user
as 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 --user
after setting the environment variableXDG_RUNTIME_DIR
for 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
- systemd (user instance)
- sudo / su
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.