Systemd service files in non-default directory

9,934

Actually the real service files are in /lib/systemd/system. Symlinks to them are created in /etc/systemd/system when the services are enabled.

If you want to put your service files somewhere else, go ahead, but when you want to enable the service, you must specify the full path to the real service file so that systemd can make the symlink to /etc/systemd/system, eg:

sudo systemctl enable /path/to/my-service-file
Share:
9,934

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    The default directory of service files is: etc/systemd/system and while this works ok, I was wondering if it was possible to specify another directory where service files can be put. The reason I want this is because I'd like to keep the service files that belong to the software that I'm writing together.

    Do you know if this is possible?

    • Admin
      Admin about 7 years
      If this is for a package, the default directory is not /etc/systemd/system, but /lib/systemd/system. That said, why not put all your service files somewhere and create links to /lib/systemd/system?
  • John
    John over 4 years
    It's giving me Access denied even with sudo
  • John
    John over 4 years
    Nevermind, here's the solution superuser.com/questions/1125250/…
  • Zanna
    Zanna over 4 years
    @John thanks for investigating and providing that link!