According to https://www.freedesktop.org/software/systemd/man/systemd.unit.html, the default unit path is…

  • /etc/systemd/system: Local configuration
  • /run/systemd/system: Runtime units
  • /usr/lib/systemd/system: Units of installed packages

If I am writing a script to install software to a server, not using a package manager, none of these locations seems to be technically correct.

Since this is being set up by an installer script, /usr/lib/systemd/system directory seems more right than /etc/systemd/system, even though the Linux distro's package manager is not being used. Is that right?

I thought about trying to modify the SYSTEMD_UNIT_PATH to incude something like /opt/lib/systemd/system, but I'm pretty sure that is a bad idea.

  • /etc/systemd/system seems fine to me. It's the documented path for what you are looking for. What is your specific problem with it? – Michael Hampton Aug 14 '16 at 20:36
  • Clarifying the question. – Steve Jorgensen Aug 14 '16 at 22:31

I'm a little bit confused: why didn't you use systemctl? I suggest, that the pathes used are different in different distros, thus I would use that programm to be compatible across distros and to future modifications!

  • Ah. You mean using systemctl link <path>? I didn't know it existed until I read the docs for systemctl after reading your answer. I think this is the answer to my question, and I'll give it a try. – Steve Jorgensen Aug 14 '16 at 23:18
  • 1
    This isn't a complete answer. Can you improve your answer to suggest how you would actually use systemctl to install a unit file? For example, the man page does not make clear if link is a temporary solution or survives reboots. Moreover, simply trying to link a file, if you meant systemctl link just results in Failed to link unit: Invalid argument for me. – user3188445 Aug 30 '16 at 1:05

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.