]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.preset.xml
sysusers: add support for a --image= switch
[thirdparty/systemd.git] / man / systemd.preset.xml
1 <?xml version="1.0"?>
2 <!--*-nxml-*-->
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">
7
8 <refentryinfo>
9 <title>systemd.preset</title>
10 <productname>systemd</productname>
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>
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>
30 </refsynopsisdiv>
31
32 <refsect1>
33 <title>Description</title>
34
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
38 see
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>
47
48 <para>For more information on the preset logic please have a look
49 at the <ulink
50 url="https://www.freedesktop.org/wiki/Software/systemd/Preset">Presets</ulink>
51 document.</para>
52
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>
57
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,
63 below.)</para>
64 </refsect1>
65
66 <refsect1>
67 <title>Preset File Format</title>
68
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 <literal>#</literal> or
74 <literal>;</literal> are ignored. Multiple instance names for unit
75 templates may be specified as a space separated list at the end of
76 the line instead of the customary position between <literal>@</literal>
77 and the unit suffix.</para>
78
79 <para>Presets must refer to the "real" unit file, and not to any aliases. See
80 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
81 for a description of unit aliasing.</para>
82
83 <para>Two different directives are understood:
84 <literal>enable</literal> may be used to enable units by default,
85 <literal>disable</literal> to disable units by default.</para>
86
87 <para>If multiple lines apply to a unit name, the first matching
88 one takes precedence over all others.</para>
89
90 <para>Each preset file shall be named in the style of
91 <filename>&lt;priority&gt;-&lt;policy-name&gt;.preset</filename>. Files
92 in <filename>/etc/</filename> override files with the same name in
93 <filename>/usr/lib/</filename> and <filename>/run/</filename>.
94 Files in <filename>/run/</filename> override files with the same
95 name in <filename>/usr/lib/</filename>. Packages should install
96 their preset files in <filename>/usr/lib/</filename>. Files in
97 <filename>/etc/</filename> are reserved for the local
98 administrator, who may use this logic to override the preset files
99 installed by vendor packages. All preset files are sorted by their
100 filename in lexicographic order, regardless of which of the
101 directories they reside in. If multiple files specify the same
102 unit name, the entry in the file with the lexicographically
103 earliest name will be applied. It is recommended to prefix all
104 filenames with a two-digit number and a dash, to simplify the
105 ordering of the files.</para>
106
107 <para>If the administrator wants to disable a preset file supplied
108 by the vendor, the recommended way is to place a symlink to
109 <filename>/dev/null</filename> in
110 <filename>/etc/systemd/system-preset/</filename> bearing the same
111 filename.</para>
112 </refsect1>
113
114 <refsect1>
115 <title>Examples</title>
116
117 <example>
118 <title>Default to off</title>
119
120 <programlisting># /usr/lib/systemd/system-preset/99-default.preset
121
122 disable *</programlisting>
123 </example>
124
125 <para>This disables all units. Due to the filename prefix
126 <literal>99-</literal>, it will be read last and hence can easily
127 be overridden by spin or administrator preset policy.</para>
128
129 <example>
130 <title>Enable multiple template instances</title>
131
132 <programlisting># /usr/lib/systemd/system-preset/80-dirsrv.preset
133
134 enable dirsrv@.service foo bar baz</programlisting>
135 </example>
136
137 <para>This enables all three of <filename>dirsrv@foo.service</filename>,
138 <filename>dirsrv@bar.service</filename> and <filename>dirsrv@baz.service</filename>.</para>
139
140 <example>
141 <title>A GNOME spin</title>
142
143 <programlisting># /usr/lib/systemd/system-preset/50-gnome.preset
144
145 enable gdm.service
146 enable colord.service
147 enable accounts-daemon.service
148 enable avahi-daemon.*</programlisting>
149
150 </example>
151
152 <para>This enables the three mentioned units, plus all
153 <filename>avahi-daemon</filename> regardless of which unit type. A
154 file like this could be useful for inclusion in a GNOME spin of a
155 distribution. It will ensure that the units necessary for GNOME
156 are properly enabled as they are installed. It leaves all other
157 units untouched, and subject to other (later) preset files, for
158 example like the one from the first example above.</para>
159
160 <example>
161 <title>Administrator policy</title>
162
163 <programlisting># /etc/systemd/system-preset/00-lennart.preset
164
165 enable httpd.service
166 enable sshd.service
167 enable postfix.service
168 disable *</programlisting>
169 </example>
170
171 <para>This enables three specific services and disables all
172 others. This is useful for administrators to specifically select
173 the units to enable, and disable all others. Due to the filename
174 prefix <literal>00-</literal> it will be read early and
175 override all other preset policy files.</para>
176 </refsect1>
177
178 <refsect1>
179 <title>See Also</title>
180 <para>
181 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
182 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
183 <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>
184 </para>
185 </refsect1>
186
187 </refentry>