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