]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.preset.xml
doc: document the `architecture` setting
[thirdparty/systemd.git] / man / systemd.preset.xml
1 <?xml version="1.0"?>
2 <!--*-nxml-*-->
3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!--
5 SPDX-License-Identifier: LGPL-2.1+
6 -->
7 <refentry id="systemd.preset">
8
9 <refentryinfo>
10 <title>systemd.preset</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>systemd.preset</refentrytitle>
16 <manvolnum>5</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>systemd.preset</refname>
21 <refpurpose>Service enablement presets</refpurpose>
22 </refnamediv>
23
24 <refsynopsisdiv>
25 <para><filename>/etc/systemd/system-preset/*.preset</filename></para>
26 <para><filename>/run/systemd/system-preset/*.preset</filename></para>
27 <para><filename>/usr/lib/systemd/system-preset/*.preset</filename></para>
28 <para><filename>/etc/systemd/user-preset/*.preset</filename></para>
29 <para><filename>/run/systemd/user-preset/*.preset</filename></para>
30 <para><filename>/usr/lib/systemd/user-preset/*.preset</filename></para>
31 </refsynopsisdiv>
32
33 <refsect1>
34 <title>Description</title>
35
36 <para>Preset files may be used to encode policy which units shall
37 be enabled by default and which ones shall be disabled. They are
38 read by <command>systemctl preset</command> (for more information
39 see
40 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
41 which uses this information to enable or disable a unit according
42 to preset policy. <command>systemctl preset</command> is used by
43 the post install scriptlets of RPM packages (or other OS package
44 formats), to enable/disable specific units by default on package
45 installation, enforcing distribution, spin or administrator preset
46 policy. This allows choosing a certain set of units to be
47 enabled/disabled even before installing the actual package.</para>
48
49 <para>For more information on the preset logic please have a look
50 at the <ulink
51 url="https://www.freedesktop.org/wiki/Software/systemd/Preset">Presets</ulink>
52 document.</para>
53
54 <para>It is not recommended to ship preset files within the
55 respective software packages implementing the units, but rather
56 centralize them in a distribution or spin default policy, which
57 can be amended by administrator policy.</para>
58
59 <para>If no preset files exist, <command>systemctl
60 preset</command> will enable all units that are installed by
61 default. If this is not desired and all units shall rather be
62 disabled, it is necessary to ship a preset file with a single,
63 catchall "<filename>disable *</filename>" line. (See example 1,
64 below.)</para>
65 </refsect1>
66
67 <refsect1>
68 <title>Preset File Format</title>
69
70 <para>The preset files contain a list of directives consisting of
71 either the word <literal>enable</literal> or
72 <literal>disable</literal> followed by a space and a unit name
73 (possibly with shell style wildcards), separated by newlines.
74 Empty lines and lines whose first non-whitespace character is # or
75 ; are ignored.</para>
76
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
81 <para>Two different directives are understood:
82 <literal>enable</literal> may be used to enable units by default,
83 <literal>disable</literal> to disable units by default.</para>
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
89 <filename>&lt;priority&gt;-&lt;policy-name&gt;.preset</filename>. Files
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
108 <filename>/etc/systemd/system-preset/</filename> bearing the same
109 filename.</para>
110 </refsect1>
111
112 <refsect1>
113 <title>Examples</title>
114
115 <example>
116 <title>Default to off</title>
117
118 <programlisting># /usr/lib/systemd/system-preset/99-default.preset
119
120 disable *</programlisting>
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
125 be overridden by spin or administrator preset policy.</para>
126
127 <example>
128 <title>A GNOME spin</title>
129
130 <programlisting># /usr/lib/systemd/system-preset/50-gnome.preset
131
132 enable gdm.service
133 enable colord.service
134 enable accounts-daemon.service
135 enable avahi-daemon.*</programlisting>
136
137 </example>
138
139 <para>This enables the three mentioned units, plus all
140 <filename>avahi-daemon</filename> regardless of which unit type. A
141 file like this could be useful for inclusion in a GNOME spin of a
142 distribution. It will ensure that the units necessary for GNOME
143 are properly enabled as they are installed. It leaves all other
144 units untouched, and subject to other (later) preset files, for
145 example like the one from the first example above.</para>
146
147 <example>
148 <title>Administrator policy</title>
149
150 <programlisting># /etc/systemd/system-preset/00-lennart.preset
151
152 enable httpd.service
153 enable sshd.service
154 enable postfix.service
155 disable *</programlisting>
156 </example>
157
158 <para>This enables three specific services and disables all
159 others. This is useful for administrators to specifically select
160 the units to enable, and disable all others. Due to the filename
161 prefix <literal>00-</literal> it will be read early and
162 override all other preset policy files.</para>
163 </refsect1>
164
165 <refsect1>
166 <title>See Also</title>
167 <para>
168 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
169 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
170 <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>
171 </para>
172 </refsect1>
173
174 </refentry>