0

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.

3
  • /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? Aug 14, 2016 at 20:36
  • Clarifying the question. Aug 14, 2016 at 22:31
  • Actually I'd recommend learning how to build packages your package manager can deal with. It's much more convenient for maintenance.
    – U. Windl
    Jul 27, 2021 at 9:38

1 Answer 1

1

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!

2
  • 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. Aug 14, 2016 at 23:18
  • 3
    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. Aug 30, 2016 at 1:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .