systemctl --user enable?

607 views
Skip to first unread message

Niels Kobschaetzki

unread,
Jun 4, 2016, 7:48:04 AM6/4/16
to qubes...@googlegroups.com
Hi,

from my old linux-installation I have several systemd-services and
-timers that I used only with --user and which are located in
~/.config/systemd/system

I can start them with systemctl --user start foo.service (or foo.timer)

But systemctl --user enable foo.service gives me only the following
error: Failed to execute operation: No such file or directory

What am I doing wrong?

Niels
signature.asc

Patrick Schleizer

unread,
Jun 4, 2016, 9:17:08 AM6/4/16
to qubes...@googlegroups.com
Using Debian templates? Then I don't think anyone on the internet
explained yet how to do that or there might be a bug in Debian. Bug report:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820111

Cheers,
Patrick

Niels Kobschaetzki

unread,
Jun 4, 2016, 10:21:12 AM6/4/16
to Patrick Schleizer, qubes...@googlegroups.com
no, I tried it in an AppVM which is based on a Fedora 23-template (and I
used those services in the past in Fedora- and Arch-installs)

Niels
signature.asc

Niels Kobschaetzki

unread,
Jun 4, 2016, 2:57:01 PM6/4/16
to Patrick Schleizer, qubes...@googlegroups.com
Symlinking by hand the timers into
~/.config/systemd/system/default.target.wants starts the timers on boot
up. Thus I have a workaround. But why enable does not work in the first
place, I do not really understand :/

Niels
signature.asc

Marek Marczykowski-Górecki

unread,
Jun 4, 2016, 3:55:24 PM6/4/16
to Niels Kobschaetzki, qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Sat, Jun 04, 2016 at 11:31:25AM +0200, Niels Kobschaetzki wrote:
> Hi,
>
> from my old linux-installation I have several systemd-services and
> -timers that I used only with --user and which are located in
> ~/.config/systemd/system

It should be ~/.config/systemd/user

> I can start them with systemctl --user start foo.service (or foo.timer)
>
> But systemctl --user enable foo.service gives me only the following
> error: Failed to execute operation: No such file or directory
>
> What am I doing wrong?
>
> Niels
>



- --
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJXUzIlAAoJENuP0xzK19csF5kH/3QzgNghCQZMXCW22A208uQk
c4wiPR6xRzW+XLwufZ8wB8IjZFyDuN5g6bXYFbGZInZBCOR5zttI1kLgjjZk+o16
sF8HW5iR50ZXFO5C81BcfcE34UKjTH29KoHj6ED0G0iapdpFudcoru4ypjR6TAWw
v/hBb9DShUWAoan4+Op9H43bc478qzfMN4f/Avb/ZXX446b6lUv1Jn3BhM9/mNPQ
MQ/k8eTJl3ZDkoeOXPuR1+7WAxw9U9cV4QOz7wow6NywbN6FI4ubdWZFa4B6Xdg2
P1idCxzJOWqHvwfsauR3cWBc3eU7Gv7CyOCJV+LCnVoed5PuFMF5Y2BmY62wixQ=
=+7GX
-----END PGP SIGNATURE-----

Unman

unread,
Jun 4, 2016, 11:14:20 PM6/4/16
to Patrick Schleizer, qubes...@googlegroups.com
This works for me:

loginctrl enable-linger user

Drop the service file in .config/systemd/user

