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