# Running a user-level services in Rocky 9

**URL:** <https://forums.rockylinux.org/t/running-a-user-level-services-in-rocky-9/11880>\
**Category:** Rocky Linux Help & Support\
**Tags:** rocky-linux-9\
**Created:** [November 16, 2023, 4:05pm UTC](https://forums.rockylinux.org/t/running-a-user-level-services-in-rocky-9/11880 "2023-11-16T16:05:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ariksu](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@ariksu](https://forums.rockylinux.org/u/ariksu)\
**Post date:** [November 16, 2023, 4:05pm UTC](https://forums.rockylinux.org/t/running-a-user-level-services-in-rocky-9/11880/1 "2023-11-16T16:05:08Z")

</div>

I could not find any documentation on correct setting systemctl --user in a non-desktop setup of rocky linux 9

I’m trying to run test services under a non-priveleged user (gitlab-runner). Unfortunately I have no idea of the correct way to do so.

```auto
sh-5.1$ systemctl --user
Failed to connect to bus: No medium found

```

I’ve checked the dbus launched, and here it is. however it is running under a special “dbus” user, and not my own (ssm-user, or gitlab-runner user)

```auto
sh-5.1$ ps aux | grep dbus
dbus 772 0.0 0.0 10808 4536 ? Ss Nov12 0:00 /usr/bin/dbus-broker-launch --scope system --audit
dbus 778 0.0 0.0 5132 2832 ? S Nov12 0:00 dbus-broker --log 4 --controller 9 --machine-id ec2a795dd342a229ae604c7a0c9b1237 --max-bytes 536870912 --max-fds 4096 --max-matches 131072 --audit

```

I’ve checked the dbus.service, and looks like it is in place

```auto
sh-5.1$ cat /etc/systemd/user/dbus.service
[Unit]
Description=D-Bus User Message Bus
Documentation=man:dbus-broker-launch(1)
DefaultDependencies=false
Before=basic.target shutdown.target
Requires=dbus.socket
Conflicts=shutdown.target

[Service]
Type=notify
Sockets=dbus.socket
ExecStart=/usr/bin/dbus-broker-launch --scope user
ExecReload=/usr/bin/busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus ReloadConfig

[Install]
Alias=dbus.service

```

so, how could I launch it for a user? What is the expected flow?

---

<div class="post-metadata">

**Author:** ![Ritov](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@Ritov](https://forums.rockylinux.org/u/Ritov)\
**Post date:** [November 16, 2023, 8:29pm UTC](https://forums.rockylinux.org/t/running-a-user-level-services-in-rocky-9/11880/2 "2023-11-16T20:29:04Z")

</div>

```auto
# loginctl enable-linger `id -u yourUserName`

```

and

`reboot`

---

<div class="post-metadata">

**Author:** ![ariksu](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@ariksu](https://forums.rockylinux.org/u/ariksu)\
**Post date:** [November 17, 2023, 12:44pm UTC](https://forums.rockylinux.org/t/running-a-user-level-services-in-rocky-9/11880/3 "2023-11-17T12:44:28Z")

</div>

@Ritov  
I’ve enalbed the lingering and rebooted. Nothing have changed, unfortunately.

Validated with below after reboot

```auto
 loginctl show-user ssm-user -p Linger
Linger=yes

```

Is there any documentation on dbus (or dbus-broker) debugging? I am trying to find any logs, but don’t understand where it could go.

---

<div class="post-metadata">

**Author:** ![ariksu](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@ariksu](https://forums.rockylinux.org/u/ariksu)\
**Post date:** [November 17, 2023, 2:00pm UTC](https://forums.rockylinux.org/t/running-a-user-level-services-in-rocky-9/11880/4 "2023-11-17T14:00:55Z")

</div>

Problem solved, thank you @Ritov .

(Feeling a great temptation skip problem solution and root cause description but i am not such an evil person).

Beside lingering another item is required: user must be logged in through logind. This could be checked by typing

```auto
$ whoami
test
$ loginctl list-sessions
SESSION UID USER SEAT TTY
    c15 1009 test pts/0

1 sessions listed.

```

but in my case i was seeing the following behavior

```auto
sh-5.1$ whoami
ssm-user
sh-5.1$ loginctl list-sessions
No sessions.
sh-5.1$ sudo su gitlab-runner
bash-5.1$ whoami
gitlab-runner
bash-5.1$ loginctl list-sessions
SESSION UID USER SEAT TTY
    c16 0 root pts/0

1 sessions listed.

```

So basically, ssm console which is using ssm user does not using logind to log on. And switching user through sudo su creates a session for a root, not for a user you’re switching to.

TLDR:  
To run user services you need

1. enable lingering via

```auto
loginctl enable-linger username

```

1. 

log as user either via

```auto
su username

```

or via normal ssh.

Running “sudo su username” will create dbus for root and will block you from running systemctl --user!!!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/1X/91b7219eec10e30013422e4df76c1d898711a5d5.svg) [@system](https://forums.rockylinux.org/u/system)\
**Post date:** [January 16, 2024, 2:01pm UTC](https://forums.rockylinux.org/t/running-a-user-level-services-in-rocky-9/11880/5 "2024-01-16T14:01:33Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
