3 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
6 <refentry id=
"systemd.preset">
9 <title>systemd.preset
</title>
10 <productname>systemd
</productname>
14 <refentrytitle>systemd.preset
</refentrytitle>
15 <manvolnum>5</manvolnum>
19 <refname>systemd.preset
</refname>
20 <refpurpose>Service enablement presets
</refpurpose>
24 <para><filename>/etc/systemd/system-preset/*.preset
</filename></para>
25 <para><filename>/run/systemd/system-preset/*.preset
</filename></para>
26 <para><filename>/usr/lib/systemd/system-preset/*.preset
</filename></para>
27 <para><filename>/etc/systemd/user-preset/*.preset
</filename></para>
28 <para><filename>/run/systemd/user-preset/*.preset
</filename></para>
29 <para><filename>/usr/lib/systemd/user-preset/*.preset
</filename></para>
33 <title>Description
</title>
35 <para>Preset files may be used to encode policy which units shall
36 be enabled by default and which ones shall be disabled. They are
37 read by
<command>systemctl preset
</command> (for more information
39 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
40 which uses this information to enable or disable a unit according
41 to preset policy.
<command>systemctl preset
</command> is used by
42 the post install scriptlets of RPM packages (or other OS package
43 formats), to enable/disable specific units by default on package
44 installation, enforcing distribution, spin or administrator preset
45 policy. This allows choosing a certain set of units to be
46 enabled/disabled even before installing the actual package.
</para>
48 <para>For more information on the preset logic please have a look
50 url=
"https://www.freedesktop.org/wiki/Software/systemd/Preset">Presets
</ulink>
53 <para>It is not recommended to ship preset files within the
54 respective software packages implementing the units, but rather
55 centralize them in a distribution or spin default policy, which
56 can be amended by administrator policy.
</para>
58 <para>If no preset files exist,
<command>systemctl
59 preset
</command> will enable all units that are installed by
60 default. If this is not desired and all units shall rather be
61 disabled, it is necessary to ship a preset file with a single,
62 catchall
"<filename>disable *</filename>" line. (See example
1,
67 <title>Preset File Format
</title>
69 <para>The preset files contain a list of directives consisting of
70 either the word
<literal>enable
</literal> or
71 <literal>disable
</literal> followed by a space and a unit name
72 (possibly with shell style wildcards), separated by newlines.
73 Empty lines and lines whose first non-whitespace character is # or
76 <para>Presets must refer to the
"real" unit file, and not to any aliases. See
77 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
78 for a description of unit aliasing.
</para>
80 <para>Two different directives are understood:
81 <literal>enable
</literal> may be used to enable units by default,
82 <literal>disable
</literal> to disable units by default.
</para>
84 <para>If multiple lines apply to a unit name, the first matching
85 one takes precedence over all others.
</para>
87 <para>Each preset file shall be named in the style of
88 <filename><priority
>-
<policy-name
>.preset
</filename>. Files
89 in
<filename>/etc/
</filename> override files with the same name in
90 <filename>/usr/lib/
</filename> and
<filename>/run/
</filename>.
91 Files in
<filename>/run/
</filename> override files with the same
92 name in
<filename>/usr/lib/
</filename>. Packages should install
93 their preset files in
<filename>/usr/lib/
</filename>. Files in
94 <filename>/etc/
</filename> are reserved for the local
95 administrator, who may use this logic to override the preset files
96 installed by vendor packages. All preset files are sorted by their
97 filename in lexicographic order, regardless of which of the
98 directories they reside in. If multiple files specify the same
99 unit name, the entry in the file with the lexicographically
100 earliest name will be applied. It is recommended to prefix all
101 filenames with a two-digit number and a dash, to simplify the
102 ordering of the files.
</para>
104 <para>If the administrator wants to disable a preset file supplied
105 by the vendor, the recommended way is to place a symlink to
106 <filename>/dev/null
</filename> in
107 <filename>/etc/systemd/system-preset/
</filename> bearing the same
112 <title>Examples
</title>
115 <title>Default to off
</title>
117 <programlisting># /usr/lib/systemd/system-preset/
99-default.preset
119 disable *
</programlisting>
122 <para>This disables all units. Due to the filename prefix
123 <literal>99-
</literal>, it will be read last and hence can easily
124 be overridden by spin or administrator preset policy.
</para>
127 <title>A GNOME spin
</title>
129 <programlisting># /usr/lib/systemd/system-preset/
50-gnome.preset
132 enable colord.service
133 enable accounts-daemon.service
134 enable avahi-daemon.*
</programlisting>
138 <para>This enables the three mentioned units, plus all
139 <filename>avahi-daemon
</filename> regardless of which unit type. A
140 file like this could be useful for inclusion in a GNOME spin of a
141 distribution. It will ensure that the units necessary for GNOME
142 are properly enabled as they are installed. It leaves all other
143 units untouched, and subject to other (later) preset files, for
144 example like the one from the first example above.
</para>
147 <title>Administrator policy
</title>
149 <programlisting># /etc/systemd/system-preset/
00-lennart.preset
153 enable postfix.service
154 disable *
</programlisting>
157 <para>This enables three specific services and disables all
158 others. This is useful for administrators to specifically select
159 the units to enable, and disable all others. Due to the filename
160 prefix
<literal>00-
</literal> it will be read early and
161 override all other preset policy files.
</para>
165 <title>See Also
</title>
167 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
168 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
169 <citerefentry><refentrytitle>systemd-delta
</refentrytitle><manvolnum>1</manvolnum></citerefentry>