When I try to run runuser -l mruser -c "systemctl --user status myservice.service"
as root, I get the following error:
Failed to connect to bus: No such file or directory
I do not get this error when doing the same on a RHEL 8.4 system. I am able to run systemd --user commands as mruser using runuser with no problems.
Troubleshooting Performed:
- tried running
systemctl --user status myservice.service
asmruser
command runs with no errors. - I already checked loginctl for
mruser
,Linger=yes
- Checked to make sure there was a
systemd --user
process running withps
- Logged into the user's account directly with separate ssh session, Then tried the same command as root in the original session, still same error.
mruser
already hasexport XDG_RUNTIME_DIR=/run/user/$(id -u)
in~/.bashrc
- Tried rebooting the system, still nothing.
- Already read this post, was not very helpful.
On the RHEL system systemd is v239, On Ubuntu 20.04 its v245. Am I missing something? Why can I not run the systemd --user commands as root on Ubuntu?
UPDATE: I think the issue has to do with runuser
not seeing exported variables. which means $XDG_RUNTIME_DIR
is not being recognized or used. Anyone know why runuser is not seeing exported variables defined in mruser
's ~/.bashrc
file? I checked the RHEL instance, and root IS able to see and use the exported variables.