]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.unit.xml
test: suppress logs generated by journal tests
[thirdparty/systemd.git] / man / systemd.unit.xml
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % entities SYSTEM "custom-entities.ent" >
5 %entities;
6 ]>
7 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
8
9 <refentry id="systemd.unit"
10 xmlns:xi="http://www.w3.org/2001/XInclude">
11
12 <refentryinfo>
13 <title>systemd.unit</title>
14 <productname>systemd</productname>
15 </refentryinfo>
16
17 <refmeta>
18 <refentrytitle>systemd.unit</refentrytitle>
19 <manvolnum>5</manvolnum>
20 </refmeta>
21
22 <refnamediv>
23 <refname>systemd.unit</refname>
24 <refpurpose>Unit configuration</refpurpose>
25 </refnamediv>
26
27 <refsynopsisdiv>
28 <para><simplelist type="inline">
29 <member><filename><replaceable>service</replaceable>.service</filename></member>
30 <member><filename><replaceable>socket</replaceable>.socket</filename></member>
31 <member><filename><replaceable>device</replaceable>.device</filename></member>
32 <member><filename><replaceable>mount</replaceable>.mount</filename></member>
33 <member><filename><replaceable>automount</replaceable>.automount</filename></member>
34 <member><filename><replaceable>swap</replaceable>.swap</filename></member>
35 <member><filename><replaceable>target</replaceable>.target</filename></member>
36 <member><filename><replaceable>path</replaceable>.path</filename></member>
37 <member><filename><replaceable>timer</replaceable>.timer</filename></member>
38 <member><filename><replaceable>slice</replaceable>.slice</filename></member>
39 <member><filename><replaceable>scope</replaceable>.scope</filename></member>
40 </simplelist></para>
41
42 <refsect2>
43 <title>System Unit Search Path</title>
44
45 <para><simplelist>
46 <member><filename>/etc/systemd/system.control/*</filename></member>
47 <member><filename>/run/systemd/system.control/*</filename></member>
48 <member><filename>/run/systemd/transient/*</filename></member>
49 <member><filename>/run/systemd/generator.early/*</filename></member>
50 <member><filename>/etc/systemd/system/*</filename></member>
51 <member><filename>/etc/systemd/system.attached/*</filename></member>
52 <member><filename>/run/systemd/system/*</filename></member>
53 <member><filename>/run/systemd/system.attached/*</filename></member>
54 <member><filename>/run/systemd/generator/*</filename></member>
55 <member><filename index='false'></filename></member>
56 <member><filename>/usr/lib/systemd/system/*</filename></member>
57 <member><filename>/run/systemd/generator.late/*</filename></member>
58 </simplelist></para>
59 </refsect2>
60
61 <refsect2>
62 <title>User Unit Search Path</title>
63 <para><simplelist>
64 <member><filename>~/.config/systemd/user.control/*</filename></member>
65 <member><filename>$XDG_RUNTIME_DIR/systemd/user.control/*</filename></member>
66 <member><filename>$XDG_RUNTIME_DIR/systemd/transient/*</filename></member>
67 <member><filename>$XDG_RUNTIME_DIR/systemd/generator.early/*</filename></member>
68 <member><filename>~/.config/systemd/user/*</filename></member>
69 <member><filename>$XDG_CONFIG_DIRS/systemd/user/*</filename></member>
70 <member><filename>/etc/systemd/user/*</filename></member>
71 <member><filename>$XDG_RUNTIME_DIR/systemd/user/*</filename></member>
72 <member><filename>/run/systemd/user/*</filename></member>
73 <member><filename>$XDG_RUNTIME_DIR/systemd/generator/*</filename></member>
74 <member><filename>$XDG_DATA_HOME/systemd/user/*</filename></member>
75 <member><filename>$XDG_DATA_DIRS/systemd/user/*</filename></member>
76 <member><filename index='false'></filename></member>
77 <member><filename>/usr/lib/systemd/user/*</filename></member>
78 <member><filename>$XDG_RUNTIME_DIR/systemd/generator.late/*</filename></member>
79 </simplelist></para>
80 </refsect2>
81
82 </refsynopsisdiv>
83
84 <refsect1>
85 <title>Description</title>
86
87 <para>A unit file is a plain text ini-style file that encodes information about a service, a
88 socket, a device, a mount point, an automount point, a swap file or partition, a start-up
89 target, a watched file system path, a timer controlled and supervised by
90 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, a
91 resource management slice or a group of externally created processes. See
92 <citerefentry><refentrytitle>systemd.syntax</refentrytitle><manvolnum>7</manvolnum></citerefentry>
93 for a general description of the syntax.</para>
94
95 <para>This man page lists the common configuration options of all
96 the unit types. These options need to be configured in the [Unit]
97 or [Install] sections of the unit files.</para>
98
99 <para>In addition to the generic [Unit] and [Install] sections
100 described here, each unit may have a type-specific section, e.g.
101 [Service] for a service unit. See the respective man pages for
102 more information:
103 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
104 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
105 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
106 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
107 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
108 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
109 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
110 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
111 <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
112 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
113 <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
114 </para>
115
116 <para>Unit files are loaded from a set of paths determined during compilation, described in the next
117 section.</para>
118
119 <para>Valid unit names consist of a "unit name prefix", and a suffix specifying the unit type which
120 begins with a dot. The "unit name prefix" must consist of one or more valid characters (ASCII letters,
121 digits, <literal>:</literal>, <literal>-</literal>, <literal>_</literal>, <literal>.</literal>, and
122 <literal>\</literal>). The total length of the unit name including the suffix must not exceed 255
123 characters. The unit type suffix must be one of <literal>.service</literal>, <literal>.socket</literal>,
124 <literal>.device</literal>, <literal>.mount</literal>, <literal>.automount</literal>,
125 <literal>.swap</literal>, <literal>.target</literal>, <literal>.path</literal>,
126 <literal>.timer</literal>, <literal>.slice</literal>, or <literal>.scope</literal>.</para>
127
128 <para>Unit names can be parameterized by a single argument called the "instance name". The unit is then
129 constructed based on a "template file" which serves as the definition of multiple services or other
130 units. A template unit must have a single <literal>@</literal> at the end of the unit name prefix (right
131 before the type suffix). The name of the full unit is formed by inserting the instance name between
132 <literal>@</literal> and the unit type suffix. In the unit file itself, the instance parameter may be
133 referred to using <literal>%i</literal> and other specifiers, see below.</para>
134
135 <para>Unit files may contain additional options on top of those listed here. If systemd encounters an
136 unknown option, it will write a warning log message but continue loading the unit. If an option or
137 section name is prefixed with <option>X-</option>, it is ignored completely by systemd. Options within an
138 ignored section do not need the prefix. Applications may use this to include additional information in
139 the unit files. To access those options, applications need to parse the unit files on their own.</para>
140
141 <para>Units can be aliased (have an alternative name), by creating a symlink from the new name to the
142 existing name in one of the unit search paths. For example, <filename>systemd-networkd.service</filename>
143 has the alias <filename>dbus-org.freedesktop.network1.service</filename>, created during installation as
144 a symlink, so when <command>systemd</command> is asked through D-Bus to load
145 <filename>dbus-org.freedesktop.network1.service</filename>, it'll load
146 <filename>systemd-networkd.service</filename>. As another example, <filename>default.target</filename>
147 the default system target started at boot — is commonly aliased to either
148 <filename>multi-user.target</filename> or <filename>graphical.target</filename> to select what is started
149 by default. Alias names may be used in commands like <command>disable</command>,
150 <command>start</command>, <command>stop</command>, <command>status</command>, and similar, and in all
151 unit dependency directives, including <varname>Wants=</varname>, <varname>Requires=</varname>,
152 <varname>Before=</varname>, <varname>After=</varname>. Aliases cannot be used with the
153 <command>preset</command> command.</para>
154
155 <para>Aliases obey the following restrictions: a unit of a certain type (<literal>.service</literal>,
156 <literal>.socket</literal>, …) can only be aliased by a name with the same type suffix. A plain unit (not
157 a template or an instance), may only be aliased by a plain name. A template instance may only be aliased
158 by another template instance, and the instance part must be identical. A template may be aliased by
159 another template (in which case the alias applies to all instances of the template). As a special case, a
160 template instance (e.g. <literal>alias@inst.service</literal>) may be a symlink to different template
161 (e.g. <literal>template@inst.service</literal>). In that case, just this specific instance is aliased,
162 while other instances of the template (e.g. <literal>alias@foo.service</literal>,
163 <literal>alias@bar.service</literal>) are not aliased. Those rules preserve the requirement that the
164 instance (if any) is always uniquely defined for a given unit and all its aliases. The target of alias
165 symlink must point to a valid unit file location, i.e. the symlink target name must match the symlink
166 source name as described, and the destination path must be in one of the unit search paths, see UNIT FILE
167 LOAD PATH section below for more details. Note that the target file might not exist, i.e. the symlink may
168 be dangling.</para>
169
170 <para>Unit files may specify aliases through the <varname>Alias=</varname> directive in the [Install]
171 section. When the unit is enabled, symlinks will be created for those names, and removed when the unit is
172 disabled. For example, <filename>reboot.target</filename> specifies
173 <varname>Alias=ctrl-alt-del.target</varname>, so when enabled, the symlink
174 <filename>/etc/systemd/system/ctrl-alt-del.service</filename> pointing to the
175 <filename>reboot.target</filename> file will be created, and when
176 <keycombo><keycap>Ctrl</keycap><keycap>Alt</keycap><keycap>Del</keycap></keycombo> is invoked,
177 <command>systemd</command> will look for the <filename>ctrl-alt-del.service</filename> and execute
178 <filename>reboot.service</filename>. <command>systemd</command> does not look at the [Install] section at
179 all during normal operation, so any directives in that section only have an effect through the symlinks
180 created during enablement.</para>
181
182 <para>Along with a unit file <filename>foo.service</filename>, the directory
183 <filename>foo.service.wants/</filename> may exist. All unit files symlinked from such a directory are
184 implicitly added as dependencies of type <varname>Wants=</varname> to the unit. Similar functionality
185 exists for <varname>Requires=</varname> type dependencies as well, the directory suffix is
186 <filename>.requires/</filename> in this case. This functionality is useful to hook units into the
187 start-up of other units, without having to modify their unit files. For details about the semantics of
188 <varname>Wants=</varname> and <varname>Requires=</varname>, see below. The preferred way to create
189 symlinks in the <filename>.wants/</filename> or <filename>.requires/</filename> directories is by
190 specifying the dependency in [Install] section of the target unit, and creating the symlink in the file
191 system with the <command>enable</command> or <command>preset</command> commands of
192 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The
193 target can be a normal unit (either plain or a specific instance of a template unit). In case when the
194 source unit is a template, the target can also be a template, in which case the instance will be
195 "propagated" to the target unit to form a valid unit instance. The target of symlinks in
196 <filename>.wants/</filename> or <filename>.requires/</filename> must thus point to a valid unit file
197 location, i.e. the symlink target name must satisfy the described requirements, and the destination path
198 must be in one of the unit search paths, see UNIT FILE LOAD PATH section below for more details. Note
199 that the target file might not exist, i.e. the symlink may be dangling.</para>
200
201 <para>Along with a unit file <filename>foo.service</filename>, a "drop-in" directory
202 <filename>foo.service.d/</filename> may exist. All files with the suffix
203 <literal>.conf</literal> from this directory will be merged in the alphanumeric order and parsed
204 after the main unit file itself has been parsed. This is useful to alter or add configuration
205 settings for a unit, without having to modify unit files. Each drop-in file must contain appropriate
206 section headers. For instantiated units, this logic will first look for the instance
207 <literal>.d/</literal> subdirectory (e.g. <literal>foo@bar.service.d/</literal>) and read its
208 <literal>.conf</literal> files, followed by the template <literal>.d/</literal> subdirectory (e.g.
209 <literal>foo@.service.d/</literal>) and the <literal>.conf</literal> files there. Moreover for unit
210 names containing dashes (<literal>-</literal>), the set of directories generated by repeatedly
211 truncating the unit name after all dashes is searched too. Specifically, for a unit name
212 <filename>foo-bar-baz.service</filename> not only the regular drop-in directory
213 <filename>foo-bar-baz.service.d/</filename> is searched but also both <filename>foo-bar-.service.d/</filename> and
214 <filename>foo-.service.d/</filename>. This is useful for defining common drop-ins for a set of related units, whose
215 names begin with a common prefix. This scheme is particularly useful for mount, automount and slice units, whose
216 systematic naming structure is built around dashes as component separators. Note that equally named drop-in files
217 further down the prefix hierarchy override those further up,
218 i.e. <filename>foo-bar-.service.d/10-override.conf</filename> overrides
219 <filename>foo-.service.d/10-override.conf</filename>.</para>
220
221 <para>In cases of unit aliases (described above), dropins for the aliased name and all aliases are
222 loaded. In the example of <filename>default.target</filename> aliasing
223 <filename>graphical.target</filename>, <filename>default.target.d/</filename>,
224 <filename>default.target.wants/</filename>, <filename>default.target.requires/</filename>,
225 <filename>graphical.target.d/</filename>, <filename>graphical.target.wants/</filename>,
226 <filename>graphical.target.requires/</filename> would all be read. For templates, dropins for the
227 template, any template aliases, the template instance, and all alias instances are read. When just a
228 specific template instance is aliased, then the dropins for the target template, the target template
229 instance, and the alias template instance are read.</para>
230
231 <para>In addition to <filename>/etc/systemd/system</filename>, the drop-in <literal>.d/</literal>
232 directories for system services can be placed in <filename>/usr/lib/systemd/system</filename> or
233 <filename>/run/systemd/system</filename> directories. Drop-in files in <filename>/etc/</filename>
234 take precedence over those in <filename>/run/</filename> which in turn take precedence over those
235 in <filename>/usr/lib/</filename>. Drop-in files under any of these directories take precedence
236 over unit files wherever located. Multiple drop-in files with different names are applied in
237 lexicographic order, regardless of which of the directories they reside in.</para>
238
239 <para>Units also support a top-level drop-in with <filename><replaceable>type</replaceable>.d/</filename>,
240 where <replaceable>type</replaceable> may be e.g. <literal>service</literal> or <literal>socket</literal>,
241 that allows altering or adding to the settings of all corresponding unit files on the system.
242 The formatting and precedence of applying drop-in configurations follow what is defined above.
243 Files in <filename><replaceable>type</replaceable>.d/</filename> have lower precedence compared
244 to files in name-specific override directories. The usual rules apply: multiple drop-in files
245 with different names are applied in lexicographic order, regardless of which of the directories
246 they reside in, so a file in <filename><replaceable>type</replaceable>.d/</filename> applies
247 to a unit only if there are no drop-ins or masks with that name in directories with higher
248 precedence. See Examples.</para>
249
250 <para>Note that while systemd offers a flexible dependency system
251 between units it is recommended to use this functionality only
252 sparingly and instead rely on techniques such as bus-based or
253 socket-based activation which make dependencies implicit,
254 resulting in a both simpler and more flexible system.</para>
255
256 <para>As mentioned above, a unit may be instantiated from a template file. This allows creation
257 of multiple units from a single configuration file. If systemd looks for a unit configuration
258 file, it will first search for the literal unit name in the file system. If that yields no
259 success and the unit name contains an <literal>@</literal> character, systemd will look for a
260 unit template that shares the same name but with the instance string (i.e. the part between the
261 <literal>@</literal> character and the suffix) removed. Example: if a service
262 <filename>getty@tty3.service</filename> is requested and no file by that name is found, systemd
263 will look for <filename>getty@.service</filename> and instantiate a service from that
264 configuration file if it is found.</para>
265
266 <para>To refer to the instance string from within the
267 configuration file you may use the special <literal>%i</literal>
268 specifier in many of the configuration options. See below for
269 details.</para>
270
271 <para>If a unit file is empty (i.e. has the file size 0) or is
272 symlinked to <filename>/dev/null</filename>, its configuration
273 will not be loaded and it appears with a load state of
274 <literal>masked</literal>, and cannot be activated. Use this as an
275 effective way to fully disable a unit, making it impossible to
276 start it even manually.</para>
277
278 <para>The unit file format is covered by the
279 <ulink url="https://systemd.io/PORTABILITY_AND_STABILITY/">Interface
280 Portability and Stability Promise</ulink>.</para>
281
282 </refsect1>
283
284 <refsect1>
285 <title>String Escaping for Inclusion in Unit Names</title>
286
287 <para>Sometimes it is useful to convert arbitrary strings into unit names. To facilitate this, a method of string
288 escaping is used, in order to map strings containing arbitrary byte values (except <constant>NUL</constant>) into
289 valid unit names and their restricted character set. A common special case are unit names that reflect paths to
290 objects in the file system hierarchy. Example: a device unit <filename>dev-sda.device</filename> refers to a device
291 with the device node <filename index="false">/dev/sda</filename> in the file system.</para>
292
293 <para>The escaping algorithm operates as follows: given a string, any <literal>/</literal> character is
294 replaced by <literal>-</literal>, and all other characters which are not ASCII alphanumerics,
295 <literal>:</literal>, <literal>_</literal> or <literal>.</literal> are replaced by C-style
296 <literal>\x2d</literal> escapes. In addition, <literal>.</literal> is replaced with such a C-style escape
297 when it would appear as the first character in the escaped string.</para>
298
299 <para>When the input qualifies as absolute file system path, this algorithm is extended slightly: the path to the
300 root directory <literal>/</literal> is encoded as single dash <literal>-</literal>. In addition, any leading,
301 trailing or duplicate <literal>/</literal> characters are removed from the string before transformation. Example:
302 <filename index="false">/foo//bar/baz/</filename> becomes <literal>foo-bar-baz</literal>.</para>
303
304 <para>This escaping is fully reversible, as long as it is known whether the escaped string was a path (the
305 unescaping results are different for paths and non-path strings). The
306 <citerefentry><refentrytitle>systemd-escape</refentrytitle><manvolnum>1</manvolnum></citerefentry> command may be
307 used to apply and reverse escaping on arbitrary strings. Use <command>systemd-escape --path</command> to escape
308 path strings, and <command>systemd-escape</command> without <option>--path</option> otherwise.</para>
309 </refsect1>
310
311 <refsect1>
312 <title>Automatic dependencies</title>
313
314 <refsect2>
315 <title>Implicit Dependencies</title>
316
317 <para>A number of unit dependencies are implicitly established, depending on unit type and
318 unit configuration. These implicit dependencies can make unit configuration file cleaner. For
319 the implicit dependencies in each unit type, please refer to section "Implicit Dependencies"
320 in respective man pages.</para>
321
322 <para>For example, service units with <varname>Type=dbus</varname> automatically acquire
323 dependencies of type <varname>Requires=</varname> and <varname>After=</varname> on
324 <filename>dbus.socket</filename>. See
325 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
326 for details.</para>
327 </refsect2>
328
329 <refsect2>
330 <title>Default Dependencies</title>
331
332 <para>Default dependencies are similar to implicit dependencies, but can be turned on and off
333 by setting <varname>DefaultDependencies=</varname> to <varname>yes</varname> (the default) and
334 <varname>no</varname>, while implicit dependencies are always in effect. See section "Default
335 Dependencies" in respective man pages for the effect of enabling
336 <varname>DefaultDependencies=</varname> in each unit types.</para>
337
338 <para>For example, target units will complement all configured dependencies of type
339 <varname>Wants=</varname> or <varname>Requires=</varname> with dependencies of type
340 <varname>After=</varname>. See
341 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>
342 for details. Note that this behavior can be opted out by setting
343 <varname>DefaultDependencies=no</varname> in the specified units, or it can be selectively
344 overridden via an explicit <varname>Before=</varname> dependency.</para>
345 </refsect2>
346 </refsect1>
347
348 <refsect1>
349 <title>Unit File Load Path</title>
350
351 <para>Unit files are loaded from a set of paths determined during
352 compilation, described in the two tables below. Unit files found
353 in directories listed earlier override files with the same name in
354 directories lower in the list.</para>
355
356 <para>When the variable <varname>$SYSTEMD_UNIT_PATH</varname> is set,
357 the contents of this variable overrides the unit load path. If
358 <varname>$SYSTEMD_UNIT_PATH</varname> ends with an empty component
359 (<literal>:</literal>), the usual unit load path will be appended
360 to the contents of the variable.</para>
361
362 <table>
363 <title>
364 Load path when running in system mode (<option>--system</option>).
365 </title>
366
367 <tgroup cols='2'>
368 <colspec colname='path' />
369 <colspec colname='expl' />
370 <thead>
371 <row>
372 <entry>Path</entry>
373 <entry>Description</entry>
374 </row>
375 </thead>
376 <tbody>
377 <row>
378 <entry><filename>/etc/systemd/system.control</filename></entry>
379 <entry morerows="1">Persistent and transient configuration created using the dbus API</entry>
380 </row>
381 <row>
382 <entry><filename>/run/systemd/system.control</filename></entry>
383 </row>
384 <row>
385 <entry><filename>/run/systemd/transient</filename></entry>
386 <entry>Dynamic configuration for transient units</entry>
387 </row>
388 <row>
389 <entry><filename>/run/systemd/generator.early</filename></entry>
390 <entry>Generated units with high priority (see <replaceable>early-dir</replaceable> in <citerefentry
391 ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry>
392 </row>
393 <row>
394 <entry><filename>/etc/systemd/system</filename></entry>
395 <entry>System units created by the administrator</entry>
396 </row>
397 <row>
398 <entry><filename>/run/systemd/system</filename></entry>
399 <entry>Runtime units</entry>
400 </row>
401 <row>
402 <entry><filename>/run/systemd/generator</filename></entry>
403 <entry>Generated units with medium priority (see <replaceable>normal-dir</replaceable> in <citerefentry
404 ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry>
405 </row>
406 <row>
407 <entry><filename>/usr/local/lib/systemd/system</filename></entry>
408 <entry>System units installed by the administrator </entry>
409 </row>
410 <row>
411 <entry><filename>/usr/lib/systemd/system</filename></entry>
412 <entry>System units installed by the distribution package manager</entry>
413 </row>
414 <row>
415 <entry><filename>/run/systemd/generator.late</filename></entry>
416 <entry>Generated units with low priority (see <replaceable>late-dir</replaceable> in <citerefentry
417 ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry>
418 </row>
419 </tbody>
420 </tgroup>
421 </table>
422
423 <table>
424 <title>
425 Load path when running in user mode (<option>--user</option>).
426 </title>
427
428 <tgroup cols='2'>
429 <colspec colname='path' />
430 <colspec colname='expl' />
431 <thead>
432 <row>
433 <entry>Path</entry>
434 <entry>Description</entry>
435 </row>
436 </thead>
437 <tbody>
438 <row>
439 <entry><filename>$XDG_CONFIG_HOME/systemd/user.control</filename> or <filename
440 >~/.config/systemd/user.control</filename></entry>
441 <entry morerows="1">Persistent and transient configuration created using the dbus API (<varname>$XDG_CONFIG_HOME</varname> is used if set, <filename>~/.config</filename> otherwise)</entry>
442 </row>
443 <row>
444 <entry><filename>$XDG_RUNTIME_DIR/systemd/user.control</filename></entry>
445 </row>
446 <row>
447 <entry><filename>$XDG_RUNTIME_DIR/systemd/transient</filename></entry>
448 <entry>Dynamic configuration for transient units</entry>
449 </row>
450 <row>
451 <entry><filename>$XDG_RUNTIME_DIR/systemd/generator.early</filename></entry>
452 <entry>Generated units with high priority (see <replaceable>early-dir</replaceable> in <citerefentry
453 ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry>
454 </row>
455 <row>
456 <entry><filename>$XDG_CONFIG_HOME/systemd/user</filename> or <filename>$HOME/.config/systemd/user</filename></entry>
457 <entry>User configuration (<varname>$XDG_CONFIG_HOME</varname> is used if set, <filename>~/.config</filename> otherwise)</entry>
458 </row>
459 <row>
460 <entry><filename>$XDG_CONFIG_DIRS/systemd/user</filename> or <filename>/etc/xdg/systemd/user</filename></entry>
461 <entry>Additional configuration directories as specified by the XDG base directory specification (<varname>$XDG_CONFIG_DIRS</varname> is used if set, <filename>/etc/xdg</filename> otherwise)</entry>
462 </row>
463 <row>
464 <entry><filename>/etc/systemd/user</filename></entry>
465 <entry>User units created by the administrator</entry>
466 </row>
467 <row>
468 <entry><filename>$XDG_RUNTIME_DIR/systemd/user</filename></entry>
469 <entry>Runtime units (only used when $XDG_RUNTIME_DIR is set)</entry>
470 </row>
471 <row>
472 <entry><filename>/run/systemd/user</filename></entry>
473 <entry>Runtime units</entry>
474 </row>
475 <row>
476 <entry><filename>$XDG_RUNTIME_DIR/systemd/generator</filename></entry>
477 <entry>Generated units with medium priority (see <replaceable>normal-dir</replaceable> in <citerefentry
478 ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry>
479 </row>
480 <row>
481 <entry><filename>$XDG_DATA_HOME/systemd/user</filename> or <filename>$HOME/.local/share/systemd/user</filename></entry>
482 <entry>Units of packages that have been installed in the home directory (<varname>$XDG_DATA_HOME</varname> is used if set, <filename>~/.local/share</filename> otherwise)</entry>
483 </row>
484 <row>
485 <entry><filename>$XDG_DATA_DIRS/systemd/user</filename> or <filename>/usr/local/share/systemd/user</filename> and <filename>/usr/share/systemd/user</filename></entry>
486 <entry>Additional data directories as specified by the XDG base directory specification (<varname>$XDG_DATA_DIRS</varname> is used if set, <filename>/usr/local/share</filename> and <filename>/usr/share</filename> otherwise)</entry>
487 </row>
488 <row>
489 <entry><filename>$dir/systemd/user</filename> for each <varname index="false">$dir</varname> in <varname>$XDG_DATA_DIRS</varname></entry>
490 <entry>Additional locations for installed user units, one for each entry in <varname>$XDG_DATA_DIRS</varname></entry>
491 </row>
492 <row>
493 <entry><filename>/usr/local/lib/systemd/user</filename></entry>
494 <entry>User units installed by the administrator</entry>
495 </row>
496 <row>
497 <entry><filename>/usr/lib/systemd/user</filename></entry>
498 <entry>User units installed by the distribution package manager</entry>
499 </row>
500 <row>
501 <entry><filename>$XDG_RUNTIME_DIR/systemd/generator.late</filename></entry>
502 <entry>Generated units with low priority (see <replaceable>late-dir</replaceable> in <citerefentry
503 ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry>
504 </row>
505 </tbody>
506 </tgroup>
507 </table>
508
509 <para>The set of load paths for the user manager instance may be augmented or
510 changed using various environment variables. And environment variables may in
511 turn be set using environment generators, see
512 <citerefentry><refentrytitle>systemd.environment-generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
513 In particular, <varname>$XDG_DATA_HOME</varname> and
514 <varname>$XDG_DATA_DIRS</varname> may be easily set using
515 <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
516 Thus, directories listed here are just the defaults. To see the actual list that
517 would be used based on compilation options and current environment use
518 <programlisting>systemd-analyze --user unit-paths</programlisting>
519 </para>
520
521 <para>Moreover, additional units might be loaded into systemd from directories not on the unit load path
522 by creating a symlink pointing to a unit file in the directories. You can use <command>systemctl
523 link</command> for this; see
524 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The file
525 system where the linked unit files are located must be accessible when systemd is started (e.g. anything
526 underneath <filename>/home/</filename> or <filename>/var/</filename> is not allowed, unless those
527 directories are located on the root file system).</para>
528
529 <para>It is important to distinguish "linked unit files" from "unit file aliases": any symlink where the
530 symlink <emphasis>target</emphasis> is within the unit load path becomes an alias: the source name and
531 the target file name must satisfy specific constraints listed above in the discussion of aliases, but the
532 symlink target doesn't have to exist, and in fact the symlink target path is not used, except to check
533 whether the target is within the unit load path. In contrast, a symlink which goes outside of the unit
534 load path signifies a linked unit file. The symlink is followed when loading the file, but the
535 destination name is otherwise unused (and may even not be a valid unit file name). For example, symlinks
536 <filename index='false'>/etc/systemd/system/alias1.service</filename><filename index='false'>service1.service</filename>,
537 <filename index='false'>/etc/systemd/system/alias2.service</filename><filename index='false'>/usr/lib/systemd/service1.service</filename>,
538 <filename index='false'>/etc/systemd/system/alias3.service</filename><filename index='false'>/etc/systemd/system/service1.service</filename>
539 are all valid aliases and <filename index='false'>service1.service</filename> will have
540 four names, even if the unit file is located at
541 <filename index='false'>/run/systemd/system/service1.service</filename>. In contrast,
542 a symlink <filename index='false'>/etc/systemd/system/link1.service</filename><filename index='false'>../link1_service_file</filename>
543 means that <filename index='false'>link1.service</filename> is a "linked unit" and the contents of
544 <filename index='false'>/etc/systemd/link1_service_file</filename> provide its configuration.</para>
545 </refsect1>
546
547 <refsect1>
548 <title>Unit Garbage Collection</title>
549
550 <para>The system and service manager loads a unit's configuration automatically when a unit is referenced for the
551 first time. It will automatically unload the unit configuration and state again when the unit is not needed anymore
552 ("garbage collection"). A unit may be referenced through a number of different mechanisms:</para>
553
554 <orderedlist>
555 <listitem><para>Another loaded unit references it with a dependency such as <varname>After=</varname>,
556 <varname>Wants=</varname>, …</para></listitem>
557
558 <listitem><para>The unit is currently starting, running, reloading or stopping.</para></listitem>
559
560 <listitem><para>The unit is currently in the <constant>failed</constant> state. (But see below.)</para></listitem>
561
562 <listitem><para>A job for the unit is pending.</para></listitem>
563
564 <listitem><para>The unit is pinned by an active IPC client program.</para></listitem>
565
566 <listitem><para>The unit is a special "perpetual" unit that is always active and loaded. Examples for perpetual
567 units are the root mount unit <filename>-.mount</filename> or the scope unit <filename>init.scope</filename> that
568 the service manager itself lives in.</para></listitem>
569
570 <listitem><para>The unit has running processes associated with it.</para></listitem>
571 </orderedlist>
572
573 <para>The garbage collection logic may be altered with the <varname>CollectMode=</varname> option, which allows
574 configuration whether automatic unloading of units that are in <constant>failed</constant> state is permissible,
575 see below.</para>
576
577 <para>Note that when a unit's configuration and state is unloaded, all execution results, such as exit codes, exit
578 signals, resource consumption and other statistics are lost, except for what is stored in the log subsystem.</para>
579
580 <para>Use <command>systemctl daemon-reload</command> or an equivalent command to reload unit configuration while
581 the unit is already loaded. In this case all configuration settings are flushed out and replaced with the new
582 configuration (which however might not be in effect immediately), however all runtime state is
583 saved/restored.</para>
584 </refsect1>
585
586 <refsect1>
587 <title>[Unit] Section Options</title>
588
589 <para>The unit file may include a [Unit] section, which carries
590 generic information about the unit that is not dependent on the
591 type of unit:</para>
592
593 <variablelist class='unit-directives'>
594 <varlistentry>
595 <term><varname>Description=</varname></term>
596 <listitem><para>A short human readable title of the unit. This may be used by
597 <command>systemd</command> (and other UIs) as a user-visible label for the unit, so this string
598 should identify the unit rather than describe it, despite the name. This string also shouldn't just
599 repeat the unit name. <literal>Apache2 Web Server</literal> is a good example. Bad examples are
600 <literal>high-performance light-weight HTTP server</literal> (too generic) or
601 <literal>Apache2</literal> (meaningless for people who do not know Apache, duplicates the unit
602 name). <command>systemd</command> may use this string as a noun in status messages (<literal>Starting
603 <replaceable>description</replaceable>...</literal>, <literal>Started
604 <replaceable>description</replaceable>.</literal>, <literal>Reached target
605 <replaceable>description</replaceable>.</literal>, <literal>Failed to start
606 <replaceable>description</replaceable>.</literal>), so it should be capitalized, and should not be a
607 full sentence, or a phrase with a continuous verb. Bad examples include <literal>exiting the
608 container</literal> or <literal>updating the database once per day.</literal>.</para>
609
610 <xi:include href="version-info.xml" xpointer="v201"/>
611 </listitem>
612 </varlistentry>
613
614 <varlistentry>
615 <term><varname>Documentation=</varname></term>
616 <listitem><para>A space-separated list of URIs referencing
617 documentation for this unit or its configuration. Accepted are
618 only URIs of the types <literal>http://</literal>,
619 <literal>https://</literal>, <literal>file:</literal>,
620 <literal>info:</literal>, <literal>man:</literal>. For more
621 information about the syntax of these URIs, see <citerefentry
622 project='man-pages'><refentrytitle>uri</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
623 The URIs should be listed in order of relevance, starting with
624 the most relevant. It is a good idea to first reference
625 documentation that explains what the unit's purpose is,
626 followed by how it is configured, followed by any other
627 related documentation. This option may be specified more than
628 once, in which case the specified list of URIs is merged. If
629 the empty string is assigned to this option, the list is reset
630 and all prior assignments will have no
631 effect.</para>
632
633 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
634 </varlistentry>
635
636 <varlistentry>
637 <term><varname>Wants=</varname></term>
638
639 <listitem><para>Configures (weak) requirement dependencies on other units. This option may be
640 specified more than once or multiple space-separated units may be specified in one option in which
641 case dependencies for all listed names will be created. Dependencies of this type may also be
642 configured outside of the unit configuration file by adding a symlink to a
643 <filename>.wants/</filename> directory accompanying the unit file. For details, see above.</para>
644
645 <para>Units listed in this option will be started if the configuring unit is. However, if the listed
646 units fail to start or cannot be added to the transaction, this has no impact on the validity of the
647 transaction as a whole, and this unit will still be started. This is the recommended way to hook
648 the start-up of one unit to the start-up of another unit.</para>
649
650 <para>Note that requirement dependencies do not influence the order in which services are started or
651 stopped. This has to be configured independently with the <varname>After=</varname> or
652 <varname>Before=</varname> options. If unit <filename>foo.service</filename> pulls in unit
653 <filename>bar.service</filename> as configured with <varname>Wants=</varname> and no ordering is
654 configured with <varname>After=</varname> or <varname>Before=</varname>, then both units will be
655 started simultaneously and without any delay between them if <filename>foo.service</filename> is
656 activated.</para>
657
658 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
659 </varlistentry>
660
661 <varlistentry>
662 <term><varname>Requires=</varname></term>
663
664 <listitem><para>Similar to <varname>Wants=</varname>, but declares a stronger requirement
665 dependency. Dependencies of this type may also be configured by adding a symlink to a
666 <filename>.requires/</filename> directory accompanying the unit file.</para>
667
668 <para>If this unit gets activated, the units listed will be activated as well. If one of
669 the other units fails to activate, and an ordering dependency <varname>After=</varname> on the
670 failing unit is set, this unit will not be started. Besides, with or without specifying
671 <varname>After=</varname>, this unit will be stopped (or restarted) if one of the other units is
672 explicitly stopped (or restarted).</para>
673
674 <para>Often, it is a better choice to use <varname>Wants=</varname> instead of
675 <varname>Requires=</varname> in order to achieve a system that is more robust when dealing with
676 failing services.</para>
677
678 <para>Note that this dependency type does not imply that the other unit always has to be in active state when
679 this unit is running. Specifically: failing condition checks (such as <varname>ConditionPathExists=</varname>,
680 <varname>ConditionPathIsSymbolicLink=</varname>, … — see below) do not cause the start job of a unit with a
681 <varname>Requires=</varname> dependency on it to fail. Also, some unit types may deactivate on their own (for
682 example, a service process may decide to exit cleanly, or a device may be unplugged by the user), which is not
683 propagated to units having a <varname>Requires=</varname> dependency. Use the <varname>BindsTo=</varname>
684 dependency type together with <varname>After=</varname> to ensure that a unit may never be in active state
685 without a specific other unit also in active state (see below).</para>
686
687 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
688 </varlistentry>
689
690 <varlistentry>
691 <term><varname>Requisite=</varname></term>
692
693 <listitem><para>Similar to <varname>Requires=</varname>. However, if the units listed here
694 are not started already, they will not be started and the starting of this unit will fail
695 immediately. <varname>Requisite=</varname> does not imply an ordering dependency, even if
696 both units are started in the same transaction. Hence this setting should usually be
697 combined with <varname>After=</varname>, to ensure this unit is not started before the other
698 unit.</para>
699
700 <para>When <varname>Requisite=b.service</varname> is used on
701 <filename>a.service</filename>, this dependency will show as
702 <varname>RequisiteOf=a.service</varname> in property listing of
703 <filename>b.service</filename>. <varname>RequisiteOf=</varname>
704 dependency cannot be specified directly.</para>
705
706 <xi:include href="version-info.xml" xpointer="v201"/>
707 </listitem>
708 </varlistentry>
709
710 <varlistentry>
711 <term><varname>BindsTo=</varname></term>
712
713 <listitem><para>Configures requirement dependencies, very similar in style to
714 <varname>Requires=</varname>. However, this dependency type is stronger: in addition to the effect of
715 <varname>Requires=</varname> it declares that if the unit bound to is stopped, this unit will be stopped
716 too. This means a unit bound to another unit that suddenly enters inactive state will be stopped too.
717 Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit
718 might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of
719 a mount unit might be unmounted without involvement of the system and service manager.</para>
720
721 <para>When used in conjunction with <varname>After=</varname> on the same unit the behaviour of
722 <varname>BindsTo=</varname> is even stronger. In this case, the unit bound to strictly has to be in active
723 state for this unit to also be in active state. This not only means a unit bound to another unit that suddenly
724 enters inactive state, but also one that is bound to another unit that gets skipped due to an unmet condition
725 check (such as <varname>ConditionPathExists=</varname>, <varname>ConditionPathIsSymbolicLink=</varname>, … —
726 see below) will be stopped, should it be running. Hence, in many cases it is best to combine
727 <varname>BindsTo=</varname> with <varname>After=</varname>.</para>
728
729 <para>When <varname>BindsTo=b.service</varname> is used on
730 <filename>a.service</filename>, this dependency will show as
731 <varname>BoundBy=a.service</varname> in property listing of
732 <filename>b.service</filename>. <varname>BoundBy=</varname>
733 dependency cannot be specified directly.</para>
734
735 <xi:include href="version-info.xml" xpointer="v201"/>
736 </listitem>
737 </varlistentry>
738
739 <varlistentry>
740 <term><varname>PartOf=</varname></term>
741
742 <listitem><para>Configures dependencies similar to
743 <varname>Requires=</varname>, but limited to stopping and
744 restarting of units. When systemd stops or restarts the units
745 listed here, the action is propagated to this unit. Note that
746 this is a one-way dependency — changes to this unit do not
747 affect the listed units.</para>
748
749 <para>When <varname>PartOf=b.service</varname> is used on
750 <filename>a.service</filename>, this dependency will show as
751 <varname>ConsistsOf=a.service</varname> in property listing of
752 <filename>b.service</filename>. <varname>ConsistsOf=</varname>
753 dependency cannot be specified directly.</para>
754
755 <xi:include href="version-info.xml" xpointer="v201"/>
756 </listitem>
757 </varlistentry>
758
759 <varlistentry>
760 <term><varname>Upholds=</varname></term>
761
762 <listitem><para>Configures dependencies similar to <varname>Wants=</varname>, but as long as this unit
763 is up, all units listed in <varname>Upholds=</varname> are started whenever found to be inactive or
764 failed, and no job is queued for them. While a <varname>Wants=</varname> dependency on another unit
765 has a one-time effect when this units started, a <varname>Upholds=</varname> dependency on it has a
766 continuous effect, constantly restarting the unit if necessary. This is an alternative to the
767 <varname>Restart=</varname> setting of service units, to ensure they are kept running whatever
768 happens. The restart happens without delay, and usual per-unit rate-limit applies.</para>
769
770 <para>When <varname>Upholds=b.service</varname> is used on <filename>a.service</filename>, this
771 dependency will show as <varname>UpheldBy=a.service</varname> in the property listing of
772 <filename>b.service</filename>.</para>
773
774 <xi:include href="version-info.xml" xpointer="v249"/>
775 </listitem>
776 </varlistentry>
777
778 <varlistentry>
779 <term><varname>Conflicts=</varname></term>
780
781 <listitem><para>A space-separated list of unit names. Configures negative requirement
782 dependencies. If a unit has a <varname>Conflicts=</varname> setting on another unit, starting the
783 former will stop the latter and vice versa.</para>
784
785 <para>Note that this setting does not imply an ordering dependency, similarly to the
786 <varname>Wants=</varname> and <varname>Requires=</varname> dependencies described above. This means
787 that to ensure that the conflicting unit is stopped before the other unit is started, an
788 <varname>After=</varname> or <varname>Before=</varname> dependency must be declared. It doesn't
789 matter which of the two ordering dependencies is used, because stop jobs are always ordered before
790 start jobs, see the discussion in <varname>Before=</varname>/<varname>After=</varname> below.</para>
791
792 <para>If unit A that conflicts with unit B is scheduled to
793 be started at the same time as B, the transaction will either
794 fail (in case both are required parts of the transaction) or be
795 modified to be fixed (in case one or both jobs are not a
796 required part of the transaction). In the latter case, the job
797 that is not required will be removed, or in case both are
798 not required, the unit that conflicts will be started and the
799 unit that is conflicted is stopped.</para>
800
801 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
802 </varlistentry>
803
804 <varlistentry>
805 <term><varname>Before=</varname></term>
806 <term><varname>After=</varname></term>
807
808 <listitem><para>These two settings expect a space-separated list of unit names. They may be specified
809 more than once, in which case dependencies for all listed names are created.</para>
810
811 <para>Those two settings configure ordering dependencies between units. If unit
812 <filename>foo.service</filename> contains the setting <option>Before=bar.service</option> and both
813 units are being started, <filename>bar.service</filename>'s start-up is delayed until
814 <filename>foo.service</filename> has finished starting up. <varname>After=</varname> is the inverse
815 of <varname>Before=</varname>, i.e. while <varname>Before=</varname> ensures that the configured unit
816 is started before the listed unit begins starting up, <varname>After=</varname> ensures the opposite,
817 that the listed unit is fully started up before the configured unit is started.</para>
818
819 <para>When two units with an ordering dependency between them are shut down, the inverse of the
820 start-up order is applied. I.e. if a unit is configured with <varname>After=</varname> on another
821 unit, the former is stopped before the latter if both are shut down. Given two units with any
822 ordering dependency between them, if one unit is shut down and the other is started up, the shutdown
823 is ordered before the start-up. It doesn't matter if the ordering dependency is
824 <varname>After=</varname> or <varname>Before=</varname>, in this case. It also doesn't matter which
825 of the two is shut down, as long as one is shut down and the other is started up; the shutdown is
826 ordered before the start-up in all cases. If two units have no ordering dependencies between them,
827 they are shut down or started up simultaneously, and no ordering takes place. It depends on the unit
828 type when precisely a unit has finished starting up. Most importantly, for service units start-up is
829 considered completed for the purpose of <varname>Before=</varname>/<varname>After=</varname> when all
830 its configured start-up commands have been invoked and they either failed or reported start-up
831 success. Note that this does includes <varname>ExecStartPost=</varname> (or
832 <varname>ExecStopPost=</varname> for the shutdown case).</para>
833
834 <para>Note that those settings are independent of and orthogonal to the requirement dependencies as
835 configured by <varname>Requires=</varname>, <varname>Wants=</varname>, <varname>Requisite=</varname>,
836 or <varname>BindsTo=</varname>. It is a common pattern to include a unit name in both the
837 <varname>After=</varname> and <varname>Wants=</varname> options, in which case the unit listed will
838 be started before the unit that is configured with these options.</para>
839
840 <para>Note that <varname>Before=</varname> dependencies on device units have no effect and are not
841 supported. Devices generally become available as a result of an external hotplug event, and systemd
842 creates the corresponding device unit without delay.</para>
843
844 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
845 </varlistentry>
846
847 <varlistentry>
848 <term><varname>OnFailure=</varname></term>
849
850 <listitem><para>A space-separated list of one or more units that are activated when this unit enters
851 the <literal>failed</literal> state.</para>
852
853 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
854 </varlistentry>
855
856 <varlistentry>
857 <term><varname>OnSuccess=</varname></term>
858
859 <listitem><para>A space-separated list of one or more units that are activated when this unit enters
860 the <literal>inactive</literal> state.</para>
861
862 <xi:include href="version-info.xml" xpointer="v249"/></listitem>
863 </varlistentry>
864
865 <varlistentry>
866 <term><varname>PropagatesReloadTo=</varname></term>
867 <term><varname>ReloadPropagatedFrom=</varname></term>
868
869 <listitem><para>A space-separated list of one or more units to which reload requests from this unit
870 shall be propagated to, or units from which reload requests shall be propagated to this unit,
871 respectively. Issuing a reload request on a unit will automatically also enqueue reload requests on
872 all units that are linked to it using these two settings.</para>
873
874 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
875 </varlistentry>
876
877 <varlistentry>
878 <term><varname>PropagatesStopTo=</varname></term>
879 <term><varname>StopPropagatedFrom=</varname></term>
880
881 <listitem><para>A space-separated list of one or more units to which stop requests from this unit
882 shall be propagated to, or units from which stop requests shall be propagated to this unit,
883 respectively. Issuing a stop request on a unit will automatically also enqueue stop requests on all
884 units that are linked to it using these two settings.</para>
885
886 <xi:include href="version-info.xml" xpointer="v249"/></listitem>
887 </varlistentry>
888
889 <varlistentry>
890 <term><varname>JoinsNamespaceOf=</varname></term>
891
892 <listitem><para>For units that start processes (such as service units), lists one or more other units
893 whose network and/or temporary file namespace to join. If this is specified on a unit (say,
894 <filename>a.service</filename> has <varname>JoinsNamespaceOf=b.service</varname>), then the inverse
895 dependency (<varname>JoinsNamespaceOf=a.service</varname> for b.service) is implied. This only
896 applies to unit types which support the <varname>PrivateNetwork=</varname>,
897 <varname>NetworkNamespacePath=</varname>, <varname>PrivateIPC=</varname>,
898 <varname>IPCNamespacePath=</varname>, and <varname>PrivateTmp=</varname> directives (see
899 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
900 details). If a unit that has this setting set is started, its processes will see the same
901 <filename>/tmp/</filename>, <filename>/var/tmp/</filename>, IPC namespace and network namespace as
902 one listed unit that is started. If multiple listed units are already started and these do not share
903 their namespace, then it is not defined which namespace is joined. Note that this setting only has an
904 effect if <varname>PrivateNetwork=</varname>/<varname>NetworkNamespacePath=</varname>,
905 <varname>PrivateIPC=</varname>/<varname>IPCNamespacePath=</varname> and/or
906 <varname>PrivateTmp=</varname> is enabled for both the unit that joins the namespace and the unit
907 whose namespace is joined.</para>
908
909 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
910 </varlistentry>
911
912 <varlistentry>
913 <term><varname>RequiresMountsFor=</varname></term>
914
915 <listitem><para>Takes a space-separated list of absolute
916 paths. Automatically adds dependencies of type
917 <varname>Requires=</varname> and <varname>After=</varname> for
918 all mount units required to access the specified path.</para>
919
920 <para>Mount points marked with <option>noauto</option> are not
921 mounted automatically through <filename>local-fs.target</filename>,
922 but are still honored for the purposes of this option, i.e. they
923 will be pulled in by this unit.</para>
924
925 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
926 </varlistentry>
927
928 <varlistentry>
929 <term><varname>WantsMountsFor=</varname></term>
930
931 <listitem><para>Same as <varname>RequiresMountsFor=</varname>,
932 but adds dependencies of type <varname>Wants=</varname> instead
933 of <varname>Requires=</varname>.</para>
934
935 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
936 </varlistentry>
937
938 <varlistentry>
939 <term><varname>OnSuccessJobMode=</varname></term>
940 <term><varname>OnFailureJobMode=</varname></term>
941
942 <listitem><para>Takes a value of
943 <literal>fail</literal>,
944 <literal>replace</literal>,
945 <literal>replace-irreversibly</literal>,
946 <literal>isolate</literal>,
947 <literal>flush</literal>,
948 <literal>ignore-dependencies</literal> or
949 <literal>ignore-requirements</literal>. Defaults to
950 <literal>replace</literal>. Specifies how the units listed in
951 <varname>OnSuccess=</varname>/<varname>OnFailure=</varname> will be enqueued. See
952 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
953 <option>--job-mode=</option> option for details on the
954 possible values. If this is set to <literal>isolate</literal>,
955 only a single unit may be listed in
956 <varname>OnSuccess=</varname>/<varname>OnFailure=</varname>.</para>
957
958 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
959 </varlistentry>
960
961 <varlistentry>
962 <term><varname>IgnoreOnIsolate=</varname></term>
963
964 <listitem><para>Takes a boolean argument. If <option>true</option>, this unit will not be stopped
965 when isolating another unit. Defaults to <option>false</option> for service, target, socket, timer,
966 and path units, and <option>true</option> for slice, scope, device, swap, mount, and automount
967 units.</para>
968
969 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
970 </varlistentry>
971
972 <varlistentry>
973 <term><varname>StopWhenUnneeded=</varname></term>
974
975 <listitem><para>Takes a boolean argument. If
976 <option>true</option>, this unit will be stopped when it is no
977 longer used. Note that, in order to minimize the work to be
978 executed, systemd will not stop units by default unless they
979 are conflicting with other units, or the user explicitly
980 requested their shut down. If this option is set, a unit will
981 be automatically cleaned up if no other active unit requires
982 it. Defaults to <option>false</option>.</para>
983
984 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
985 </varlistentry>
986
987 <varlistentry>
988 <term><varname>RefuseManualStart=</varname></term>
989 <term><varname>RefuseManualStop=</varname></term>
990
991 <listitem><para>Takes a boolean argument. If
992 <option>true</option>, this unit can only be activated or
993 deactivated indirectly. In this case, explicit start-up or
994 termination requested by the user is denied, however if it is
995 started or stopped as a dependency of another unit, start-up
996 or termination will succeed. This is mostly a safety feature
997 to ensure that the user does not accidentally activate units
998 that are not intended to be activated explicitly, and not
999 accidentally deactivate units that are not intended to be
1000 deactivated. These options default to
1001 <option>false</option>.</para>
1002
1003 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
1004 </varlistentry>
1005
1006 <varlistentry>
1007 <term><varname>AllowIsolate=</varname></term>
1008
1009 <listitem><para>Takes a boolean argument. If
1010 <option>true</option>, this unit may be used with the
1011 <command>systemctl isolate</command> command. Otherwise, this
1012 will be refused. It probably is a good idea to leave this
1013 disabled except for target units that shall be used similar to
1014 runlevels in SysV init systems, just as a precaution to avoid
1015 unusable system states. This option defaults to
1016 <option>false</option>.</para>
1017
1018 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
1019 </varlistentry>
1020
1021 <varlistentry>
1022 <term><varname>DefaultDependencies=</varname></term>
1023
1024 <listitem><para>Takes a boolean argument. If
1025 <option>yes</option>, (the default), a few default
1026 dependencies will implicitly be created for the unit. The
1027 actual dependencies created depend on the unit type. For
1028 example, for service units, these dependencies ensure that the
1029 service is started only after basic system initialization is
1030 completed and is properly terminated on system shutdown. See
1031 the respective man pages for details. Generally, only services
1032 involved with early boot or late shutdown should set this
1033 option to <option>no</option>. It is highly recommended to
1034 leave this option enabled for the majority of common units. If
1035 set to <option>no</option>, this option does not disable
1036 all implicit dependencies, just non-essential
1037 ones.</para>
1038
1039 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
1040 </varlistentry>
1041
1042 <varlistentry>
1043 <term><varname>SurviveFinalKillSignal=</varname></term>
1044
1045 <listitem><para>Takes a boolean argument. Defaults to <option>no</option>. If <option>yes</option>,
1046 processes belonging to this unit will not be sent the final <literal>SIGTERM</literal> and
1047 <literal>SIGKILL</literal> signals during the final phase of the system shutdown process.
1048 This functionality replaces the older mechanism that allowed a program to set
1049 <literal>argv[0][0] = '@'</literal> as described at
1050 <ulink url="https://systemd.io/ROOT_STORAGE_DAEMONS">systemd and Storage Daemons for the Root File
1051 System</ulink>, which however continues to be supported.</para>
1052
1053 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
1054 </varlistentry>
1055
1056 <varlistentry>
1057 <term><varname>CollectMode=</varname></term>
1058
1059 <listitem><para>Tweaks the "garbage collection" algorithm for this unit. Takes one of <option>inactive</option>
1060 or <option>inactive-or-failed</option>. If set to <option>inactive</option> the unit will be unloaded if it is
1061 in the <constant>inactive</constant> state and is not referenced by clients, jobs or other units — however it
1062 is not unloaded if it is in the <constant>failed</constant> state. In <option>failed</option> mode, failed
1063 units are not unloaded until the user invoked <command>systemctl reset-failed</command> on them to reset the
1064 <constant>failed</constant> state, or an equivalent command. This behaviour is altered if this option is set to
1065 <option>inactive-or-failed</option>: in this case the unit is unloaded even if the unit is in a
1066 <constant>failed</constant> state, and thus an explicitly resetting of the <constant>failed</constant> state is
1067 not necessary. Note that if this mode is used unit results (such as exit codes, exit signals, consumed
1068 resources, …) are flushed out immediately after the unit completed, except for what is stored in the logging
1069 subsystem. Defaults to <option>inactive</option>.</para>
1070
1071 <xi:include href="version-info.xml" xpointer="v236"/>
1072 </listitem>
1073 </varlistentry>
1074
1075 <varlistentry>
1076 <term><varname>FailureAction=</varname></term>
1077 <term><varname>SuccessAction=</varname></term>
1078
1079 <listitem><para>Configure the action to take when the unit stops and enters a failed state or
1080 inactive state. Takes one of <option>none</option>, <option>reboot</option>,
1081 <option>reboot-force</option>, <option>reboot-immediate</option>, <option>poweroff</option>,
1082 <option>poweroff-force</option>, <option>poweroff-immediate</option>, <option>exit</option>,
1083 <option>exit-force</option>, <option>soft-reboot</option>, <option>soft-reboot-force</option>,
1084 <option>kexec</option>, <option>kexec-force</option>, <option>halt</option>,
1085 <option>halt-force</option> and <option>halt-immediate</option>. In system mode, all options are
1086 allowed. In user mode, only <option>none</option>, <option>exit</option>, and
1087 <option>exit-force</option> are allowed. Both options default to <option>none</option>.</para>
1088
1089 <para>If <option>none</option> is set, no action will be triggered. <option>reboot</option> causes a
1090 reboot following the normal shutdown procedure (i.e. equivalent to <command>systemctl
1091 reboot</command>). <option>reboot-force</option> causes a forced reboot which will terminate all
1092 processes forcibly but should cause no dirty file systems on reboot (i.e. equivalent to
1093 <command>systemctl reboot -f</command>) and <option>reboot-immediate</option> causes immediate
1094 execution of the
1095 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system
1096 call, which might result in data loss (i.e. equivalent to <command>systemctl reboot -ff</command>).
1097 Similarly, <option>poweroff</option>, <option>poweroff-force</option>,
1098 <option>poweroff-immediate</option>, <option>kexec</option>, <option>kexec-force</option>,
1099 <option>halt</option>, <option>halt-force</option> and <option>halt-immediate</option> have the
1100 effect of powering down the system, executing kexec, and halting the system respectively with similar
1101 semantics. <option>exit</option> causes the manager to exit following the normal shutdown procedure,
1102 and <option>exit-force</option> causes it terminate without shutting down services. When
1103 <option>exit</option> or <option>exit-force</option> is used by default the exit status of the main
1104 process of the unit (if this applies) is returned from the service manager. However, this may be
1105 overridden with
1106 <varname>FailureActionExitStatus=</varname>/<varname>SuccessActionExitStatus=</varname>, see below.
1107 <option>soft-reboot</option> will trigger a userspace reboot operation.
1108 <option>soft-reboot-force</option> does that too, but does not go through the shutdown transaction
1109 beforehand.</para>
1110
1111 <xi:include href="version-info.xml" xpointer="v236"/></listitem>
1112 </varlistentry>
1113
1114 <varlistentry>
1115 <term><varname>FailureActionExitStatus=</varname></term>
1116 <term><varname>SuccessActionExitStatus=</varname></term>
1117
1118 <listitem><para>Controls the exit status to propagate back to an invoking container manager (in case of a
1119 system service) or service manager (in case of a user manager) when the
1120 <varname>FailureAction=</varname>/<varname>SuccessAction=</varname> are set to <option>exit</option> or
1121 <option>exit-force</option> and the action is triggered. By default the exit status of the main process of the
1122 triggering unit (if this applies) is propagated. Takes a value in the range 0255 or the empty string to
1123 request default behaviour.</para>
1124
1125 <xi:include href="version-info.xml" xpointer="v240"/></listitem>
1126 </varlistentry>
1127
1128 <varlistentry>
1129 <term><varname>JobTimeoutSec=</varname></term>
1130 <term><varname>JobRunningTimeoutSec=</varname></term>
1131
1132 <listitem><para><varname>JobTimeoutSec=</varname> specifies a timeout for the whole job that starts
1133 running when the job is queued. <varname>JobRunningTimeoutSec=</varname> specifies a timeout that
1134 starts running when the queued job is actually started. If either limit is reached, the job will be
1135 cancelled, the unit however will not change state or even enter the <literal>failed</literal> mode.
1136 </para>
1137
1138 <para>Both settings take a time span with the default unit of seconds, but other units may be
1139 specified, see
1140 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
1141 The default is <literal>infinity</literal> (job timeouts disabled), except for device units where
1142 <varname>JobRunningTimeoutSec=</varname> defaults to <varname>DefaultDeviceTimeoutSec=</varname>.
1143 </para>
1144
1145 <para>Note: these timeouts are independent from any unit-specific timeouts (for example, the timeout
1146 set with <varname>TimeoutStartSec=</varname> in service units). The job timeout has no effect on the
1147 unit itself. Or in other words: unit-specific timeouts are useful to abort unit state changes, and
1148 revert them. The job timeout set with this option however is useful to abort only the job waiting for
1149 the unit state to change.</para>
1150
1151 <xi:include href="version-info.xml" xpointer="v201"/>
1152 </listitem>
1153 </varlistentry>
1154
1155 <varlistentry>
1156 <term><varname>JobTimeoutAction=</varname></term>
1157 <term><varname>JobTimeoutRebootArgument=</varname></term>
1158
1159 <listitem><para><varname>JobTimeoutAction=</varname> optionally configures an additional action to
1160 take when the timeout is hit, see description of <varname>JobTimeoutSec=</varname> and
1161 <varname>JobRunningTimeoutSec=</varname> above. It takes the same values as
1162 <varname>FailureAction=</varname>/<varname>SuccessAction=</varname>. Defaults to
1163 <option>none</option>.</para>
1164
1165 <para><varname>JobTimeoutRebootArgument=</varname> configures an optional reboot string to pass to
1166 the <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system
1167 call.</para>
1168
1169 <xi:include href="version-info.xml" xpointer="v240"/></listitem>
1170 </varlistentry>
1171
1172 <varlistentry>
1173 <term><varname>StartLimitIntervalSec=<replaceable>interval</replaceable></varname></term>
1174 <term><varname>StartLimitBurst=<replaceable>burst</replaceable></varname></term>
1175
1176 <listitem><para>Configure unit start rate limiting. Units which are started more than
1177 <replaceable>burst</replaceable> times within an <replaceable>interval</replaceable> time span are
1178 not permitted to start any more. Use <varname>StartLimitIntervalSec=</varname> to configure the
1179 checking interval and <varname>StartLimitBurst=</varname> to configure how many starts per interval
1180 are allowed.</para>
1181
1182 <para><replaceable>interval</replaceable> is a time span with the default unit of seconds, but other
1183 units may be specified, see
1184 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
1185 The special value <literal>infinity</literal> can be used to limit the total number of start
1186 attempts, even if they happen at large time intervals.
1187 Defaults to <varname>DefaultStartLimitIntervalSec=</varname> in manager configuration file, and may
1188 be set to 0 to disable any kind of rate limiting. <replaceable>burst</replaceable> is a number and
1189 defaults to <varname>DefaultStartLimitBurst=</varname> in manager configuration file.</para>
1190
1191 <para>These configuration options are particularly useful in conjunction with the service setting
1192 <varname>Restart=</varname> (see
1193 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>);
1194 however, they apply to all kinds of starts (including manual), not just those triggered by the
1195 <varname>Restart=</varname> logic.</para>
1196
1197 <para>Note that units which are configured for <varname>Restart=</varname>, and which reach the start
1198 limit are not attempted to be restarted anymore; however, they may still be restarted manually or
1199 from a timer or socket at a later point, after the <replaceable>interval</replaceable> has passed.
1200 From that point on, the restart logic is activated again. <command>systemctl reset-failed</command>
1201 will cause the restart rate counter for a service to be flushed, which is useful if the administrator
1202 wants to manually start a unit and the start limit interferes with that. Rate-limiting is enforced
1203 after any unit condition checks are executed, and hence unit activations with failing conditions do
1204 not count towards the rate limit.</para>
1205
1206 <para>When a unit is unloaded due to the garbage collection logic (see above) its rate limit counters
1207 are flushed out too. This means that configuring start rate limiting for a unit that is not
1208 referenced continuously has no effect.</para>
1209
1210 <para>This setting does not apply to slice, target, device, and scope units, since they are unit
1211 types whose activation may either never fail, or may succeed only a single time.</para>
1212
1213 <xi:include href="version-info.xml" xpointer="v229"/></listitem>
1214 </varlistentry>
1215
1216 <varlistentry>
1217 <term><varname>StartLimitAction=</varname></term>
1218
1219 <listitem><para>Configure an additional action to take if the rate limit configured with
1220 <varname>StartLimitIntervalSec=</varname> and <varname>StartLimitBurst=</varname> is hit. Takes the same
1221 values as the <varname>FailureAction=</varname>/<varname>SuccessAction=</varname> settings. If
1222 <option>none</option> is set, hitting the rate limit will trigger no action except that
1223 the start will not be permitted. Defaults to <option>none</option>.</para>
1224
1225 <xi:include href="version-info.xml" xpointer="v229"/></listitem>
1226 </varlistentry>
1227
1228 <varlistentry>
1229 <term><varname>RebootArgument=</varname></term>
1230 <listitem><para>Configure the optional argument for the
1231 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call if
1232 <varname>StartLimitAction=</varname> or <varname>FailureAction=</varname> is a reboot action. This
1233 works just like the optional argument to <command>systemctl reboot</command> command.</para>
1234
1235 <xi:include href="version-info.xml" xpointer="v229"/></listitem>
1236 </varlistentry>
1237
1238 <varlistentry>
1239 <term><varname>SourcePath=</varname></term>
1240 <listitem><para>A path to a configuration file this unit has
1241 been generated from. This is primarily useful for
1242 implementation of generator tools that convert configuration
1243 from an external configuration file format into native unit
1244 files. This functionality should not be used in normal
1245 units.</para>
1246
1247 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
1248 </varlistentry>
1249 </variablelist>
1250
1251 <refsect2>
1252 <title>Conditions and Asserts</title>
1253
1254 <para>Unit files may also include a number of <varname index="false">Condition…=</varname> and <varname
1255 index="false">Assert…=</varname> settings. Before the unit is started, systemd will verify that the
1256 specified conditions and asserts are true. If not, the starting of the unit will be (mostly silently)
1257 skipped (in case of conditions), or aborted with an error message (in case of asserts). Failing
1258 conditions or asserts will not result in the unit being moved into the <literal>failed</literal>
1259 state. The conditions and asserts are checked at the time the queued start job is to be executed. The
1260 ordering dependencies are still respected, so other units are still pulled in and ordered as if this
1261 unit was successfully activated, and the conditions and asserts are executed the precise moment the
1262 unit would normally start and thus can validate system state after the units ordered before completed
1263 initialization. Use condition expressions for skipping units that do not apply to the local system, for
1264 example because the kernel or runtime environment doesn't require their functionality.
1265 </para>
1266
1267 <para>If multiple conditions are specified, the unit will be executed if all of them apply (i.e. a
1268 logical AND is applied). Condition checks can use a pipe symbol (<literal>|</literal>) after the equals
1269 sign (<literal>Condition…=|…</literal>), which causes the condition to become a
1270 <emphasis>triggering</emphasis> condition. If at least one triggering condition is defined for a unit,
1271 then the unit will be started if at least one of the triggering conditions of the unit applies and all
1272 of the regular (i.e. non-triggering) conditions apply. If you prefix an argument with the pipe symbol
1273 and an exclamation mark, the pipe symbol must be passed first, the exclamation second. If any of these
1274 options is assigned the empty string, the list of conditions is reset completely, all previous
1275 condition settings (of any kind) will have no effect.</para>
1276
1277 <para>The <varname>AssertArchitecture=</varname>, <varname>AssertVirtualization=</varname>, … options
1278 are similar to conditions but cause the start job to fail (instead of being skipped). The failed check
1279 is logged. Units with unmet conditions are considered to be in a clean state and will be garbage
1280 collected if they are not referenced. This means that when queried, the condition failure may or may
1281 not show up in the state of the unit.</para>
1282
1283 <para>Note that neither assertion nor condition expressions result in unit state changes. Also note
1284 that both are checked at the time the job is to be executed, i.e. long after depending jobs and it
1285 itself were queued. Thus, neither condition nor assertion expressions are suitable for conditionalizing
1286 unit dependencies.</para>
1287
1288 <para>The <command>condition</command> verb of
1289 <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry> can
1290 be used to test condition and assert expressions.</para>
1291
1292 <para>Except for <varname>ConditionPathIsSymbolicLink=</varname>, all path checks follow symlinks.</para>
1293
1294 <variablelist class='unit-directives'>
1295 <varlistentry>
1296 <term><varname>ConditionArchitecture=</varname></term>
1297
1298 <listitem><para>Check whether the system is running on a specific architecture. Takes one of
1299 <literal>x86</literal>,
1300 <literal>x86-64</literal>,
1301 <literal>ppc</literal>,
1302 <literal>ppc-le</literal>,
1303 <literal>ppc64</literal>,
1304 <literal>ppc64-le</literal>,
1305 <literal>ia64</literal>,
1306 <literal>parisc</literal>,
1307 <literal>parisc64</literal>,
1308 <literal>s390</literal>,
1309 <literal>s390x</literal>,
1310 <literal>sparc</literal>,
1311 <literal>sparc64</literal>,
1312 <literal>mips</literal>,
1313 <literal>mips-le</literal>,
1314 <literal>mips64</literal>,
1315 <literal>mips64-le</literal>,
1316 <literal>alpha</literal>,
1317 <literal>arm</literal>,
1318 <literal>arm-be</literal>,
1319 <literal>arm64</literal>,
1320 <literal>arm64-be</literal>,
1321 <literal>sh</literal>,
1322 <literal>sh64</literal>,
1323 <literal>m68k</literal>,
1324 <literal>tilegx</literal>,
1325 <literal>cris</literal>,
1326 <literal>arc</literal>,
1327 <literal>arc-be</literal>, or
1328 <literal>native</literal>.</para>
1329
1330 <para>Use
1331 <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1332 for the complete list of known architectures.</para>
1333
1334 <para>The architecture is determined from the information returned by
1335 <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1336 and is thus subject to
1337 <citerefentry><refentrytitle>personality</refentrytitle><manvolnum>2</manvolnum></citerefentry>.
1338 Note that a <varname>Personality=</varname> setting in the same unit file has no effect on this
1339 condition. A special architecture name <literal>native</literal> is mapped to the architecture the
1340 system manager itself is compiled for. The test may be negated by prepending an exclamation
1341 mark.</para>
1342
1343 <xi:include href="version-info.xml" xpointer="v201"/>
1344 </listitem>
1345 </varlistentry>
1346
1347 <varlistentry>
1348 <term><varname>ConditionFirmware=</varname></term>
1349
1350 <listitem><para>Check whether the system's firmware is of a certain type. The following values are
1351 possible:</para>
1352
1353 <itemizedlist>
1354 <listitem><para><literal>uefi</literal> matches systems with EFI.</para></listitem>
1355
1356 <listitem><para><literal>device-tree</literal> matches systems with a device tree.
1357 </para></listitem>
1358
1359 <listitem><para><literal>device-tree-compatible(<replaceable>value</replaceable>)</literal>
1360 matches systems with a device tree that are compatible with <literal>value</literal>.
1361 </para></listitem>
1362
1363 <listitem><para><literal>smbios-field(<replaceable>field</replaceable>
1364 <replaceable>operator</replaceable> <replaceable>value</replaceable>)</literal> matches systems
1365 with a SMBIOS field containing a certain value. <replaceable>field</replaceable> is the name of
1366 the SMBIOS field exposed as <literal>sysfs</literal> attribute file below
1367 <filename>/sys/class/dmi/id/</filename>. <replaceable>operator</replaceable> is one of
1368 <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>&gt;=</literal>,
1369 <literal>&gt;</literal>, <literal>==</literal>, <literal>&lt;&gt;</literal> for version
1370 comparisons, <literal>=</literal> and <literal>!=</literal> for literal string comparisons, or
1371 <literal>$=</literal>, <literal>!$=</literal> for shell-style glob comparisons.
1372 <replaceable>value</replaceable> is the expected value of the SMBIOS field value (possibly
1373 containing shell style globs in case <literal>$=</literal>/<literal>!$=</literal> is used).
1374 </para></listitem>
1375 </itemizedlist>
1376
1377 <xi:include href="version-info.xml" xpointer="v249"/></listitem>
1378 </varlistentry>
1379
1380 <varlistentry>
1381 <term><varname>ConditionVirtualization=</varname></term>
1382
1383 <listitem><para>Check whether the system is executed in a virtualized environment and optionally
1384 test whether it is a specific implementation. Takes either boolean value to check if being executed
1385 in any virtualized environment, or one of
1386 <literal>vm</literal> and
1387 <literal>container</literal> to test against a generic type of virtualization solution, or one of
1388 <literal>qemu</literal>,
1389 <literal>kvm</literal>,
1390 <literal>amazon</literal>,
1391 <literal>zvm</literal>,
1392 <literal>vmware</literal>,
1393 <literal>microsoft</literal>,
1394 <literal>oracle</literal>,
1395 <literal>powervm</literal>,
1396 <literal>xen</literal>,
1397 <literal>bochs</literal>,
1398 <literal>uml</literal>,
1399 <literal>bhyve</literal>,
1400 <literal>qnx</literal>,
1401 <literal>apple</literal>,
1402 <literal>sre</literal>,
1403 <literal>openvz</literal>,
1404 <literal>lxc</literal>,
1405 <literal>lxc-libvirt</literal>,
1406 <literal>systemd-nspawn</literal>,
1407 <literal>docker</literal>,
1408 <literal>podman</literal>,
1409 <literal>rkt</literal>,
1410 <literal>wsl</literal>,
1411 <literal>proot</literal>,
1412 <literal>pouch</literal>,
1413 <literal>acrn</literal> to test
1414 against a specific implementation, or
1415 <literal>private-users</literal> to check whether we are running in a user namespace. See
1416 <citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1417 for a full list of known virtualization technologies and their identifiers. If multiple
1418 virtualization technologies are nested, only the innermost is considered. The test may be negated
1419 by prepending an exclamation mark.</para>
1420
1421 <xi:include href="version-info.xml" xpointer="v244"/>
1422 </listitem>
1423 </varlistentry>
1424
1425 <varlistentry>
1426 <term><varname>ConditionHost=</varname></term>
1427
1428 <listitem><para><varname>ConditionHost=</varname> may be used to match against the hostname or
1429 machine ID of the host. This either takes a hostname string (optionally with shell style globs)
1430 which is tested against the locally set hostname as returned by
1431 <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>, or
1432 a machine ID formatted as string (see
1433 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
1434 The test may be negated by prepending an exclamation mark.</para>
1435
1436 <xi:include href="version-info.xml" xpointer="v244"/>
1437 </listitem>
1438 </varlistentry>
1439
1440 <varlistentry>
1441 <term><varname>ConditionKernelCommandLine=</varname></term>
1442
1443 <listitem><para><varname>ConditionKernelCommandLine=</varname> may be used to check whether a
1444 specific kernel command line option is set (or if prefixed with the exclamation mark — unset). The
1445 argument must either be a single word, or an assignment (i.e. two words, separated by
1446 <literal>=</literal>). In the former case the kernel command line is searched for the word
1447 appearing as is, or as left hand side of an assignment. In the latter case, the exact assignment is
1448 looked for with right and left hand side matching. This operates on the kernel command line
1449 communicated to userspace via <filename>/proc/cmdline</filename>, except when the service manager
1450 is invoked as payload of a container manager, in which case the command line of <filename>PID
1451 1</filename> is used instead (i.e. <filename>/proc/1/cmdline</filename>).</para>
1452
1453 <xi:include href="version-info.xml" xpointer="v244"/>
1454 </listitem>
1455 </varlistentry>
1456
1457 <varlistentry>
1458 <term><varname>ConditionKernelVersion=</varname></term>
1459
1460 <listitem><para><varname>ConditionKernelVersion=</varname> may be used to check whether the kernel
1461 version (as reported by <command>uname -r</command>) matches a certain expression, or if prefixed
1462 with the exclamation mark, does not match. The argument must be a list of (potentially quoted)
1463 expressions. Each expression starts with one of <literal>=</literal> or <literal>!=</literal> for
1464 string comparisons, <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>==</literal>,
1465 <literal>&lt;&gt;</literal>, <literal>&gt;=</literal>, <literal>&gt;</literal> for version
1466 comparisons, or <literal>$=</literal>, <literal>!$=</literal> for a shell-style glob match. If no
1467 operator is specified, <literal>$=</literal> is implied.</para>
1468
1469 <para>Note that using the kernel version string is an unreliable way to determine which features
1470 are supported by a kernel, because of the widespread practice of backporting drivers, features, and
1471 fixes from newer upstream kernels into older versions provided by distributions. Hence, this check
1472 is inherently unportable and should not be used for units which may be used on different
1473 distributions.</para>
1474
1475 <xi:include href="version-info.xml" xpointer="v244"/>
1476 </listitem>
1477 </varlistentry>
1478
1479 <varlistentry>
1480 <term><varname>ConditionCredential=</varname></term>
1481
1482 <listitem><para><varname>ConditionCredential=</varname> may be used to check whether a credential
1483 by the specified name was passed into the service manager. See <ulink
1484 url="https://systemd.io/CREDENTIALS">System and Service Credentials</ulink> for details about
1485 credentials. If used in services for the system service manager this may be used to conditionalize
1486 services based on system credentials passed in. If used in services for the per-user service
1487 manager this may be used to conditionalize services based on credentials passed into the
1488 <filename>unit@.service</filename> service instance belonging to the user. The argument must be a
1489 valid credential name.</para>
1490
1491 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
1492 </varlistentry>
1493
1494 <varlistentry>
1495 <term><varname>ConditionEnvironment=</varname></term>
1496
1497 <listitem><para><varname>ConditionEnvironment=</varname> may be used to check whether a specific
1498 environment variable is set (or if prefixed with the exclamation mark — unset) in the service
1499 manager's environment block.
1500
1501 The argument may be a single word, to check if the variable with this name is defined in the
1502 environment block, or an assignment
1503 (<literal><replaceable>name</replaceable>=<replaceable>value</replaceable></literal>), to check if
1504 the variable with this exact value is defined. Note that the environment block of the service
1505 manager itself is checked, i.e. not any variables defined with <varname>Environment=</varname> or
1506 <varname>EnvironmentFile=</varname>, as described above. This is particularly useful when the
1507 service manager runs inside a containerized environment or as per-user service manager, in order to
1508 check for variables passed in by the enclosing container manager or PAM.</para>
1509
1510 <xi:include href="version-info.xml" xpointer="v246"/>
1511 </listitem>
1512 </varlistentry>
1513
1514 <varlistentry>
1515 <term><varname>ConditionSecurity=</varname></term>
1516
1517 <listitem><para><varname>ConditionSecurity=</varname> may be used to check whether the given
1518 security technology is enabled on the system. Currently, the following values are recognized:</para>
1519
1520 <table>
1521 <title>Recognized security technologies</title>
1522
1523 <tgroup cols='2'>
1524 <colspec colname='value'/>
1525 <colspec colname='description'/>
1526
1527 <thead>
1528 <row>
1529 <entry>Value</entry>
1530 <entry>Description</entry>
1531 </row>
1532 </thead>
1533 <tbody>
1534 <row>
1535 <entry>selinux</entry>
1536 <entry>SELinux MAC</entry>
1537 </row>
1538 <row>
1539 <entry>apparmor</entry>
1540 <entry>AppArmor MAC</entry>
1541 </row>
1542 <row>
1543 <entry>tomoyo</entry>
1544 <entry>Tomoyo MAC</entry>
1545 </row>
1546 <row>
1547 <entry>smack</entry>
1548 <entry>SMACK MAC</entry>
1549 </row>
1550 <row>
1551 <entry>ima</entry>
1552 <entry>Integrity Measurement Architecture (IMA)</entry>
1553 </row>
1554 <row>
1555 <entry>audit</entry>
1556 <entry>Linux Audit Framework</entry>
1557 </row>
1558 <row>
1559 <entry>uefi-secureboot</entry>
1560 <entry>UEFI SecureBoot</entry>
1561 </row>
1562 <row>
1563 <entry>tpm2</entry>
1564 <entry>Trusted Platform Module 2.0 (TPM2)</entry>
1565 </row>
1566 <row>
1567 <entry>cvm</entry>
1568 <entry>Confidential virtual machine (SEV/TDX)</entry>
1569 </row>
1570 <row>
1571 <entry>measured-uki</entry>
1572 <entry>Unified Kernel Image with PCR 11 Measurements, as per <citerefentry><refentrytitle>systemd-stub</refentrytitle><manvolnum>7</manvolnum></citerefentry>. <xi:include href="version-info.xml" xpointer="v255"/></entry>
1573 </row>
1574 </tbody>
1575 </tgroup>
1576 </table>
1577
1578 <para>The test may be negated by prepending an exclamation mark.</para>
1579
1580 <xi:include href="version-info.xml" xpointer="v244"/>
1581 </listitem>
1582 </varlistentry>
1583
1584 <varlistentry>
1585 <term><varname>ConditionCapability=</varname></term>
1586
1587 <listitem><para>Check whether the given capability exists in the capability bounding set of the
1588 service manager (i.e. this does not check whether capability is actually available in the permitted
1589 or effective sets, see
1590 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
1591 for details). Pass a capability name such as <literal>CAP_MKNOD</literal>, possibly prefixed with
1592 an exclamation mark to negate the check.</para>
1593
1594 <xi:include href="version-info.xml" xpointer="v244"/>
1595 </listitem>
1596 </varlistentry>
1597
1598 <varlistentry>
1599 <term><varname>ConditionACPower=</varname></term>
1600
1601 <listitem><para>Check whether the system has AC power, or is exclusively battery powered at the
1602 time of activation of the unit. This takes a boolean argument. If set to <literal>true</literal>,
1603 the condition will hold only if at least one AC connector of the system is connected to a power
1604 source, or if no AC connectors are known. Conversely, if set to <literal>false</literal>, the
1605 condition will hold only if there is at least one AC connector known and all AC connectors are
1606 disconnected from a power source.</para>
1607
1608 <xi:include href="version-info.xml" xpointer="v244"/>
1609 </listitem>
1610 </varlistentry>
1611
1612 <varlistentry>
1613 <term><varname>ConditionNeedsUpdate=</varname></term>
1614
1615 <listitem><para>Takes one of <filename>/var/</filename> or <filename>/etc/</filename> as argument,
1616 possibly prefixed with a <literal>!</literal> (to invert the condition). This condition may be
1617 used to conditionalize units on whether the specified directory requires an update because
1618 <filename>/usr/</filename>'s modification time is newer than the stamp file
1619 <filename>.updated</filename> in the specified directory. This is useful to implement offline
1620 updates of the vendor operating system resources in <filename>/usr/</filename> that require updating
1621 of <filename>/etc/</filename> or <filename>/var/</filename> on the next following boot. Units making
1622 use of this condition should order themselves before
1623 <citerefentry><refentrytitle>systemd-update-done.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1624 to make sure they run before the stamp file's modification time gets reset indicating a completed
1625 update.</para>
1626
1627 <para>If the <varname>systemd.condition_needs_update=</varname> option is specified on the kernel
1628 command line (taking a boolean), it will override the result of this condition check, taking
1629 precedence over any file modification time checks. If the kernel command line option is used,
1630 <filename>systemd-update-done.service</filename> will not have immediate effect on any following
1631 <varname>ConditionNeedsUpdate=</varname> checks, until the system is rebooted where the kernel
1632 command line option is not specified anymore.</para>
1633
1634 <para>Note that to make this scheme effective, the timestamp of <filename>/usr/</filename> should
1635 be explicitly updated after its contents are modified. The kernel will automatically update
1636 modification timestamp on a directory only when immediate children of a directory are modified; an
1637 modification of nested files will not automatically result in mtime of <filename>/usr/</filename>
1638 being updated.</para>
1639
1640 <para>Also note that if the update method includes a call to execute appropriate post-update steps
1641 itself, it should not touch the timestamp of <filename>/usr/</filename>. In a typical distribution
1642 packaging scheme, packages will do any required update steps as part of the installation or
1643 upgrade, to make package contents immediately usable. <varname>ConditionNeedsUpdate=</varname>
1644 should be used with other update mechanisms where such an immediate update does not
1645 happen.</para>
1646
1647 <xi:include href="version-info.xml" xpointer="v244"/></listitem>
1648 </varlistentry>
1649
1650 <varlistentry>
1651 <term><varname>ConditionFirstBoot=</varname></term>
1652
1653 <listitem><para>Takes a boolean argument. This condition may be used to conditionalize units on
1654 whether the system is booting up for the first time. This roughly means that <filename>/etc/</filename>
1655 was unpopulated when the system started booting (for details, see "First Boot Semantics" in
1656 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
1657 First Boot is considered finished (this condition will evaluate as false) after the manager
1658 has finished the startup phase.</para>
1659
1660 <para>This condition may be used to populate <filename>/etc/</filename> on the first boot after
1661 factory reset, or when a new system instance boots up for the first time.</para>
1662
1663 <para>Note that the service manager itself will perform setup steps during First Boot: it will
1664 initialize
1665 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> and
1666 preset all units, enabling or disabling them according to the
1667 <citerefentry><refentrytitle>systemd.preset</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1668 settings. Additional setup may be performed via units with
1669 <varname>ConditionFirstBoot=yes</varname>.</para>
1670
1671 <para>For robustness, units with <varname>ConditionFirstBoot=yes</varname> should order themselves
1672 before <filename>first-boot-complete.target</filename> and pull in this passive target with
1673 <varname>Wants=</varname>. This ensures that in a case of an aborted first boot, these units will
1674 be re-run during the next system startup.</para>
1675
1676 <para>If the <varname>systemd.condition_first_boot=</varname> option is specified on the kernel
1677 command line (taking a boolean), it will override the result of this condition check, taking
1678 precedence over <filename>/etc/machine-id</filename> existence checks.</para>
1679
1680 <xi:include href="version-info.xml" xpointer="v244"/>
1681 </listitem>
1682 </varlistentry>
1683
1684 <varlistentry>
1685 <term><varname>ConditionPathExists=</varname></term>
1686
1687 <listitem><para>Check for the existence of a file. If the specified absolute path name does not exist,
1688 the condition will fail. If the absolute path name passed to
1689 <varname>ConditionPathExists=</varname> is prefixed with an exclamation mark
1690 (<literal>!</literal>), the test is negated, and the unit is only started if the path does not
1691 exist.</para>
1692
1693 <xi:include href="version-info.xml" xpointer="v244"/>
1694 </listitem>
1695 </varlistentry>
1696
1697 <varlistentry>
1698 <term><varname>ConditionPathExistsGlob=</varname></term>
1699
1700 <listitem><para><varname>ConditionPathExistsGlob=</varname> is similar to
1701 <varname>ConditionPathExists=</varname>, but checks for the existence of at least one file or
1702 directory matching the specified globbing pattern.</para>
1703
1704 <xi:include href="version-info.xml" xpointer="v244"/>
1705 </listitem>
1706 </varlistentry>
1707
1708 <varlistentry>
1709 <term><varname>ConditionPathIsDirectory=</varname></term>
1710
1711 <listitem><para><varname>ConditionPathIsDirectory=</varname> is similar to
1712 <varname>ConditionPathExists=</varname> but verifies that a certain path exists and is a
1713 directory.</para>
1714
1715 <xi:include href="version-info.xml" xpointer="v244"/>
1716 </listitem>
1717 </varlistentry>
1718
1719 <varlistentry>
1720 <term><varname>ConditionPathIsSymbolicLink=</varname></term>
1721
1722 <listitem><para><varname>ConditionPathIsSymbolicLink=</varname> is similar to
1723 <varname>ConditionPathExists=</varname> but verifies that a certain path exists and is a symbolic
1724 link.</para>
1725
1726 <xi:include href="version-info.xml" xpointer="v244"/>
1727 </listitem>
1728 </varlistentry>
1729
1730 <varlistentry>
1731 <term><varname>ConditionPathIsMountPoint=</varname></term>
1732
1733 <listitem><para><varname>ConditionPathIsMountPoint=</varname> is similar to
1734 <varname>ConditionPathExists=</varname> but verifies that a certain path exists and is a mount
1735 point.</para>
1736
1737 <xi:include href="version-info.xml" xpointer="v244"/>
1738 </listitem>
1739 </varlistentry>
1740
1741 <varlistentry>
1742 <term><varname>ConditionPathIsReadWrite=</varname></term>
1743
1744 <listitem><para><varname>ConditionPathIsReadWrite=</varname> is similar to
1745 <varname>ConditionPathExists=</varname> but verifies that the underlying file system is readable
1746 and writable (i.e. not mounted read-only).</para>
1747
1748 <xi:include href="version-info.xml" xpointer="v244"/>
1749 </listitem>
1750 </varlistentry>
1751
1752 <varlistentry>
1753 <term><varname>ConditionPathIsEncrypted=</varname></term>
1754
1755 <listitem><para><varname>ConditionPathIsEncrypted=</varname> is similar to
1756 <varname>ConditionPathExists=</varname> but verifies that the underlying file system's backing
1757 block device is encrypted using dm-crypt/LUKS. Note that this check does not cover ext4
1758 per-directory encryption, and only detects block level encryption. Moreover, if the specified path
1759 resides on a file system on top of a loopback block device, only encryption above the loopback device is
1760 detected. It is not detected whether the file system backing the loopback block device is encrypted.</para>
1761
1762 <xi:include href="version-info.xml" xpointer="v246"/>
1763 </listitem>
1764 </varlistentry>
1765
1766 <varlistentry>
1767 <term><varname>ConditionDirectoryNotEmpty=</varname></term>
1768
1769 <listitem><para><varname>ConditionDirectoryNotEmpty=</varname> is similar to
1770 <varname>ConditionPathExists=</varname> but verifies that a certain path exists and is a non-empty
1771 directory.</para>
1772
1773 <xi:include href="version-info.xml" xpointer="v244"/>
1774 </listitem>
1775 </varlistentry>
1776
1777 <varlistentry>
1778 <term><varname>ConditionFileNotEmpty=</varname></term>
1779
1780 <listitem><para><varname>ConditionFileNotEmpty=</varname> is similar to
1781 <varname>ConditionPathExists=</varname> but verifies that a certain path exists and refers to a
1782 regular file with a non-zero size.</para>
1783
1784 <xi:include href="version-info.xml" xpointer="v244"/>
1785 </listitem>
1786 </varlistentry>
1787
1788 <varlistentry>
1789 <term><varname>ConditionFileIsExecutable=</varname></term>
1790
1791 <listitem><para><varname>ConditionFileIsExecutable=</varname> is similar to
1792 <varname>ConditionPathExists=</varname> but verifies that a certain path exists, is a regular file,
1793 and marked executable.</para>
1794
1795 <xi:include href="version-info.xml" xpointer="v244"/>
1796 </listitem>
1797 </varlistentry>
1798
1799 <varlistentry>
1800 <term><varname>ConditionUser=</varname></term>
1801
1802 <listitem><para><varname>ConditionUser=</varname> takes a numeric <literal>UID</literal>, a UNIX
1803 user name, or the special value <literal>@system</literal>. This condition may be used to check
1804 whether the service manager is running as the given user. The special value
1805 <literal>@system</literal> can be used to check if the user id is within the system user
1806 range. This option is not useful for system services, as the system manager exclusively runs as the
1807 root user, and thus the test result is constant.</para>
1808
1809 <xi:include href="version-info.xml" xpointer="v244"/>
1810 </listitem>
1811 </varlistentry>
1812
1813 <varlistentry>
1814 <term><varname>ConditionGroup=</varname></term>
1815
1816 <listitem><para><varname>ConditionGroup=</varname> is similar to <varname>ConditionUser=</varname>
1817 but verifies that the service manager's real or effective group, or any of its auxiliary groups,
1818 match the specified group or GID. This setting does not support the special value
1819 <literal>@system</literal>.</para>
1820
1821 <xi:include href="version-info.xml" xpointer="v244"/>
1822 </listitem>
1823 </varlistentry>
1824
1825 <varlistentry>
1826 <term><varname>ConditionControlGroupController=</varname></term>
1827
1828 <listitem><para>Check whether given cgroup controllers (e.g. <literal>cpu</literal>) are available
1829 for use on the system or whether the legacy v1 cgroup or the modern v2 cgroup hierarchy is used.
1830 </para>
1831
1832 <para>Multiple controllers may be passed with a space separating them; in this case the condition
1833 will only pass if all listed controllers are available for use. Controllers unknown to systemd are
1834 ignored. Valid controllers are <literal>cpu</literal>, <literal>io</literal>,
1835 <literal>memory</literal>, and <literal>pids</literal>. Even if available in the kernel, a
1836 particular controller may not be available if it was disabled on the kernel command line with
1837 <varname>cgroup_disable=controller</varname>.</para>
1838
1839 <para>Alternatively, two special strings <literal>v1</literal> and <literal>v2</literal> may be
1840 specified (without any controller names). <literal>v2</literal> will pass if the unified v2 cgroup
1841 hierarchy is used, and <literal>v1</literal> will pass if the legacy v1 hierarchy or the hybrid
1842 hierarchy are used. Note that legacy or hybrid hierarchies have been deprecated. See
1843 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> for
1844 more information.</para>
1845
1846 <xi:include href="version-info.xml" xpointer="v244"/>
1847 </listitem>
1848 </varlistentry>
1849
1850 <varlistentry>
1851 <term><varname>ConditionMemory=</varname></term>
1852
1853 <listitem><para>Verify that the specified amount of system memory is available to the current
1854 system. Takes a memory size in bytes as argument, optionally prefixed with a comparison operator
1855 <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>=</literal> (or <literal>==</literal>),
1856 <literal>!=</literal> (or <literal>&lt;&gt;</literal>), <literal>&gt;=</literal>,
1857 <literal>&gt;</literal>. On bare-metal systems compares the amount of physical memory in the system
1858 with the specified size, adhering to the specified comparison operator. In containers compares the
1859 amount of memory assigned to the container instead.</para>
1860
1861 <xi:include href="version-info.xml" xpointer="v244"/>
1862 </listitem>
1863 </varlistentry>
1864
1865 <varlistentry>
1866 <term><varname>ConditionCPUs=</varname></term>
1867
1868 <listitem><para>Verify that the specified number of CPUs is available to the current system. Takes
1869 a number of CPUs as argument, optionally prefixed with a comparison operator
1870 <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>=</literal> (or <literal>==</literal>),
1871 <literal>!=</literal> (or <literal>&lt;&gt;</literal>), <literal>&gt;=</literal>,
1872 <literal>&gt;</literal>. Compares the number of CPUs in the CPU affinity mask configured of the
1873 service manager itself with the specified number, adhering to the specified comparison operator. On
1874 physical systems the number of CPUs in the affinity mask of the service manager usually matches the
1875 number of physical CPUs, but in special and virtual environments might differ. In particular, in
1876 containers the affinity mask usually matches the number of CPUs assigned to the container and not
1877 the physically available ones.</para>
1878
1879 <xi:include href="version-info.xml" xpointer="v244"/></listitem>
1880 </varlistentry>
1881
1882 <varlistentry>
1883 <term><varname>ConditionCPUFeature=</varname></term>
1884
1885 <listitem><para>Verify that a given CPU feature is available via the <literal>CPUID</literal>
1886 instruction. This condition only does something on i386 and x86-64 processors. On other
1887 processors it is assumed that the CPU does not support the given feature. It checks the leaves
1888 <literal>1</literal>, <literal>7</literal>, <literal>0x80000001</literal>, and
1889 <literal>0x80000007</literal>. Valid values are:
1890 <literal>fpu</literal>,
1891 <literal>vme</literal>,
1892 <literal>de</literal>,
1893 <literal>pse</literal>,
1894 <literal>tsc</literal>,
1895 <literal>msr</literal>,
1896 <literal>pae</literal>,
1897 <literal>mce</literal>,
1898 <literal>cx8</literal>,
1899 <literal>apic</literal>,
1900 <literal>sep</literal>,
1901 <literal>mtrr</literal>,
1902 <literal>pge</literal>,
1903 <literal>mca</literal>,
1904 <literal>cmov</literal>,
1905 <literal>pat</literal>,
1906 <literal>pse36</literal>,
1907 <literal>clflush</literal>,
1908 <literal>mmx</literal>,
1909 <literal>fxsr</literal>,
1910 <literal>sse</literal>,
1911 <literal>sse2</literal>,
1912 <literal>ht</literal>,
1913 <literal>pni</literal>,
1914 <literal>pclmul</literal>,
1915 <literal>monitor</literal>,
1916 <literal>ssse3</literal>,
1917 <literal>fma3</literal>,
1918 <literal>cx16</literal>,
1919 <literal>sse4_1</literal>,
1920 <literal>sse4_2</literal>,
1921 <literal>movbe</literal>,
1922 <literal>popcnt</literal>,
1923 <literal>aes</literal>,
1924 <literal>xsave</literal>,
1925 <literal>osxsave</literal>,
1926 <literal>avx</literal>,
1927 <literal>f16c</literal>,
1928 <literal>rdrand</literal>,
1929 <literal>bmi1</literal>,
1930 <literal>avx2</literal>,
1931 <literal>bmi2</literal>,
1932 <literal>rdseed</literal>,
1933 <literal>adx</literal>,
1934 <literal>sha_ni</literal>,
1935 <literal>syscall</literal>,
1936 <literal>rdtscp</literal>,
1937 <literal>lm</literal>,
1938 <literal>lahf_lm</literal>,
1939 <literal>abm</literal>,
1940 <literal>constant_tsc</literal>.</para>
1941
1942 <xi:include href="version-info.xml" xpointer="v248"/>
1943 </listitem>
1944 </varlistentry>
1945
1946 <varlistentry>
1947 <term><varname>ConditionOSRelease=</varname></term>
1948
1949 <listitem><para>Verify that a specific <literal>key=value</literal> pair is set in the host's
1950 <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
1951
1952 <para>Other than exact string matching (with <literal>=</literal> and <literal>!=</literal>),
1953 relative comparisons are supported for versioned parameters (e.g. <literal>VERSION_ID</literal>;
1954 with <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>==</literal>,
1955 <literal>&lt;&gt;</literal>, <literal>&gt;=</literal>, <literal>&gt;</literal>), and shell-style
1956 wildcard comparisons (<literal>*</literal>, <literal>?</literal>, <literal>[]</literal>) are
1957 supported with the <literal>$=</literal> (match) and <literal>!$=</literal> (non-match).</para>
1958
1959 <xi:include href="version-info.xml" xpointer="v249"/>
1960 </listitem>
1961 </varlistentry>
1962
1963 <varlistentry>
1964 <term><varname>ConditionMemoryPressure=</varname></term>
1965 <term><varname>ConditionCPUPressure=</varname></term>
1966 <term><varname>ConditionIOPressure=</varname></term>
1967
1968 <listitem><para>Verify that the overall system (memory, CPU or IO) pressure is below or equal to a threshold.
1969 This setting takes a threshold value as argument. It can be specified as a simple percentage value,
1970 suffixed with <literal>%</literal>, in which case the pressure will be measured as an average over the last
1971 five minutes before the attempt to start the unit is performed.
1972 Alternatively, the average timespan can also be specified using <literal>/</literal> as a separator, for
1973 example: <literal>10%/1min</literal>. The supported timespans match what the kernel provides, and are
1974 limited to <literal>10sec</literal>, <literal>1min</literal> and <literal>5min</literal>. The
1975 <literal>full</literal> PSI will be checked first, and if not found <literal>some</literal> will be
1976 checked. For more details, see the documentation on <ulink
1977 url="https://docs.kernel.org/accounting/psi.html">PSI (Pressure Stall Information)
1978 </ulink>.</para>
1979
1980 <para>Optionally, the threshold value can be prefixed with the slice unit under which the pressure will be checked,
1981 followed by a <literal>:</literal>. If the slice unit is not specified, the overall system pressure will be measured,
1982 instead of a particular cgroup's.</para>
1983
1984 <xi:include href="version-info.xml" xpointer="v250"/>
1985 </listitem>
1986 </varlistentry>
1987
1988 <varlistentry>
1989 <term><varname>AssertArchitecture=</varname></term>
1990 <term><varname>AssertVirtualization=</varname></term>
1991 <term><varname>AssertHost=</varname></term>
1992 <term><varname>AssertKernelCommandLine=</varname></term>
1993 <term><varname>AssertKernelVersion=</varname></term>
1994 <term><varname>AssertCredential=</varname></term>
1995 <term><varname>AssertEnvironment=</varname></term>
1996 <term><varname>AssertSecurity=</varname></term>
1997 <term><varname>AssertCapability=</varname></term>
1998 <term><varname>AssertACPower=</varname></term>
1999 <term><varname>AssertNeedsUpdate=</varname></term>
2000 <term><varname>AssertFirstBoot=</varname></term>
2001 <term><varname>AssertPathExists=</varname></term>
2002 <term><varname>AssertPathExistsGlob=</varname></term>
2003 <term><varname>AssertPathIsDirectory=</varname></term>
2004 <term><varname>AssertPathIsSymbolicLink=</varname></term>
2005 <term><varname>AssertPathIsMountPoint=</varname></term>
2006 <term><varname>AssertPathIsReadWrite=</varname></term>
2007 <term><varname>AssertPathIsEncrypted=</varname></term>
2008 <term><varname>AssertDirectoryNotEmpty=</varname></term>
2009 <term><varname>AssertFileNotEmpty=</varname></term>
2010 <term><varname>AssertFileIsExecutable=</varname></term>
2011 <term><varname>AssertUser=</varname></term>
2012 <term><varname>AssertGroup=</varname></term>
2013 <term><varname>AssertControlGroupController=</varname></term>
2014 <term><varname>AssertMemory=</varname></term>
2015 <term><varname>AssertCPUs=</varname></term>
2016 <term><varname>AssertCPUFeature=</varname></term>
2017 <term><varname>AssertOSRelease=</varname></term>
2018 <term><varname>AssertMemoryPressure=</varname></term>
2019 <term><varname>AssertCPUPressure=</varname></term>
2020 <term><varname>AssertIOPressure=</varname></term>
2021
2022 <listitem><para>Similar to the <varname>ConditionArchitecture=</varname>,
2023 <varname>ConditionVirtualization=</varname>, …, condition settings described above, these settings
2024 add assertion checks to the start-up of the unit. However, unlike the conditions settings, any
2025 assertion setting that is not met results in failure of the start job (which means this is logged
2026 loudly). Note that hitting a configured assertion does not cause the unit to enter the
2027 <literal>failed</literal> state (or in fact result in any state change of the unit), it affects
2028 only the job queued for it. Use assertion expressions for units that cannot operate when specific
2029 requirements are not met, and when this is something the administrator or user should look
2030 into.</para>
2031
2032 <xi:include href="version-info.xml" xpointer="v218"/>
2033 </listitem>
2034 </varlistentry>
2035 </variablelist>
2036 </refsect2>
2037 </refsect1>
2038
2039 <refsect1>
2040 <title>Mapping of unit properties to their inverses</title>
2041
2042 <para>Unit settings that create a relationship with a second unit usually show up
2043 in properties of both units, for example in <command>systemctl show</command>
2044 output. In some cases the name of the property is the same as the name of the
2045 configuration setting, but not always. This table lists the properties
2046 that are shown on two units which are connected through some dependency, and shows
2047 which property on "source" unit corresponds to which property on the "target" unit.
2048 </para>
2049
2050 <table>
2051 <title>
2052 "Forward" and "reverse" unit properties
2053 </title>
2054
2055 <tgroup cols='4'>
2056 <colspec colname='forward' />
2057 <colspec colname='reverse' />
2058 <colspec colname='fuse' />
2059 <colspec colname='ruse' />
2060 <thead>
2061 <row>
2062 <entry>"Forward" property</entry>
2063 <entry>"Reverse" property</entry>
2064 <entry namest='fuse' nameend='ruse' valign='middle'>Where used</entry>
2065 </row>
2066 </thead>
2067 <tbody>
2068 <row>
2069 <entry><varname>Before=</varname></entry>
2070 <entry><varname>After=</varname></entry>
2071 <entry morerows='1' namest='fuse' nameend='ruse' valign='middle'>[Unit] section</entry>
2072 </row>
2073 <row>
2074 <entry><varname>After=</varname></entry>
2075 <entry><varname>Before=</varname></entry>
2076 </row>
2077 <row>
2078 <entry><varname>Requires=</varname></entry>
2079 <entry><varname>RequiredBy=</varname></entry>
2080 <entry>[Unit] section</entry>
2081 <entry>[Install] section</entry>
2082 </row>
2083 <row>
2084 <entry><varname>Wants=</varname></entry>
2085 <entry><varname>WantedBy=</varname></entry>
2086 <entry>[Unit] section</entry>
2087 <entry>[Install] section</entry>
2088 </row>
2089 <row>
2090 <entry><varname>Upholds=</varname></entry>
2091 <entry><varname>UpheldBy=</varname></entry>
2092 <entry>[Unit] section</entry>
2093 <entry>[Install] section</entry>
2094 </row>
2095 <row>
2096 <entry><varname>PartOf=</varname></entry>
2097 <entry><varname>ConsistsOf=</varname></entry>
2098 <entry>[Unit] section</entry>
2099 <entry>an automatic property</entry>
2100 </row>
2101 <row>
2102 <entry><varname>BindsTo=</varname></entry>
2103 <entry><varname>BoundBy=</varname></entry>
2104 <entry>[Unit] section</entry>
2105 <entry>an automatic property</entry>
2106 </row>
2107 <row>
2108 <entry><varname>Requisite=</varname></entry>
2109 <entry><varname>RequisiteOf=</varname></entry>
2110 <entry>[Unit] section</entry>
2111 <entry>an automatic property</entry>
2112 </row>
2113 <row>
2114 <entry><varname>Conflicts=</varname></entry>
2115 <entry><varname>ConflictedBy=</varname></entry>
2116 <entry>[Unit] section</entry>
2117 <entry>an automatic property</entry>
2118 </row>
2119 <row>
2120 <entry><varname>Triggers=</varname></entry>
2121 <entry><varname>TriggeredBy=</varname></entry>
2122 <entry namest='fuse' nameend='ruse' valign='middle'>Automatic properties, see notes below</entry>
2123 </row>
2124 <row>
2125 <entry><varname>PropagatesReloadTo=</varname></entry>
2126 <entry><varname>ReloadPropagatedFrom=</varname></entry>
2127 <entry morerows='1' namest='fuse' nameend='ruse' valign='middle'>[Unit] section</entry>
2128 </row>
2129 <row>
2130 <entry><varname>ReloadPropagatedFrom=</varname></entry>
2131 <entry><varname>PropagatesReloadTo=</varname></entry>
2132 </row>
2133 <row>
2134 <entry><varname>PropagatesStopTo=</varname></entry>
2135 <entry><varname>StopPropagatedFrom=</varname></entry>
2136 <entry morerows='1' namest='fuse' nameend='ruse' valign='middle'>[Unit] section</entry>
2137 </row>
2138 <row>
2139 <entry><varname>StopPropagatedFrom=</varname></entry>
2140 <entry><varname>PropagatesStopTo=</varname></entry>
2141 </row>
2142 <row>
2143 <entry><varname>Following=</varname></entry>
2144 <entry>n/a</entry>
2145 <entry>An automatic property</entry>
2146 </row>
2147 </tbody>
2148 </tgroup>
2149 </table>
2150
2151 <para>Note: <varname>WantedBy=</varname>, <varname>RequiredBy=</varname>, and <varname>UpheldBy=</varname>
2152 are used in the [Install] section to create symlinks in <filename>.wants/</filename>,
2153 <filename>.requires/</filename>, and <filename>.upholds/</filename> directories. They cannot be used
2154 directly as a unit configuration setting.</para>
2155
2156 <para>Note: <varname>ConsistsOf=</varname>, <varname>BoundBy=</varname>,
2157 <varname>RequisiteOf=</varname>, <varname>ConflictedBy=</varname> are created
2158 implicitly along with their reverses and cannot be specified directly.</para>
2159
2160 <para>Note: <varname>Triggers=</varname> is created implicitly between a socket,
2161 path unit, or an automount unit, and the unit they activate. By default a unit
2162 with the same name is triggered, but this can be overridden using
2163 <varname>Sockets=</varname>, <varname>Service=</varname>, and <varname>Unit=</varname>
2164 settings. See
2165 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2166 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2167 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2168 and
2169 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
2170 for details. <varname>TriggeredBy=</varname> is created implicitly on the
2171 triggered unit.</para>
2172
2173 <para>Note: <varname>Following=</varname> is used to group device aliases and points to the
2174 "primary" device unit that systemd is using to track device state, usually corresponding to a
2175 sysfs path. It does not show up in the "target" unit.</para>
2176 </refsect1>
2177
2178 <refsect1>
2179 <title>[Install] Section Options</title>
2180
2181 <para>Unit files may include an [Install] section, which carries installation information for
2182 the unit. This section is not interpreted by
2183 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> during runtime; it is
2184 used by the <command>enable</command> and <command>disable</command> commands of the
2185 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool during
2186 installation of a unit.</para>
2187
2188 <variablelist class='unit-directives'>
2189 <varlistentry>
2190 <term><varname>Alias=</varname></term>
2191
2192 <listitem><para>A space-separated list of additional names this unit shall be installed under. The names listed
2193 here must have the same suffix (i.e. type) as the unit filename. This option may be specified more than once,
2194 in which case all listed names are used. At installation time, <command>systemctl enable</command> will create
2195 symlinks from these names to the unit filename. Note that not all unit types support such alias names, and this
2196 setting is not supported for them. Specifically, mount, slice, swap, and automount units do not support
2197 aliasing.</para>
2198
2199 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
2200 </varlistentry>
2201
2202 <varlistentry>
2203 <term><varname>WantedBy=</varname></term>
2204 <term><varname>RequiredBy=</varname></term>
2205 <term><varname>UpheldBy=</varname></term>
2206
2207 <listitem><para>This option may be used more than once, or a space-separated list of unit names may
2208 be given. A symbolic link is created in the <filename>.wants/</filename>, <filename>.requires/</filename>,
2209 or <filename>.upholds/</filename> directory of each of the listed units when this unit is installed
2210 by <command>systemctl enable</command>. This has the effect of a dependency of type
2211 <varname>Wants=</varname>, <varname>Requires=</varname>, or <varname>Upholds=</varname> being added
2212 from the listed unit to the current unit. See the description of the mentioned dependency types
2213 in the [Unit] section for details.</para>
2214
2215 <para>In case of template units listing non template units, the listing unit must have
2216 <varname>DefaultInstance=</varname> set, or <command>systemctl enable</command> must be called with
2217 an instance name. The instance (default or specified) will be added to the
2218 <filename>.wants/</filename>, <filename>.requires/</filename>, or <filename>.upholds/</filename>
2219 list of the listed unit. For example, <command>WantedBy=getty.target</command> in a service
2220 <filename>getty@.service</filename> will result in <command>systemctl enable getty@tty2.service</command>
2221 creating a <filename>getty.target.wants/getty@tty2.service</filename> link to
2222 <filename>getty@.service</filename>. This also applies to listing specific instances of templated
2223 units: this specific instance will gain the dependency. A template unit may also list a template
2224 unit, in which case a generic dependency will be added where each instance of the listing unit will
2225 have a dependency on an instance of the listed template with the same instance value. For example,
2226 <command>WantedBy=container@.target</command> in a service <filename>monitor@.service</filename> will
2227 result in <command>systemctl enable monitor@.service</command> creating a
2228 <filename>container@.target.wants/monitor@.service</filename> link to
2229 <filename>monitor@.service</filename>, which applies to all instances of
2230 <filename>container@.target</filename>.</para>
2231
2232 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
2233 </varlistentry>
2234
2235 <varlistentry>
2236 <term><varname>Also=</varname></term>
2237
2238 <listitem><para>Additional units to install/deinstall when
2239 this unit is installed/deinstalled. If the user requests
2240 installation/deinstallation of a unit with this option
2241 configured, <command>systemctl enable</command> and
2242 <command>systemctl disable</command> will automatically
2243 install/uninstall units listed in this option as well.</para>
2244
2245 <para>This option may be used more than once, or a
2246 space-separated list of unit names may be
2247 given.</para>
2248
2249 <xi:include href="version-info.xml" xpointer="v201"/></listitem>
2250 </varlistentry>
2251
2252 <varlistentry>
2253 <term><varname>DefaultInstance=</varname></term>
2254
2255 <listitem><para>In template unit files, this specifies for
2256 which instance the unit shall be enabled if the template is
2257 enabled without any explicitly set instance. This option has
2258 no effect in non-template unit files. The specified string
2259 must be usable as instance identifier.</para>
2260
2261 <xi:include href="version-info.xml" xpointer="v215"/></listitem>
2262 </varlistentry>
2263 </variablelist>
2264
2265 <para>The following specifiers are interpreted in the Install section:
2266 %a, %b, %B, %g, %G, %H, %i, %j, %l, %m, %n, %N, %o, %p, %u, %U, %v, %w, %W, %%.
2267 For their meaning see the next section.</para>
2268 </refsect1>
2269
2270 <refsect1>
2271 <title>Specifiers</title>
2272
2273 <para>Many settings resolve specifiers which may be used to write
2274 generic unit files referring to runtime or unit parameters that
2275 are replaced when the unit files are loaded. Specifiers must be known
2276 and resolvable for the setting to be valid. The following
2277 specifiers are understood:</para>
2278
2279 <table class='specifiers'>
2280 <title>Specifiers available in unit files</title>
2281 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
2282 <colspec colname="spec" />
2283 <colspec colname="mean" />
2284 <colspec colname="detail" />
2285 <thead>
2286 <row>
2287 <entry>Specifier</entry>
2288 <entry>Meaning</entry>
2289 <entry>Details</entry>
2290 </row>
2291 </thead>
2292 <tbody>
2293 <row>
2294 <!-- We do not use the common definition from standard-specifiers.xml here since it includes a
2295 reference onto our own man page, which would make the rendered version self-referential. -->
2296 <entry><literal>%a</literal></entry>
2297 <entry>Architecture</entry>
2298 <entry>A short string identifying the architecture of the local system. A string such as <constant>x86</constant>, <constant>x86-64</constant> or <constant>arm64</constant>. See the architectures defined for <varname>ConditionArchitecture=</varname> above for a full list.</entry>
2299 </row>
2300 <xi:include href="standard-specifiers.xml" xpointer="A"/>
2301 <xi:include href="standard-specifiers.xml" xpointer="b"/>
2302 <xi:include href="standard-specifiers.xml" xpointer="B"/>
2303 <row>
2304 <entry><literal>%C</literal></entry>
2305 <entry>Cache directory root</entry>
2306 <entry>This is either <filename>/var/cache</filename> (for the system manager) or the path <literal>$XDG_CACHE_HOME</literal> resolves to (for user managers).</entry>
2307 </row>
2308 <row>
2309 <entry><literal>%d</literal></entry>
2310 <entry>Credentials directory</entry>
2311 <entry>This is the value of the <literal>$CREDENTIALS_DIRECTORY</literal> environment variable if available. See section "Credentials" in <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
2312 </row>
2313 <row>
2314 <entry><literal>%D</literal></entry>
2315 <entry>Shared data directory</entry>
2316 <entry>This is either <filename>/usr/share/</filename> (for the system manager) or the path <literal>$XDG_DATA_HOME</literal> resolves to (for user managers).</entry>
2317 </row>
2318 <row>
2319 <entry><literal>%E</literal></entry>
2320 <entry>Configuration directory root</entry>
2321 <entry>This is either <filename>/etc/</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to (for user managers).</entry>
2322 </row>
2323 <row>
2324 <entry><literal>%f</literal></entry>
2325 <entry>Unescaped filename</entry>
2326 <entry>This is either the unescaped instance name (if applicable) with <filename>/</filename> prepended (if applicable), or the unescaped prefix name prepended with <filename>/</filename>. This implements unescaping according to the rules for escaping absolute file system paths discussed above.</entry>
2327 </row>
2328 <row>
2329 <entry><literal>%g</literal></entry>
2330 <entry>User group</entry>
2331 <entry>This is the name of the group running the service manager instance. In case of the system manager this resolves to <literal>root</literal>.</entry>
2332 </row>
2333 <row>
2334 <entry><literal>%G</literal></entry>
2335 <entry>User GID</entry>
2336 <entry>This is the numeric GID of the user running the service manager instance. In case of the system manager this resolves to <literal>0</literal>.</entry>
2337 </row>
2338 <row>
2339 <entry><literal>%h</literal></entry>
2340 <entry>User home directory</entry>
2341 <entry>This is the home directory of the <emphasis>user running the service manager instance</emphasis>. In case of the system manager this resolves to <literal>/root</literal>.
2342
2343 Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry>
2344 </row>
2345 <row>
2346 <!-- We do not use the common definition from standard-specifiers.xml here since we want a
2347 slightly more verbose explanation here, referring to the reload cycle. -->
2348 <entry><literal>%H</literal></entry>
2349 <entry>Host name</entry>
2350 <entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry>
2351 </row>
2352 <row>
2353 <entry><literal>%i</literal></entry>
2354 <entry>Instance name</entry>
2355 <entry>For instantiated units this is the string between the first <literal>@</literal> character and the type suffix. Empty for non-instantiated units.</entry>
2356 </row>
2357 <row>
2358 <entry><literal>%I</literal></entry>
2359 <entry>Unescaped instance name</entry>
2360 <entry>Same as <literal>%i</literal>, but with escaping undone.</entry>
2361 </row>
2362 <row>
2363 <entry><literal>%j</literal></entry>
2364 <entry>Final component of the prefix</entry>
2365 <entry>This is the string between the last <literal>-</literal> and the end of the prefix name. If there is no <literal>-</literal>, this is the same as <literal>%p</literal>.</entry>
2366 </row>
2367 <row>
2368 <entry><literal>%J</literal></entry>
2369 <entry>Unescaped final component of the prefix</entry>
2370 <entry>Same as <literal>%j</literal>, but with escaping undone.</entry>
2371 </row>
2372 <row>
2373 <entry><literal>%l</literal></entry>
2374 <!-- We do not use the common definition from standard-specifiers.xml here since we want a
2375 slightly more verbose explanation here, referring to the reload cycle. -->
2376 <entry>Short host name</entry>
2377 <entry>The hostname of the running system at the point in time the unit configuration is loaded, truncated at the first dot to remove any domain component.</entry>
2378 </row>
2379 <row>
2380 <entry><literal>%L</literal></entry>
2381 <entry>Log directory root</entry>
2382 <entry>This is either <filename>/var/log</filename> (for the system manager) or the path <varname>$XDG_STATE_HOME</varname> resolves to with <filename index="false">/log</filename> appended (for user managers).</entry>
2383 </row>
2384 <xi:include href="standard-specifiers.xml" xpointer="m"/>
2385 <xi:include href="standard-specifiers.xml" xpointer="M"/>
2386 <row>
2387 <entry><literal>%n</literal></entry>
2388 <entry>Full unit name</entry>
2389 <entry></entry>
2390 </row>
2391 <row>
2392 <entry><literal>%N</literal></entry>
2393 <entry>Full unit name</entry>
2394 <entry>Same as <literal>%n</literal>, but with the type suffix removed.</entry>
2395 </row>
2396 <xi:include href="standard-specifiers.xml" xpointer="o"/>
2397 <row>
2398 <entry><literal>%p</literal></entry>
2399 <entry>Prefix name</entry>
2400 <entry>For instantiated units, this refers to the string before the first <literal>@</literal> character of the unit name. For non-instantiated units, same as <literal>%N</literal>.</entry>
2401 </row>
2402 <row>
2403 <entry><literal>%P</literal></entry>
2404 <entry>Unescaped prefix name</entry>
2405 <entry>Same as <literal>%p</literal>, but with escaping undone.</entry>
2406 </row>
2407 <row>
2408 <!-- We do not use the common definition from standard-specifiers.xml here since we want a
2409 slightly more verbose explanation here, referring to the reload cycle. -->
2410 <entry><literal>%q</literal></entry>
2411 <entry>Pretty host name</entry>
2412 <entry>The pretty hostname of the running system at the point in time the unit configuration is loaded, as read from the <varname>PRETTY_HOSTNAME=</varname> field of <filename>/etc/machine-info</filename>. If not set, resolves to the short hostname. See <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
2413 </row>
2414 <row>
2415 <entry><literal>%s</literal></entry>
2416 <entry>User shell</entry>
2417 <entry>This is the shell of the user running the service manager instance.</entry>
2418 </row>
2419 <row>
2420 <entry><literal>%S</literal></entry>
2421 <entry>State directory root</entry>
2422 <entry>This is either <filename>/var/lib</filename> (for the system manager) or the path <varname>$XDG_STATE_HOME</varname> resolves to (for user managers).</entry>
2423 </row>
2424 <row>
2425 <entry><literal>%t</literal></entry>
2426 <entry>Runtime directory root</entry>
2427 <entry>This is either <filename>/run/</filename> (for the system manager) or the path <literal>$XDG_RUNTIME_DIR</literal> resolves to (for user managers).</entry>
2428 </row>
2429 <xi:include href="standard-specifiers.xml" xpointer="T"/>
2430 <row>
2431 <entry><literal>%u</literal></entry>
2432 <entry>User name</entry>
2433 <entry>This is the name of the <emphasis>user running the service manager instance</emphasis>. In case of the system manager this resolves to <literal>root</literal>.
2434
2435 Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry>
2436 </row>
2437 <row>
2438 <entry><literal>%U</literal></entry>
2439 <entry>User UID</entry>
2440 <entry>This is the numeric UID of the <emphasis>user running the service manager instance</emphasis>. In case of the system manager this resolves to <literal>0</literal>.
2441
2442 Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry>
2443 </row>
2444 <xi:include href="standard-specifiers.xml" xpointer="v"/>
2445 <xi:include href="standard-specifiers.xml" xpointer="V"/>
2446 <xi:include href="standard-specifiers.xml" xpointer="w"/>
2447 <xi:include href="standard-specifiers.xml" xpointer="W"/>
2448 <row>
2449 <entry><literal>%y</literal></entry>
2450 <entry>The path to the fragment</entry>
2451 <entry>This is the path where the main part of the unit file is located. For linked unit files, the real path outside of the unit search directories is used. For units that don't have a fragment file, this specifier will raise an error.</entry>
2452 </row>
2453 <row>
2454 <entry><literal>%Y</literal></entry>
2455 <entry>The directory of the fragment</entry>
2456 <entry>This is the directory part of <literal>%y</literal>.</entry>
2457 </row>
2458 <xi:include href="standard-specifiers.xml" xpointer="percent"/>
2459 </tbody>
2460 </tgroup>
2461 </table>
2462 </refsect1>
2463
2464 <refsect1>
2465 <title>Examples</title>
2466
2467 <example>
2468 <title>Allowing units to be enabled</title>
2469
2470 <para>The following snippet (highlighted) allows a unit (e.g.
2471 <filename>foo.service</filename>) to be enabled via
2472 <command>systemctl enable</command>:</para>
2473
2474 <programlisting>[Unit]
2475 Description=Foo
2476
2477 [Service]
2478 ExecStart=/usr/sbin/foo-daemon
2479
2480 <emphasis>[Install]</emphasis>
2481 <emphasis>WantedBy=multi-user.target</emphasis></programlisting>
2482
2483 <para>After running <command>systemctl enable</command>, a
2484 symlink
2485 <filename index="false">/etc/systemd/system/multi-user.target.wants/foo.service</filename>
2486 linking to the actual unit will be created. It tells systemd to
2487 pull in the unit when starting
2488 <filename>multi-user.target</filename>. The inverse
2489 <command>systemctl disable</command> will remove that symlink
2490 again.</para>
2491 </example>
2492
2493 <example>
2494 <title>Overriding vendor settings</title>
2495
2496 <para>There are two methods of overriding vendor settings in
2497 unit files: copying the unit file from
2498 <filename>/usr/lib/systemd/system</filename> to
2499 <filename>/etc/systemd/system</filename> and modifying the
2500 chosen settings. Alternatively, one can create a directory named
2501 <filename><replaceable>unit</replaceable>.d/</filename> within
2502 <filename>/etc/systemd/system</filename> and place a drop-in
2503 file <filename><replaceable>name</replaceable>.conf</filename>
2504 there that only changes the specific settings one is interested
2505 in. Note that multiple such drop-in files are read if
2506 present, processed in lexicographic order of their filename.</para>
2507
2508 <para>The advantage of the first method is that one easily
2509 overrides the complete unit, the vendor unit is not parsed at
2510 all anymore. It has the disadvantage that improvements to the
2511 unit file by the vendor are not automatically incorporated on
2512 updates.</para>
2513
2514 <para>The advantage of the second method is that one only
2515 overrides the settings one specifically wants, where updates to
2516 the unit by the vendor automatically apply. This has the
2517 disadvantage that some future updates by the vendor might be
2518 incompatible with the local changes.</para>
2519
2520 <para>This also applies for user instances of systemd, but with
2521 different locations for the unit files. See the section on unit
2522 load paths for further details.</para>
2523
2524 <para>Suppose there is a vendor-supplied unit
2525 <filename>/usr/lib/systemd/system/httpd.service</filename> with
2526 the following contents:</para>
2527
2528 <programlisting>[Unit]
2529 Description=Some HTTP server
2530 After=remote-fs.target sqldb.service
2531 Requires=sqldb.service
2532 AssertPathExists=/srv/webserver
2533
2534 [Service]
2535 Type=notify
2536 ExecStart=/usr/sbin/some-fancy-httpd-server
2537 Nice=5
2538
2539 [Install]
2540 WantedBy=multi-user.target</programlisting>
2541
2542 <para>Now one wants to change some settings as an administrator:
2543 firstly, in the local setup, <filename>/srv/webserver</filename>
2544 might not exist, because the HTTP server is configured to use
2545 <filename>/srv/www</filename> instead. Secondly, the local
2546 configuration makes the HTTP server also depend on a memory
2547 cache service, <filename>memcached.service</filename>, that
2548 should be pulled in (<varname>Requires=</varname>) and also be
2549 ordered appropriately (<varname>After=</varname>). Thirdly, in
2550 order to harden the service a bit more, the administrator would
2551 like to set the <varname>PrivateTmp=</varname> setting (see
2552 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
2553 for details). And lastly, the administrator would like to reset
2554 the niceness of the service to its default value of 0.</para>
2555
2556 <para>The first possibility is to copy the unit file to
2557 <filename>/etc/systemd/system/httpd.service</filename> and
2558 change the chosen settings:</para>
2559
2560 <programlisting>[Unit]
2561 Description=Some HTTP server
2562 After=remote-fs.target sqldb.service <emphasis>memcached.service</emphasis>
2563 Requires=sqldb.service <emphasis>memcached.service</emphasis>
2564 AssertPathExists=<emphasis>/srv/www</emphasis>
2565
2566 [Service]
2567 Type=notify
2568 ExecStart=/usr/sbin/some-fancy-httpd-server
2569 <emphasis>Nice=0</emphasis>
2570 <emphasis>PrivateTmp=yes</emphasis>
2571
2572 [Install]
2573 WantedBy=multi-user.target</programlisting>
2574
2575 <para>Alternatively, the administrator could create a drop-in
2576 file
2577 <filename>/etc/systemd/system/httpd.service.d/local.conf</filename>
2578 with the following contents:</para>
2579
2580 <programlisting>[Unit]
2581 After=memcached.service
2582 Requires=memcached.service
2583 # Reset all assertions and then re-add the condition we want
2584 AssertPathExists=
2585 AssertPathExists=/srv/www
2586
2587 [Service]
2588 Nice=0
2589 PrivateTmp=yes</programlisting>
2590
2591 <para>Note that for drop-in files, if one wants to remove
2592 entries from a setting that is parsed as a list (and is not a
2593 dependency), such as <varname>AssertPathExists=</varname> (or
2594 e.g. <varname>ExecStart=</varname> in service units), one needs
2595 to first clear the list before re-adding all entries except the
2596 one that is to be removed. Dependencies (<varname>After=</varname>, etc.)
2597 cannot be reset to an empty list, so dependencies can only be
2598 added in drop-ins. If you want to remove dependencies, you have
2599 to override the entire unit.</para>
2600
2601 </example>
2602
2603 <example>
2604 <title>Top level drop-ins with template units</title>
2605
2606 <para>Top level per-type drop-ins can be used to change some aspect of
2607 all units of a particular type. For example, by creating the
2608 <filename index='false'>/etc/systemd/system/service.d/</filename>
2609 directory with a drop-in file, the contents of the drop-in file can be
2610 applied to all service units. We can take this further by having the
2611 top-level drop-in instantiate a secondary helper unit. Consider for
2612 example the following set of units and drop-in files where we install
2613 an <varname>OnFailure=</varname> dependency for all service units.</para>
2614
2615 <para>
2616 <filename index='false'>/etc/systemd/system/failure-handler@.service</filename>:</para>
2617
2618 <programlisting>[Unit]
2619 Description=My failure handler for %i
2620
2621 [Service]
2622 Type=oneshot
2623 # Perform some special action for when %i exits unexpectedly.
2624 ExecStart=/usr/sbin/myfailurehandler %i
2625 </programlisting>
2626
2627 <para>We can then add an instance of
2628 <filename index='false'>failure-handler@.service</filename> as an
2629 <varname>OnFailure=</varname> dependency for all service units.</para>
2630
2631 <para>
2632 <filename index='false'>/etc/systemd/system/service.d/10-all.conf</filename>:</para>
2633
2634 <programlisting>[Unit]
2635 OnFailure=failure-handler@%N.service
2636 </programlisting>
2637
2638 <para>Now, after running <command>systemctl daemon-reload</command> all
2639 services will have acquired an <varname>OnFailure=</varname> dependency on
2640 <filename index='false'>failure-handler@%N.service</filename>. The
2641 template instance units will also have gained the dependency which results
2642 in the creation of a recursive dependency chain. systemd will try to detect
2643 these recursive dependency chains where a template unit directly and
2644 recursively depends on itself and will remove such dependencies
2645 automatically if it finds them. If systemd doesn't detect the recursive
2646 dependency chain, we can break the chain ourselves by disabling the drop-in
2647 for the template instance units via a symlink to
2648 <filename index='false'>/dev/null</filename>:</para>
2649
2650 <programlisting>
2651 <command>mkdir /etc/systemd/system/failure-handler@.service.d/</command>
2652 <command>ln -s /dev/null /etc/systemd/system/failure-handler@.service.d/10-all.conf</command>
2653 <command>systemctl daemon-reload</command>
2654 </programlisting>
2655
2656 <para>This ensures that if a <filename index='false'>failure-handler@.service</filename> instance fails it will not trigger an instance named
2657 <filename index='false'>failure-handler@failure-handler.service</filename>.</para>
2658
2659 </example>
2660
2661 </refsect1>
2662
2663 <refsect1>
2664 <title>See Also</title>
2665 <para><simplelist type="inline">
2666 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
2667 <member><citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
2668 <member><citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2669 <member><citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
2670 <member><citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2671 <member><citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2672 <member><citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2673 <member><citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2674 <member><citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2675 <member><citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2676 <member><citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2677 <member><citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2678 <member><citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2679 <member><citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2680 <member><citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
2681 <member><citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
2682 <member><citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
2683 <member><citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
2684 <member><citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
2685 <member><citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
2686 </simplelist></para>
2687 </refsect1>
2688
2689 </refentry>