0

I'm in the process of building bash-script based installer that needs to set up a systemd unit among other things. I could hard-code the typical systemd unit file locations like /etc/systemd/system or /usr/lib/systemd/system but I'd like to be able to have the script be able to detect the system's preferred location for adding a new unit file and service.

I could certainly do this by using find and looking for existing service unit files, but I wanted to avoid adding too much complexity if there's already an existing global variable (like $HOME) I could call on

1 Answer 1

0

As far as I'm aware, all systems are the same. The manpage offers a number of insights - https://www.freedesktop.org/software/systemd/man/systemd.unit.html

System Unit Search Path

/etc/systemd/system.control/*
/run/systemd/system.control/*
/run/systemd/transient/*
/run/systemd/generator.early/*
/etc/systemd/system/*
/etc/systemd/system.attached/*
/run/systemd/system/*
/run/systemd/system.attached/*
/run/systemd/generator/*
…
/usr/lib/systemd/system/*
/run/systemd/generator.late/*

If you are building the service unit file then you should probably install the files in /etc/systemd/system, which has the description "System units created by the administrator".

There are a couple places in the code that make it seem very unlikely most of these paths could be changed, and that /etc/systemd/system appears hard coded

1
  • Ah good to know that /etc/systemd/system is hardcoded for everything. That'll be good enough for my purposes
    – pyr0ball
    Commented Mar 25, 2022 at 17:43

You must log in to answer this question.

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