Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just finished the install and setup process of systemd on my arch-linux system (2012.09.07). I uninstalled initscripts (and removed the configuration files).

What I want to do is create a service that can be started and stopped by a non-root user. The service is to start a detached screen session running rtorrent. However I want every user on the system who has set this service to start (enabled) to have a particular instance started for them specifically. How would one go about doing this?

I remember reading that systemd supports user instances of services, however I have been unable to find any information on how to set this up, or whether it relates to what I am looking for.

Service file that I have used for system:


ExecStart=/usr/bin/screen -d -m -S rtorrent /usr/bin/rtorrent
ExecStop=/usr/bin/killall -w -s 2 /usr/bin/rtorrent


After reading through the man pages here and here, I understand how systemd works a bit better. Specifically that using the User= and WorkingDirectory= options allow for the service to be started in a user's session. However the issue still remains that the user themselves can not start, stop, enable, or disable the service. An Access is denied error is given by systemctl.


First off, for simplification and for better use of systemd's user session (still somewhat incomplete) feature, I used sofar's user-session-units and followed his config advice.

It seems that there is a bug in the current version of DBus (1.6.4-1) in which it does not set the environment variable DBUS_SESSION_BUS_ADDRESS meaning using the systemctl --user command errors out with:

Failed to get D-Bus connection: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

The variable should look like this:


where USERUID needs to be the UID of the given user.

share|improve this question
I realize that one could create a separate service file per user, and simply enable it. However I just want to know if it could be possible the way I have described it above. –  Hans Sep 17 '12 at 23:34
Fair enough, I could simple setup sudo for the users and have them, as mentioned in my comment above, control their own service file. However this solution would allow the user to control most other services as well... –  Hans Sep 19 '12 at 11:10
It wouldn't, if you had read sudo's documentation – sudoers(5) has many examples on restricting a command's arguments. –  grawity Sep 20 '12 at 12:23

1 Answer 1

up vote 11 down vote accepted

systemd normally does not allow ordinary users to start system services. While it does support giving access via polkit, that part is still somewhat lacking, and you cannot yet allow only one specific service.

Since rtorrent is not actually a system service, and because you want every user to have their own instance of rtorrent, experiment with systemd's "user" mode.

When you log in, the system will start a user@<uid>.service system unit for you, which will launch a separate "--user" instance of systemd. The new user-systemd will read unit files (starting with from ~/.config/systemd/user/, /etc/systemd/user/ and /usr/lib/systemd/user/.

share|improve this answer
Thanks grawity, that was basically what I was missing. However it also turns out to have been a DBus problem as well: there seems to be a bug in dbuse that doesn't set the correct global variable DBUS_SESSION_BUS_ADDRESS for a given user, so systemctl can't access the user session, it errors our. Once I figured out this small problem, everything else works beautifully! –  Hans Sep 25 '12 at 10:05
@Hans: Yes, there's a patch for that. –  grawity Sep 25 '12 at 12:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.