Figured out why it was failing. I updated my post here -->
https://askubuntu.com/questions/1430191/ubuntu-20-04-not-allowing-runuser-to-manage-systemd-user-services-failed-to/1430379#1430379
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.

```

case $- in
      *i*);;
        *) return;;
esac
```


On Tue, Sep 20, 2022 at 12:43 AM Mantas Mikulėnas <graw...@gmail.com> wrote:

> Non-interactive bash invocations generally don't read ~/.bashrc and don't
> pay attention to environment variables that you set there.
>
>
> On Mon, Sep 19, 2022 at 9:36 PM Dave Houser <davehous...@gmail.com> wrote:
>
>> I am having issues on my Ubuntu 20.04 system running systemd v245.
>> 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"
>>
>> 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.
>>
>> Here is the troubleshooting I performed.
>>
>>
>>    - tried running systemctl --user status myservice.service as mruser, 
>> command
>>    runs with no errors.
>>    - I already checked loginctl for mruser, Linger=yes
>>    - Checked to make sure there was a systemd --user process running
>>    with ps
>>    - 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 has export XDG_RUNTIME_DIR=/run/user/$(id -u) in
>>    ~/.bashrc
>>    - Tried rebooting the system, still nothing.
>>    - Deployed a new instance of Ubuntu 20.04, same problem on it.
>>    - Already read this post
>>    
>> <https://askubuntu.com/questions/1374347/error-running-systemd-as-user-failed-to-connect-to-bus-dbus-session-bus-addr>,
>>    was not very helpful.
>>
>> I made a post about this you can find it here -->
>> https://askubuntu.com/questions/1430191/ubuntu-20-04-not-allowing-runuser-to-manage-systemd-user-services-failed-to?noredirect=1#comment2491580_1430191
>>
>> This seems like odd behavior so I am not sure why this is happening. Can
>> anyone help?
>>
>> - Dave
>>
>>
>>
>
> --
> Mantas Mikulėnas
>

Reply via email to