I'm trying to load a script on boot in Ubuntu Server 18.04. My .service script is installed in /etc/systemd/system, and I can service my-service start and service my-service stop but when I try to run at boot (which according to the web I should do) with service my-service enable the system responds with my-service: unrecognised service

Searching the web only tells me how to do it in older versions of Ubuntu which do not apply to 18.04 and I am unable to determine the correct terminology to find the answer.

the script:

# filename: /etc/systemd/system/my-service.service
Description=My Service



The question (obviously) is: What am I doing wrong? How can I start this service on boot?

Thanks in advance


  • 1
    Have you tried using the real command, systemctl enable my-service? – Cez Jun 12 '19 at 6:25
  • I think I must be dyslexic. I tried that command over an over again, because most articles refer to that. But reading my command history I used servicectl instead of systemctl. There's 3 days I'll never get back... THANKS. – Clearsite - Remon Pel Jun 12 '19 at 6:29
  • Great, I've added an answer with some extra info – Cez Jun 12 '19 at 6:42
  • I noticed, thank you! Question answered and improved upon :) – Clearsite - Remon Pel Jun 12 '19 at 6:54

Use the real command, which for systemd would be:

sudo systemctl enable my-service

For reference, you do not have to use the main system directory for the unit file if you want it to run for a normal user, e.g. your own. You can create it in a directory such as:


Then you can do:

systemctl --user enable my-service

This avoids the need for sudo

As you have noted in your comment, when running per-user instances of systemd the User directive should be absent

|improve this answer|||||
  • 1
    Wow. Thanks! Even better! But just a side note: when using the second option (avoiding sudo), the line "User=the-user" should be removed from the service file, to prevent "Failed to determine supplementary groups: Operation not permitted" error. – Clearsite - Remon Pel Jun 12 '19 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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