]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.preset.xml
travis: add more ASan options
[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 # or
74 ; are ignored.</para>
75
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>
79
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>
83
84 <para>If multiple lines apply to a unit name, the first matching
85 one takes precedence over all others.</para>
86
87 <para>Each preset file shall be named in the style of
88 <filename>&lt;priority&gt;-&lt;policy-name&gt;.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>
103
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
108 filename.</para>
109 </refsect1>
110
111 <refsect1>
112 <title>Examples</title>
113
114 <example>
115 <title>Default to off</title>
116
117 <programlisting># /usr/lib/systemd/system-preset/99-default.preset
118
119 disable *</programlisting>
120 </example>
121
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>
125
126 <example>
127 <title>A GNOME spin</title>
128
129 <programlisting># /usr/lib/systemd/system-preset/50-gnome.preset
130
131 enable gdm.service
132 enable colord.service
133 enable accounts-daemon.service
134 enable avahi-daemon.*</programlisting>
135
136 </example>
137
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>
145
146 <example>
147 <title>Administrator policy</title>
148
149 <programlisting># /etc/systemd/system-preset/00-lennart.preset
150
151 enable httpd.service
152 enable sshd.service
153 enable postfix.service
154 disable *</programlisting>
155 </example>
156
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>
162 </refsect1>
163
164 <refsect1>
165 <title>See Also</title>
166 <para>
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>
170 </para>
171 </refsect1>
172
173 </refentry>