]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.preset.xml
man: use <simplelist> for 'See also' sections
[thirdparty/systemd.git] / man / systemd.preset.xml
CommitLineData
75d67e68
LP
1<?xml version="1.0"?>
2<!--*-nxml-*-->
3a54a157
ZJS
3<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
db9ecf05 5<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
75d67e68
LP
6<refentry id="systemd.preset">
7
798d3a52
ZJS
8 <refentryinfo>
9 <title>systemd.preset</title>
10 <productname>systemd</productname>
798d3a52
ZJS
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>systemd.preset</refentrytitle>
15 <manvolnum>5</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>systemd.preset</refname>
20 <refpurpose>Service enablement presets</refpurpose>
21 </refnamediv>
22
23 <refsynopsisdiv>
73e97bb0
ZJS
24 <para><simplelist>
25 <member><filename>/etc/systemd/system-preset/*.preset</filename></member>
26 <member><filename>/run/systemd/system-preset/*.preset</filename></member>
27 <member><filename>/usr/lib/systemd/system-preset/*.preset</filename></member>
28 <member><filename>/etc/systemd/user-preset/*.preset</filename></member>
29 <member><filename>/run/systemd/user-preset/*.preset</filename></member>
30 <member><filename>/usr/lib/systemd/user-preset/*.preset</filename></member>
31 </simplelist></para>
798d3a52
ZJS
32 </refsynopsisdiv>
33
34 <refsect1>
35 <title>Description</title>
36
7e215af7
ZJS
37 <para>Preset files may be used to encode policy which units shall be enabled by default and which ones
38 shall be disabled. They are read by <command>systemctl preset</command> which uses this information to
39 enable or disable a unit. Depending on that policy, <command>systemctl preset</command> is identical to
40 <command>systemctl enable</command> or <command>systemctl disable</command>.
41
42 <command>systemctl preset</command> is used by the post install scriptlets of rpm packages (or other OS
43 package formats), to enable/disable specific units by default on package installation, enforcing
44 distribution, spin or administrator preset policy. This allows choosing a certain set of units to be
45 enabled/disabled even before installing the actual package. For more information, see
46 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
47
48 <para>It is not recommended to ship preset files within the respective software packages implementing the
49 units, but rather centralize them in a distribution or spin default policy, which can be amended by
50 administrator policy, see below.</para>
798d3a52 51
bfa769d1
ZJS
52 <para>If no preset files exist, preset operations will enable all units that are installed by default. If
53 this is not desired and all units shall rather be disabled, it is necessary to ship a preset file with a
54 single, catchall "<filename>disable *</filename>" line. (See example 1, below.)</para>
55
56 <para>When the machine is booted for the first time,
57 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> will
58 enable/disable all units according to preset policy, similarly to <command>systemctl
59 preset-all</command>. Also see "First Boot Semantics" in
60 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
61 </para>
798d3a52
ZJS
62 </refsect1>
63
64 <refsect1>
65 <title>Preset File Format</title>
66
e77e07f6
DDM
67 <para>The preset files contain a list of directives, one per line. Empty lines and lines whose first
68 non-whitespace character is <literal>#</literal> or <literal>;</literal> are ignored. Each directive
69 consists of one of the words <literal>enable</literal>, <literal>disable</literal>, or
70 <literal>ignore</literal>, followed by whitespace and a unit name. The unit name may contain shell-style
71 wildcards.</para>
72
73 <para>For the enable directive for template units, one or more instance names may be specified as a
74 space-separated list after the unit name. In this case, those instances will be enabled instead of the
75 instance specified via DefaultInstance= in the unit.</para>
798d3a52 76
d923e42e
ZJS
77 <para>Presets must refer to the "real" unit file, and not to any aliases. See
78 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
79 for a description of unit aliasing.</para>
80
e77e07f6
DDM
81 <para>Three different directives are understood: <literal>enable</literal> may be used to enable units by
82 default, <literal>disable</literal> to disable units by default, and <literal>ignore</literal> to ignore
83 units and leave existing configuration intact.</para>
798d3a52
ZJS
84
85 <para>If multiple lines apply to a unit name, the first matching
86 one takes precedence over all others.</para>
87
88 <para>Each preset file shall be named in the style of
9e0d90f9 89 <filename>&lt;priority&gt;-&lt;policy-name&gt;.preset</filename>. Files
798d3a52
ZJS
90 in <filename>/etc/</filename> override files with the same name in
91 <filename>/usr/lib/</filename> and <filename>/run/</filename>.
92 Files in <filename>/run/</filename> override files with the same
93 name in <filename>/usr/lib/</filename>. Packages should install
94 their preset files in <filename>/usr/lib/</filename>. Files in
95 <filename>/etc/</filename> are reserved for the local
96 administrator, who may use this logic to override the preset files
97 installed by vendor packages. All preset files are sorted by their
98 filename in lexicographic order, regardless of which of the
99 directories they reside in. If multiple files specify the same
100 unit name, the entry in the file with the lexicographically
101 earliest name will be applied. It is recommended to prefix all
102 filenames with a two-digit number and a dash, to simplify the
103 ordering of the files.</para>
104
105 <para>If the administrator wants to disable a preset file supplied
106 by the vendor, the recommended way is to place a symlink to
107 <filename>/dev/null</filename> in
12b42c76 108 <filename>/etc/systemd/system-preset/</filename> bearing the same
798d3a52
ZJS
109 filename.</para>
110 </refsect1>
111
112 <refsect1>
1655cdee 113 <title>Examples</title>
798d3a52
ZJS
114
115 <example>
1655cdee 116 <title>Default to off</title>
798d3a52 117
1655cdee
ZJS
118 <programlisting># /usr/lib/systemd/system-preset/99-default.preset
119
120disable *</programlisting>
798d3a52
ZJS
121 </example>
122
123 <para>This disables all units. Due to the filename prefix
124 <literal>99-</literal>, it will be read last and hence can easily
1655cdee 125 be overridden by spin or administrator preset policy.</para>
798d3a52 126
1f667d8a
JB
127 <example>
128 <title>Enable multiple template instances</title>
129
130 <programlisting># /usr/lib/systemd/system-preset/80-dirsrv.preset
131
132enable dirsrv@.service foo bar baz</programlisting>
133 </example>
134
135 <para>This enables all three of <filename>dirsrv@foo.service</filename>,
136 <filename>dirsrv@bar.service</filename> and <filename>dirsrv@baz.service</filename>.</para>
137
798d3a52 138 <example>
1655cdee 139 <title>A GNOME spin</title>
798d3a52 140
1655cdee
ZJS
141 <programlisting># /usr/lib/systemd/system-preset/50-gnome.preset
142
143enable gdm.service
75d67e68
LP
144enable colord.service
145enable accounts-daemon.service
146enable avahi-daemon.*</programlisting>
147
798d3a52 148 </example>
75d67e68 149
798d3a52
ZJS
150 <para>This enables the three mentioned units, plus all
151 <filename>avahi-daemon</filename> regardless of which unit type. A
152 file like this could be useful for inclusion in a GNOME spin of a
153 distribution. It will ensure that the units necessary for GNOME
154 are properly enabled as they are installed. It leaves all other
155 units untouched, and subject to other (later) preset files, for
156 example like the one from the first example above.</para>
75d67e68 157
798d3a52 158 <example>
1655cdee
ZJS
159 <title>Administrator policy</title>
160
161 <programlisting># /etc/systemd/system-preset/00-lennart.preset
75d67e68 162
1655cdee 163enable httpd.service
75d67e68
LP
164enable sshd.service
165enable postfix.service
166disable *</programlisting>
798d3a52
ZJS
167 </example>
168
169 <para>This enables three specific services and disables all
170 others. This is useful for administrators to specifically select
171 the units to enable, and disable all others. Due to the filename
1655cdee
ZJS
172 prefix <literal>00-</literal> it will be read early and
173 override all other preset policy files.</para>
798d3a52
ZJS
174 </refsect1>
175
7e215af7 176 <refsect1>
7bac23e8 177 <title>Motivation for the preset logic</title>
7e215af7
ZJS
178
179 <para>Different distributions have different policies on which services shall be enabled by default when
180 the package they are shipped in is installed. On Fedora all services stay off by default, so that
181 installing a package will not cause a service to be enabled (with some exceptions). On Debian all
182 services are immediately enabled by default, so that installing a package will cause its services to be
183 enabled right-away.</para>
184
185 <para>Even within a single distribution, different spins (flavours, remixes, whatever you might want to
186 call them) of a distribution also have different policies on what services to enable, and what services
187 to leave off. For example, Fedora Workstation will enable <command>gdm</command> as display manager by
188 default, while the Fedora KDE spin will enable <command>sddm</command> instead.</para>
189
190 <para>Different sites might also have different policies what to turn on by default and what to turn
191 off. For example, one administrator would prefer to enforce the policy of "<command>sshd</command> should
192 be always on, but everything else off", while another one might say "<command>snmpd</command> always on,
193 and for everything else use the distribution policy defaults".</para>
194
195 <para>Traditionally, policy about which services shall be enabled were implemented in each package
196 individually. This made it cumbersome to implement different policies per spin or per site, or to create
197 software packages that do the right thing on more than one distribution. The enablement mechanism was
198 also encoding the enablement policy.</para>
199
200 <para>The preset mechanism allows clean separation of the enablement mechanism (inside the package
201 scriptlets, by invoking <command>systemctl preset</command>) and enablement policy (centralized in the
202 preset files), and lifts the configuration out of individual packages. Preset files may be written for
203 specific distributions, for specific spins or for specific sites, in order to enforce different policies
204 as needed. It is recommended to apply the policy encoded in preset files in package installation
205 scriptlets.</para>
206 </refsect1>
207
798d3a52
ZJS
208 <refsect1>
209 <title>See Also</title>
13a69c12
DT
210 <para><simplelist type="inline">
211 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
212 <member><citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
213 <member><citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
214 </simplelist></para>
7e215af7 215
be0d27ee 216 <para><citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>
7e215af7
ZJS
217 has a discussion of packaging scriptlets.</para>
218
219 <para>Fedora page introducing the use of presets:
220 <ulink url="https://fedoraproject.org/wiki/Features/PackagePresets">Features/PackagePresets</ulink>.
221 </para>
798d3a52 222 </refsect1>
75d67e68
LP
223
224</refentry>