7

I've created a .service file that includes User=xyz in the [Service] section. The service still runs as root. Quid?

[Unit]
Description=...
Requires=network-online.target

[Service]
ExecStart=/usr/bin/java ...
Type=simple
ExecStop=/usr/bin/java ...
User=siraprise

[Install]
WantedBy=multi-user.target
Gryu
  • 7,559
  • 9
  • 33
  • 52
  • Check this issue: https://askubuntu.com/questions/676007/how-do-i-make-my-systemd-service-run-via-specific-user-and-start-on-boot I was able to get an answer for a similar question here. – Matt K Dec 10 '20 at 19:07
  • Look man, the only thing that other issue tells me is that I can put User=xyz in the [Service] section of my .service file. Which, if you read my question (and I mean *attentively*) , is something I clearly already knew. – Erwin Smout Dec 24 '20 at 14:19

1 Answers1

8

Apparently the behaviour changes if User= is specified before ExecStart=.

Don't know whether that's a feature or an accident, but as a feature it's pretty dumb and moreover it seems undocumented which is actively annoying.