<div dir="ltr">Figured out why it was failing. I updated my post here --> <a href="https://askubuntu.com/questions/1430191/ubuntu-20-04-not-allowing-runuser-to-manage-systemd-user-services-failed-to/1430379#1430379">https://askubuntu.com/questions/1430191/ubuntu-20-04-not-allowing-runuser-to-manage-systemd-user-services-failed-to/1430379#1430379</a><div>Problem was Ubuntu default user .bashrc had the following case statement that required `bash -i` to be used to start an interactive shell. I removed it as a work around and runuser works now. </div><div><br></div><div>```<br><pre style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit;border-radius:0px">case $- in
      *i*);;
        *) return;;
esac
```</code></pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 20, 2022 at 12:43 AM Mantas Mikulėnas <<a href="mailto:grawity@gmail.com">grawity@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Non-interactive bash invocations generally don't read ~/.bashrc and don't pay attention to environment variables that you set there.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 19, 2022 at 9:36 PM Dave Houser <<a href="mailto:davehouser1@gmail.com" target="_blank">davehouser1@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I am having issues on my Ubuntu 20.04 system running systemd v245.<div>When trying to run `runuser -l mruser -c "systemctl --user status myservice.service"` I keep getting "Failed to connect to bus: No such file or directory" </div><div><br></div><div>This does not make sense to me because I have the same set up on a RHEL 8.4 system running systemd v239, and I dont see this issue. I can run systemd --user commands as root with runuser with no issues. </div><div><br></div><div>Here is the troubleshooting I performed. <br><br><ul style="margin-top:0px;margin-right:0px;margin-left:30px;padding:0px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI Adjusted","Segoe UI","Liberation Sans",sans-serif;font-size:15px;vertical-align:baseline;list-style-position:initial;box-sizing:inherit;color:rgb(35,38,41)"><li style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">tried running <code style="margin:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">systemctl --user status myservice.service</code> as <code style="margin:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">mruser,</code> command runs with no errors.</li><li style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">I already checked loginctl for <code style="margin:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">mruser</code>, <code style="margin:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">Linger=yes</code></li><li style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">Checked to make sure there was a <code style="margin:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">systemd --user</code> process running with <code style="margin:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">ps</code></li><li style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">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.</li><li style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit"><code style="margin:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">mruser</code> already has <code style="margin:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">export XDG_RUNTIME_DIR=/run/user/$(id -u)</code> in <code style="margin:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap">~/.bashrc</code></li><li style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">Tried rebooting the system, still nothing.</li><li style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">Deployed a new instance of Ubuntu 20.04, same problem on it. </li><li style="margin:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit">Already read <a href="https://askubuntu.com/questions/1374347/error-running-systemd-as-user-failed-to-connect-to-bus-dbus-session-bus-addr" style="margin:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit" target="_blank">this post</a>, was not very helpful.</li></ul><div><font face="-apple-system, BlinkMacSystemFont, Segoe UI Adjusted, Segoe UI, Liberation Sans, sans-serif" color="#232629"><span style="font-size:15px">I made a post about this you can find it here --> </span></font><a href="https://askubuntu.com/questions/1430191/ubuntu-20-04-not-allowing-runuser-to-manage-systemd-user-services-failed-to?noredirect=1#comment2491580_1430191" target="_blank">https://askubuntu.com/questions/1430191/ubuntu-20-04-not-allowing-runuser-to-manage-systemd-user-services-failed-to?noredirect=1#comment2491580_1430191</a></div><div><br></div><div>This seems like odd behavior so I am not sure why this is happening. Can anyone help?</div><div><br></div><div>- Dave</div></div><div><br></div><div><br></div></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr"><div dir="ltr">Mantas Mikulėnas</div></div>
</blockquote></div>