1<?xml version="1.0"?>
2<!DOCTYPE refsection PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3          "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4
5<!--
6  SPDX-License-Identifier: LGPL-2.1-or-later
7  Copyright © 2014 Josh Triplett
8-->
9
10<refsection>
11  <refsection id='confd'>
12    <title>Configuration Directories and Precedence</title>
13
14    <para>Configuration files are read from directories in <filename>/etc/</filename>,
15    <filename>/run/</filename>, <filename>/usr/local/lib/</filename>, and <filename>/usr/lib/</filename>, in
16    order of precedence, as listed in the SYNOPSIS section above. Files must have the
17    <literal>.conf</literal> extension. Files in <filename>/etc/</filename> override files with the same name
18    in <filename>/run/</filename>, <filename>/usr/local/lib/</filename>, and
19    <filename>/usr/lib/</filename>. Files in <filename>/run/</filename> override files with the same name
20    under <filename>/usr/</filename>.</para>
21
22    <para>All configuration files are sorted by their filename in lexicographic order, regardless of which of
23    the directories they reside in. If multiple files specify the same option, the entry in the file with the
24    lexicographically latest name will take precedence. Thus, the configuration in a certain file may either
25    be replaced completely (by placing a file with the same name in a directory with higher priority), or
26    individual settings might be changed (by specifying additional settings in a file with a different name
27    that is ordered later).</para>
28
29    <para>Packages should install their configuration files in <filename>/usr/lib/</filename> (distribution
30    packages) or <filename>/usr/local/lib/</filename> (local installs). Files in <filename>/etc/</filename>
31    are reserved for the local administrator, who may use this logic to override the configuration files
32    installed by vendor packages. It is recommended to prefix all filenames with a two-digit number and a
33    dash, to simplify the ordering of the files.</para>
34
35    <para>If the administrator wants to disable a configuration file supplied by the vendor, the recommended
36    way is to place a symlink to <filename>/dev/null</filename> in the configuration directory in
37    <filename>/etc/</filename>, with the same filename as the vendor configuration file. If the vendor
38    configuration file is included in the initrd image, the image has to be regenerated.</para>
39  </refsection>
40
41  <refsection id='main-conf'>
42    <title>Configuration Directories and Precedence</title>
43
44    <para>The default configuration is set during compilation, so configuration is only needed when it is
45    necessary to deviate from those defaults. Initially, the main configuration file in
46    <filename>/etc/systemd/</filename> contains commented out entries showing the defaults as a guide to the
47    administrator. Local overrides can be created by editing this file or by creating drop-ins, as described
48    below. Using drop-ins for local configuration is recommended over modifications to the main configuration
49    file.</para>
50
51    <para>In addition to the "main" configuration file, drop-in configuration snippets are read from
52    <filename>/usr/lib/systemd/*.conf.d/</filename>, <filename>/usr/local/lib/systemd/*.conf.d/</filename>,
53    and <filename>/etc/systemd/*.conf.d/</filename>. Those drop-ins have higher precedence and override the
54    main configuration file. Files in the <filename>*.conf.d/</filename> configuration subdirectories are
55    sorted by their filename in lexicographic order, regardless of in which of the subdirectories they
56    reside. When multiple files specify the same option, for options which accept just a single value, the
57    entry in the file sorted last takes precedence, and for options which accept a list of values, entries
58    are collected as they occur in the sorted files.</para>
59
60    <para>When packages need to customize the configuration, they can install drop-ins under
61    <filename>/usr/</filename>. Files in <filename>/etc/</filename> are reserved for the local administrator,
62    who may use this logic to override the configuration files installed by vendor packages. Drop-ins have to
63    be used to override package drop-ins, since the main configuration file has lower precedence. It is
64    recommended to prefix all filenames in those subdirectories with a two-digit number and a dash, to
65    simplify the ordering of the files.</para>
66
67    <para>To disable a configuration file supplied by the vendor, the recommended way is to place a symlink
68    to <filename>/dev/null</filename> in the configuration directory in <filename>/etc/</filename>, with the
69    same filename as the vendor configuration file.</para>
70  </refsection>
71</refsection>
72