systemctl --user enable foo
`
In your service file in the [Install] section:
WantedBy=default.target works fine.

See if that works for you.

unman

Niels Kobschaetzki

unread,
Jun 5, 2016, 12:07:47 AM6/5/16
to Marek Marczykowski-Górecki, qubes...@googlegroups.com
On 16/06/04 21:55, Marek Marczykowski-Górecki wrote:
>On Sat, Jun 04, 2016 at 11:31:25AM +0200, Niels Kobschaetzki wrote:
>> Hi,
>>
>> from my old linux-installation I have several systemd-services and
>> -timers that I used only with --user and which are located in
>> ~/.config/systemd/system
>
>It should be ~/.config/systemd/user

Sorry, that was a typo. It is ~/.config/systemd/user

Niels Kobschaetzki

unread,
Jun 5, 2016, 12:25:34 AM6/5/16
to Unman, Patrick Schleizer, qubes...@googlegroups.com
Thanks but unfortunately that didn't work, too

Niels

Rusty Bird

unread,
Jun 5, 2016, 4:50:30 AM6/5/16
to qubes-users, Niels Kobschaetzki
Hi Niels,

> But systemctl --user enable foo.service gives me only the following
> error: Failed to execute operation: No such file or directory

strace should be able to tell you what's going on, e.g. to attach to PID
1 (systemd):

sudo qubes-dom0-update strace
sudo strace -p 1 2>&1 | grep 'No such file or directory'

Then run the failing systemctl command in another terminal.

Rusty

signature.asc

Rusty Bird

unread,
Jun 5, 2016, 5:03:38 AM6/5/16
to qubes-users, Niels Kobschaetzki
Rusty Bird:
Sorry -- not "-p 1" in this case but whatever your "systemd --user" PID
is, see: ps -fwwC systemd

Rusty

signature.asc

Patrick Schleizer

unread,
Jun 5, 2016, 11:36:27 AM6/5/16
to Unman, qubes...@googlegroups.com
Unman:
> On Sat, Jun 04, 2016 at 01:17:03PM +0000, Patrick Schleizer wrote:
>> Using Debian templates? Then I don't think anyone on the internet
>> explained yet how to do that or there might be a bug in Debian. Bug report:
>>
>> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820111
>>
>> Cheers,
>> Patrick
>>
> This works for me:
>
> loginctrl enable-linger user

I guess you mean loginctl not loginctrl.

What this command does is apparently doing is creating an empty file:
/var/lib/systemd/linger/user

This is not great in context of Qubes, since that file is in /var and
not persistent by default in TemplateBasedVMs.

Do you think this can be configured using a proper config file also?

Apart from this, thanks a lot, it works for me also!

Cheers,
Patrick

Unman

unread,
Jun 6, 2016, 9:32:35 PM6/6/16
to Patrick Schleizer, qubes...@googlegroups.com
You'll find that the service will start automatically without linger on
a qube boot.
You can make it start just a little earlier by writing the linger file
from rc.local.

So in rc.local
mkdir -p /var/lib/systemd/linger
touch /var/lib/systemd/linger/user

With a simple logging service, and comparing against journalctl output
it looks as if the service starts just a little earlier:

Jun 07 02:04:46 tester dbus[459]: [system] Successfully activated service 'org.freedesktop.systemd1'
Jun 07 02:04:46 tester systemd[1]: Started Avahi mDNS/DNS-SD Stack.
Jun 07 02:04:46 tester systemd[1]: Started WPA supplicant.
Jun 07 02:04:46 tester systemd[1]: Started Make remote CUPS printers available locally.
Jun 07 02:04:46 tester systemd[1]: Starting IIO Sensor Proxy service...
Jun 07 02:04:46 tester systemd[1]: Starting Network Service...
Jun 07 02:04:46 tester systemd[1]: Starting Qubes remote exec agent...
Jun 07 02:04:46 tester systemd[1]: Started System Logging Service.
Jun 07 02:04:46 tester systemd[1]: Started Provide limited super user privileges to specific users.
Jun 07 02:04:46 tester systemd[1]: Started Qubes memory information reporter.
Jun 07 02:04:46 tester systemd[1]: Started Restore /etc/resolv.conf if the system crashed before the ppp link was shut down.
Jun 07 02:04:46 tester systemd[1]: Started Qubes base firewall settings.
Jun 07 02:04:46 tester systemd[1]: Started LSB: Start/stop xen driver domain daemon.
Jun 07 02:04:46 tester systemd[1]: Started Qubes remote exec agent.
Jun 07 02:04:46 tester systemd[1]: Started IIO Sensor Proxy service.
Jun 07 02:04:46 tester systemd-logind[451]: New seat seat0.
Jun 07 02:04:46 tester systemd-networkd[492]: Enumeration completed
Jun 07 02:04:46 tester systemd[1]: Starting Daily apt activities...
Jun 07 02:04:46 tester systemd[1]: Started Network Service.
Jun 07 02:04:46 tester systemd[1]: Started Login Service.
Jun 07 02:04:46 tester systemd[1]: Reached target Network.
Jun 07 02:04:46 tester systemd[1]: Starting Permit User Sessions...
Jun 07 02:04:46 tester systemd[1]: Starting Network Name Resolution...
Jun 07 02:04:46 tester systemd[1]: Started Permit User Sessions. ***STARTS HERE WITH LINGER????***
Jun 07 02:04:46 tester systemd-resolved[504]: Positive Trust Anchors:
Jun 07 02:04:46 tester systemd-resolved[504]: . IN DS 19036 8 2 49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5
Jun 07 02:04:46 tester systemd-resolved[504]: Negative trust anchors: 10.in-addr.arpa 16.172.in-addr.arpa 17.172.in-addr.arpa 18.172.in-addr.a
Jun 07 02:04:46 tester systemd-resolved[504]: Using system hostname 'tester'.
Jun 07 02:04:46 tester systemd-resolved[504]: Switching to system DNS server 10.137.3.1.
Jun 07 02:04:46 tester systemd[1]: Started Network Name Resolution.
Jun 07 02:04:46 tester mount-dirs.sh[436]: tune2fs 1.43 (17-May-2016)
Jun 07 02:04:46 tester mount-dirs.sh[436]: Setting reserved blocks percentage to 0% (0 blocks)
Jun 07 02:04:46 tester kernel: EXT4-fs (xvdb): mounted filesystem with ordered data mode. Opts: discard
Jun 07 02:04:46 tester systemd[1]: Started Initialize and mount /rw and /home.
Jun 07 02:04:46 tester systemd[1]: Starting Qubes GUI Agent...
Jun 07 02:04:46 tester systemd[1]: Starting Qubes misc post-boot actions...
Jun 07 02:04:46 tester systemd[1]: Started Qubes GUI Agent.
Jun 07 02:04:46 tester qubes-gui[554]: Waiting on /var/run/xf86-qubes-socket socket...
Jun 07 02:04:47 tester su[563]: Successful su for user by root ***STARTS HERE WITHOUT LINGER***
Jun 07 02:04:47 tester su[563]: + ??? root:user
Jun 07 02:04:47 tester su[563]: pam_unix(su:session): session opened for user user by (uid=0)


I havent compared this against a vanilla Debian system, but I wouldnt
have thought there would be much difference.

unman

Unman

unread,
Jun 6, 2016, 9:50:19 PM6/6/16
to Niels Kobschaetzki, Marek Marczykowski-Górecki, qubes...@googlegroups.com
Have you copied the files in place or linked them? (linked files may
throw this error on enable but will start)

Did you try strace? With what result?

If you post an example we could try to duplicate the error.

unman

Unman

unread,
Jun 7, 2016, 5:35:08 PM6/7/16
to Patrick Schleizer, qubes...@googlegroups.com
Ignore this absolute pile of stupidity.

Touching the file from rc.local may create it, but it wont make any
difference to the timing - how can it possibly start a service in
/home/user/.config before /home is mounted?

So the service *is* started automatically, but the linger makes no
difference, I'm pretty sure.

Patrick Schleizer

unread,
Jun 16, 2016, 9:01:32 AM6/16/16
to qubes...@googlegroups.com
Unman:
> On Sat, Jun 04, 2016 at 01:17:03PM +0000, Patrick Schleizer wrote:
>> Using Debian templates? Then I don't think anyone on the internet
>> explained yet how to do that or there might be a bug in Debian. Bug report:
>>
>> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820111
>>
>> Cheers,
>> Patrick
>>
> This works for me:
>
> loginctrl enable-linger user

This is a problem. Why is it required to enable systemd lingering?

Lingering should only be required if a user wishes to run systemd user
services even if not logged in.

> Drop the service file in .config/systemd/user
>
> systemctl --user enable foo

Now I am getting...

Failed to execute operation: Process org.freedesktop.systemd1 exited
with status 1

Any idea?

Patrick Schleizer

unread,
Jun 16, 2016, 9:14:08 AM6/16/16
to qubes...@googlegroups.com
Patrick Schleizer:
> Unman:
>> On Sat, Jun 04, 2016 at 01:17:03PM +0000, Patrick Schleizer wrote:
>>> Using Debian templates? Then I don't think anyone on the internet
>>> explained yet how to do that or there might be a bug in Debian. Bug report:
>>>
>>> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820111
>>>
>>> Cheers,
>>> Patrick
>>>
>> This works for me:
>>
>> loginctrl enable-linger user
>
> This is a problem. Why is it required to enable systemd lingering?
>
> Lingering should only be required if a user wishes to run systemd user
> services even if not logged in.
>
>> Drop the service file in .config/systemd/user
>>
>> systemctl --user enable foo
>
> Now I am getting...
>
> Failed to execute operation: Process org.freedesktop.systemd1 exited
> with status 1
>
> Any idea?

I was able to resolve this by installing systemd 230-2 from Debian
stretch, which is not a great solution.

(And no solution to what I am actually working on.
https://phabricator.whonix.org/T424
Mixing jessie packages with stretch can lead to other unrelated issues.)

Patrick Schleizer

unread,
Jun 16, 2016, 9:16:38 AM6/16/16
to qubes...@googlegroups.com
Patrick Schleizer:
> Patrick Schleizer:
>> Unman:
>>> On Sat, Jun 04, 2016 at 01:17:03PM +0000, Patrick Schleizer wrote:
>>>> Using Debian templates? Then I don't think anyone on the internet
>>>> explained yet how to do that or there might be a bug in Debian. Bug report:
>>>>
>>>> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820111
>>>>
>>>> Cheers,
>>>> Patrick
>>>>
>>> This works for me:
>>>
>>> loginctrl enable-linger user
>>
>> This is a problem. Why is it required to enable systemd lingering?
>>
>> Lingering should only be required if a user wishes to run systemd user
>> services even if not logged in.

With systemd 230-2 from Debian stretch also lingering is no longer required.

Unman

unread,
Jun 16, 2016, 9:42:53 PM6/16/16
to Patrick Schleizer, qubes...@googlegroups.com
Patrick

I don't think this is a problem in context of Qubes. Why would it be?

Anyway, all I was doing was providing an explanation of how it could
work on a Debian template, which you said no one had done.

That error message I have seen before, and it's generally been
associated with getting the requirements/Wanted incorrect.

unman
Reply all
Reply to author
Forward
0 new messages