Common location for systemd unit files on Ubuntu and RHEL

17,940

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.

Share:
17,940

Related videos on Youtube

Marged
Author by

Marged

Updated on September 18, 2022

Comments

  • Marged
    Marged over 1 year

    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
    • hchandad
      hchandad over 5 years
      /etc/systemd/system is the one, since /usr/lib/systemd/system is for units of installed packages.