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