I would like to create a scripted install for a list of Systemd services. This installation should support both Ubuntu (starting with version 16.04) and RHEL/CentOS (starting with version 7.2)

I read RHEL docs and found three paths that I could store unit files in, these paths are:

  • /usr/lib/systemd/system/
  • /lib/systemd/system/
  • /etc/systemd/system

What is the correct location for services that fulfills these criteria:

  • Unit files are there for non-system level services (application specific services)
  • No already existing OS level services are overwritten
  • The location is identical on Ubuntu and RHEL/CentOS
  • /etc/systemd/system is the one, since /usr/lib/systemd/system is for units of installed packages.
    – hchandad
    Sep 14, 2018 at 19:59

1 Answer 1


In default Red Hat distributions, /lib is a symlink to /usr/lib, but it appears those are different locations in Ubuntu.

According to the systemd documentation, /usr/lib/systemd/system/ is designated to hold upstream unit files that would not be edited by users and instead be provided and updated via packages.

The /etc/systemd/system is designated as where user provided unit files would be. Packages should not override or update anything in /etc/systemd/system. You can also use /etc/systemd/system to override existing unit files.

So using /etc/systemd/system should be the most compatible between different distributions.

You must log in to answer this question.

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