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