]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.unit.xml
Merge pull request #4509 from keszybz/foreach-word-quoted
[thirdparty/systemd.git] / man / systemd.unit.xml
1 <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % entities SYSTEM "custom-entities.ent" >
5 %entities;
6 ]>
7
8 <!--
9 This file is part of systemd.
10
11 Copyright 2010 Lennart Poettering
12
13 systemd is free software; you can redistribute it and/or modify it
14 under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
17
18 systemd is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public License
24 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 -->
26
27 <refentry id="systemd.unit">
28
29 <refentryinfo>
30 <title>systemd.unit</title>
31 <productname>systemd</productname>
32
33 <authorgroup>
34 <author>
35 <contrib>Developer</contrib>
36 <firstname>Lennart</firstname>
37 <surname>Poettering</surname>
38 <email>lennart@poettering.net</email>
39 </author>
40 </authorgroup>
41 </refentryinfo>
42
43 <refmeta>
44 <refentrytitle>systemd.unit</refentrytitle>
45 <manvolnum>5</manvolnum>
46 </refmeta>
47
48 <refnamediv>
49 <refname>systemd.unit</refname>
50 <refpurpose>Unit configuration</refpurpose>
51 </refnamediv>
52
53 <refsynopsisdiv>
54 <para><filename><replaceable>service</replaceable>.service</filename>,
55 <filename><replaceable>socket</replaceable>.socket</filename>,
56 <filename><replaceable>device</replaceable>.device</filename>,
57 <filename><replaceable>mount</replaceable>.mount</filename>,
58 <filename><replaceable>automount</replaceable>.automount</filename>,
59 <filename><replaceable>swap</replaceable>.swap</filename>,
60 <filename><replaceable>target</replaceable>.target</filename>,
61 <filename><replaceable>path</replaceable>.path</filename>,
62 <filename><replaceable>timer</replaceable>.timer</filename>,
63 <filename><replaceable>slice</replaceable>.slice</filename>,
64 <filename><replaceable>scope</replaceable>.scope</filename></para>
65
66 <para><literallayout><filename>/etc/systemd/system/*</filename>
67 <filename>/run/systemd/system/*</filename>
68 <filename>/usr/lib/systemd/system/*</filename>
69 <filename></filename>
70 </literallayout></para>
71
72 <para><literallayout><filename>~/.config/systemd/user/*</filename>
73 <filename>/etc/systemd/user/*</filename>
74 <filename>$XDG_RUNTIME_DIR/systemd/user/*</filename>
75 <filename>/run/systemd/user/*</filename>
76 <filename>~/.local/share/systemd/user/*</filename>
77 <filename>/usr/lib/systemd/user/*</filename>
78 <filename></filename>
79 </literallayout></para>
80 </refsynopsisdiv>
81
82 <refsect1>
83 <title>Description</title>
84
85 <para>A unit configuration file encodes information about a
86 service, a socket, a device, a mount point, an automount point, a
87 swap file or partition, a start-up target, a watched file system
88 path, a timer controlled and supervised by
89 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
90 a resource management slice or
91 a group of externally created processes. The syntax is inspired by
92 <ulink
93 url="http://standards.freedesktop.org/desktop-entry-spec/latest/">XDG
94 Desktop Entry Specification</ulink> <filename>.desktop</filename>
95 files, which are in turn inspired by Microsoft Windows
96 <filename>.ini</filename> files.</para>
97
98 <para>This man page lists the common configuration options of all
99 the unit types. These options need to be configured in the [Unit]
100 or [Install] sections of the unit files.</para>
101
102 <para>In addition to the generic [Unit] and [Install] sections
103 described here, each unit may have a type-specific section, e.g.
104 [Service] for a service unit. See the respective man pages for
105 more information:
106 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
107 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
108 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
109 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
110 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
111 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
112 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
113 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
114 <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
115 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
116 <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
117 </para>
118
119 <para>Various settings are allowed to be specified more than once,
120 in which case the interpretation depends on the setting. Often,
121 multiple settings form a list, and setting to an empty value
122 "resets", which means that previous assignments are ignored. When
123 this is allowed, it is mentioned in the description of the
124 setting. Note that using multiple assignments to the same value
125 makes the unit file incompatible with parsers for the XDG
126 <filename>.desktop</filename> file format.</para>
127
128 <para>Unit files are loaded from a set of paths determined during
129 compilation, described in the next section.</para>
130
131 <para>Unit files may contain additional options on top of those
132 listed here. If systemd encounters an unknown option, it will
133 write a warning log message but continue loading the unit. If an
134 option or section name is prefixed with <option>X-</option>, it is
135 ignored completely by systemd. Options within an ignored section
136 do not need the prefix. Applications may use this to include
137 additional information in the unit files.</para>
138
139 <para>Boolean arguments used in unit files can be written in
140 various formats. For positive settings the strings
141 <option>1</option>, <option>yes</option>, <option>true</option>
142 and <option>on</option> are equivalent. For negative settings, the
143 strings <option>0</option>, <option>no</option>,
144 <option>false</option> and <option>off</option> are
145 equivalent.</para>
146
147 <para>Time span values encoded in unit files can be written in various formats. A stand-alone
148 number specifies a time in seconds. If suffixed with a time unit, the unit is honored. A
149 concatenation of multiple values with units is supported, in which case the values are added
150 up. Example: <literal>50</literal> refers to 50 seconds; <literal>2min 200ms</literal> refers to
151 2 minutes and 200 milliseconds, i.e. 120200 ms. The following time units are understood:
152 <literal>s</literal>, <literal>min</literal>, <literal>h</literal>, <literal>d</literal>,
153 <literal>w</literal>, <literal>ms</literal>, <literal>us</literal>. For details see
154 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
155
156 <para>Empty lines and lines starting with <literal>#</literal> or <literal>;</literal> are
157 ignored. This may be used for commenting. Lines ending in a backslash are concatenated with the
158 following line while reading and the backslash is replaced by a space character. This may be
159 used to wrap long lines.</para>
160
161 <para>Units can be aliased (have an alternative name), by creating a symlink from the new name
162 to the existing name in one of the unit search paths. For example,
163 <filename>systemd-networkd.service</filename> has the alias
164 <filename>dbus-org.freedesktop.network1.service</filename>, created during installation as the
165 symlink <filename>/usr/lib/systemd/system/dbus-org.freedesktop.network1.service</filename>. In
166 addition, unit files may specify aliases through the <varname>Alias=</varname> directive in the
167 [Install] section; those aliases are only effective when the unit is enabled. When the unit is
168 enabled, symlinks will be created for those names, and removed when the unit is disabled. For
169 example, <filename>reboot.target</filename> specifies
170 <varname>Alias=ctrl-alt-del.target</varname>, so when enabled it will be invoked whenever
171 CTRL+ALT+DEL is pressed. Alias names may be used in commands like <command>enable</command>,
172 <command>disable</command>, <command>start</command>, <command>stop</command>,
173 <command>status</command>, …, and in unit dependency directives <varname>Wants=</varname>,
174 <varname>Requires=</varname>, <varname>Before=</varname>, <varname>After=</varname>, …, with the
175 limitation that aliases specified through <varname>Alias=</varname> are only effective when the
176 unit is enabled. Aliases cannot be used with the <command>preset</command> command.</para>
177
178 <para>Along with a unit file <filename>foo.service</filename>, the directory
179 <filename>foo.service.wants/</filename> may exist. All unit files symlinked from such a
180 directory are implicitly added as dependencies of type <varname>Wants=</varname> to the unit.
181 This is useful to hook units into the start-up of other units, without having to modify their
182 unit files. For details about the semantics of <varname>Wants=</varname>, see below. The
183 preferred way to create symlinks in the <filename>.wants/</filename> directory of a unit file is
184 with the <command>enable</command> command of the
185 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
186 tool which reads information from the [Install] section of unit files (see below). A similar
187 functionality exists for <varname>Requires=</varname> type dependencies as well, the directory
188 suffix is <filename>.requires/</filename> in this case.</para>
189
190 <para>Along with a unit file <filename>foo.service</filename>, a "drop-in" directory
191 <filename>foo.service.d/</filename> may exist. All files with the suffix
192 <literal>.conf</literal> from this directory will be parsed after the file itself is
193 parsed. This is useful to alter or add configuration settings for a unit, without having to
194 modify unit files. Each drop-in file must have appropriate section headers. Note that for
195 instantiated units, this logic will first look for the instance <literal>.d/</literal>
196 subdirectory and read its <literal>.conf</literal> files, followed by the template
197 <literal>.d/</literal> subdirectory and the <literal>.conf</literal> files there. Also note that
198 settings from the <literal>[Install]</literal> section are not honored in drop-in unit files,
199 and have no effect.</para>
200
201 <para>In addition to <filename>/etc/systemd/system</filename>, the drop-in <literal>.d</literal>
202 directories for system services can be placed in <filename>/usr/lib/systemd/system</filename> or
203 <filename>/run/systemd/system</filename> directories. Drop-in files in <filename>/etc</filename>
204 take precedence over those in <filename>/run</filename> which in turn take precedence over those
205 in <filename>/usr/lib</filename>. Drop-in files under any of these directories take precedence
206 over unit files wherever located.</para>
207
208 <!-- Note that we do not document .include here, as we consider it mostly obsolete, and want
209 people to use .d/ drop-ins instead. -->
210
211 <para>Some unit names reflect paths existing in the file system
212 namespace. Example: a device unit
213 <filename>dev-sda.device</filename> refers to a device with the
214 device node <filename noindex='true'>/dev/sda</filename> in the
215 file system namespace. If this applies, a special way to escape
216 the path name is used, so that the result is usable as part of a
217 filename. Basically, given a path, "/" is replaced by "-", and all
218 other characters which are not ASCII alphanumerics are replaced by
219 C-style "\x2d" escapes (except that "_" is never replaced and "."
220 is only replaced when it would be the first character in the
221 escaped path). The root directory "/" is encoded as single dash,
222 while otherwise the initial and ending "/" are removed from all
223 paths during transformation. This escaping is reversible. Properly
224 escaped paths can be generated using the
225 <citerefentry><refentrytitle>systemd-escape</refentrytitle><manvolnum>1</manvolnum></citerefentry>
226 command.</para>
227
228 <para>Optionally, units may be instantiated from a
229 template file at runtime. This allows creation of
230 multiple units from a single configuration file. If
231 systemd looks for a unit configuration file, it will
232 first search for the literal unit name in the
233 file system. If that yields no success and the unit
234 name contains an <literal>@</literal> character, systemd will look for a
235 unit template that shares the same name but with the
236 instance string (i.e. the part between the <literal>@</literal> character
237 and the suffix) removed. Example: if a service
238 <filename>getty@tty3.service</filename> is requested
239 and no file by that name is found, systemd will look
240 for <filename>getty@.service</filename> and
241 instantiate a service from that configuration file if
242 it is found.</para>
243
244 <para>To refer to the instance string from within the
245 configuration file you may use the special <literal>%i</literal>
246 specifier in many of the configuration options. See below for
247 details.</para>
248
249 <para>If a unit file is empty (i.e. has the file size 0) or is
250 symlinked to <filename>/dev/null</filename>, its configuration
251 will not be loaded and it appears with a load state of
252 <literal>masked</literal>, and cannot be activated. Use this as an
253 effective way to fully disable a unit, making it impossible to
254 start it even manually.</para>
255
256 <para>The unit file format is covered by the
257 <ulink
258 url="http://www.freedesktop.org/wiki/Software/systemd/InterfaceStabilityPromise">Interface
259 Stability Promise</ulink>.</para>
260
261 </refsect1>
262
263 <refsect1>
264 <title>Automatic Dependencies</title>
265
266 <para>Note that while systemd offers a flexible dependency system
267 between units it is recommended to use this functionality only
268 sparingly and instead rely on techniques such as bus-based or
269 socket-based activation which make dependencies implicit,
270 resulting in a both simpler and more flexible system.</para>
271
272 <para>A number of unit dependencies are automatically established,
273 depending on unit configuration. On top of that, for units with
274 <varname>DefaultDependencies=yes</varname> (the default) a couple
275 of additional dependencies are added. The precise effect of
276 <varname>DefaultDependencies=yes</varname> depends on the unit
277 type (see below).</para>
278
279 <para>If <varname>DefaultDependencies=yes</varname> is set, units
280 that are referenced by other units of type
281 <filename>.target</filename> via a <varname>Wants=</varname> or
282 <varname>Requires=</varname> dependency might automatically gain
283 an <varname>Before=</varname> dependency too. See
284 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>
285 for details.</para>
286 </refsect1>
287
288 <refsect1>
289 <title>Unit File Load Path</title>
290
291 <para>Unit files are loaded from a set of paths determined during
292 compilation, described in the two tables below. Unit files found
293 in directories listed earlier override files with the same name in
294 directories lower in the list.</para>
295
296 <para>When the variable <varname>$SYSTEMD_UNIT_PATH</varname> is set,
297 the contents of this variable overrides the unit load path. If
298 <varname>$SYSTEMD_UNIT_PATH</varname> ends with an empty component
299 (<literal>:</literal>), the usual unit load path will be appended
300 to the contents of the variable.</para>
301
302 <table>
303 <title>
304 Load path when running in system mode (<option>--system</option>).
305 </title>
306
307 <tgroup cols='2'>
308 <colspec colname='path' />
309 <colspec colname='expl' />
310 <thead>
311 <row>
312 <entry>Path</entry>
313 <entry>Description</entry>
314 </row>
315 </thead>
316 <tbody>
317 <row>
318 <entry><filename>/etc/systemd/system</filename></entry>
319 <entry>Local configuration</entry>
320 </row>
321 <row>
322 <entry><filename>/run/systemd/system</filename></entry>
323 <entry>Runtime units</entry>
324 </row>
325 <row>
326 <entry><filename>/usr/lib/systemd/system</filename></entry>
327 <entry>Units of installed packages</entry>
328 </row>
329 </tbody>
330 </tgroup>
331 </table>
332
333 <table>
334 <title>
335 Load path when running in user mode (<option>--user</option>).
336 </title>
337
338 <tgroup cols='2'>
339 <colspec colname='path' />
340 <colspec colname='expl' />
341 <thead>
342 <row>
343 <entry>Path</entry>
344 <entry>Description</entry>
345 </row>
346 </thead>
347 <tbody>
348 <row>
349 <entry><filename>$XDG_CONFIG_HOME/systemd/user</filename></entry>
350 <entry>User configuration (only used when $XDG_CONFIG_HOME is set)</entry>
351 </row>
352 <row>
353 <entry><filename>$HOME/.config/systemd/user</filename></entry>
354 <entry>User configuration (only used when $XDG_CONFIG_HOME is not set)</entry>
355 </row>
356 <row>
357 <entry><filename>/etc/systemd/user</filename></entry>
358 <entry>Local configuration</entry>
359 </row>
360 <row>
361 <entry><filename>$XDG_RUNTIME_DIR/systemd/user</filename></entry>
362 <entry>Runtime units (only used when $XDG_RUNTIME_DIR is set)</entry>
363 </row>
364 <row>
365 <entry><filename>/run/systemd/user</filename></entry>
366 <entry>Runtime units</entry>
367 </row>
368 <row>
369 <entry><filename>$XDG_DATA_HOME/systemd/user</filename></entry>
370 <entry>Units of packages that have been installed in the home directory (only used when $XDG_DATA_HOME is set)</entry>
371 </row>
372 <row>
373 <entry><filename>$HOME/.local/share/systemd/user</filename></entry>
374 <entry>Units of packages that have been installed in the home directory (only used when $XDG_DATA_HOME is not set)</entry>
375 </row>
376 <row>
377 <entry><filename>/usr/lib/systemd/user</filename></entry>
378 <entry>Units of packages that have been installed system-wide</entry>
379 </row>
380 </tbody>
381 </tgroup>
382 </table>
383
384 <para>Additional units might be loaded into systemd ("linked")
385 from directories not on the unit load path. See the
386 <command>link</command> command for
387 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
388 Also, some units are dynamically created via a
389 <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
390 </para>
391 </refsect1>
392
393 <refsect1>
394 <title>[Unit] Section Options</title>
395
396 <para>The unit file may include a [Unit] section, which carries
397 generic information about the unit that is not dependent on the
398 type of unit:</para>
399
400 <variablelist class='unit-directives'>
401
402 <varlistentry>
403 <term><varname>Description=</varname></term>
404 <listitem><para>A free-form string describing the unit. This
405 is intended for use in UIs to show descriptive information
406 along with the unit name. The description should contain a
407 name that means something to the end user. <literal>Apache2
408 Web Server</literal> is a good example. Bad examples are
409 <literal>high-performance light-weight HTTP server</literal>
410 (too generic) or <literal>Apache2</literal> (too specific and
411 meaningless for people who do not know
412 Apache).</para></listitem>
413 </varlistentry>
414
415 <varlistentry>
416 <term><varname>Documentation=</varname></term>
417 <listitem><para>A space-separated list of URIs referencing
418 documentation for this unit or its configuration. Accepted are
419 only URIs of the types <literal>http://</literal>,
420 <literal>https://</literal>, <literal>file:</literal>,
421 <literal>info:</literal>, <literal>man:</literal>. For more
422 information about the syntax of these URIs, see <citerefentry
423 project='man-pages'><refentrytitle>uri</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
424 The URIs should be listed in order of relevance, starting with
425 the most relevant. It is a good idea to first reference
426 documentation that explains what the unit's purpose is,
427 followed by how it is configured, followed by any other
428 related documentation. This option may be specified more than
429 once, in which case the specified list of URIs is merged. If
430 the empty string is assigned to this option, the list is reset
431 and all prior assignments will have no
432 effect.</para></listitem>
433 </varlistentry>
434
435 <varlistentry>
436 <term><varname>Requires=</varname></term>
437
438 <listitem><para>Configures requirement dependencies on other
439 units. If this unit gets activated, the units listed here will
440 be activated as well. If one of the other units gets
441 deactivated or its activation fails, this unit will be
442 deactivated. This option may be specified more than once or
443 multiple space-separated units may be specified in one option
444 in which case requirement dependencies for all listed names
445 will be created. Note that requirement dependencies do not
446 influence the order in which services are started or stopped.
447 This has to be configured independently with the
448 <varname>After=</varname> or <varname>Before=</varname>
449 options. If a unit <filename>foo.service</filename> requires a
450 unit <filename>bar.service</filename> as configured with
451 <varname>Requires=</varname> and no ordering is configured
452 with <varname>After=</varname> or <varname>Before=</varname>,
453 then both units will be started simultaneously and without any
454 delay between them if <filename>foo.service</filename> is
455 activated. Often, it is a better choice to use
456 <varname>Wants=</varname> instead of
457 <varname>Requires=</varname> in order to achieve a system that
458 is more robust when dealing with failing services.</para>
459
460 <para>Note that dependencies of this type may also be
461 configured outside of the unit configuration file by adding a
462 symlink to a <filename>.requires/</filename> directory
463 accompanying the unit file. For details, see
464 above.</para></listitem>
465 </varlistentry>
466
467 <varlistentry>
468 <term><varname>Requisite=</varname></term>
469
470 <listitem><para>Similar to <varname>Requires=</varname>.
471 However, if the units listed here are not started already,
472 they will not be started and the transaction will fail
473 immediately. </para></listitem>
474 </varlistentry>
475
476 <varlistentry>
477 <term><varname>Wants=</varname></term>
478
479 <listitem><para>A weaker version of
480 <varname>Requires=</varname>. Units listed in this option will
481 be started if the configuring unit is. However, if the listed
482 units fail to start or cannot be added to the transaction,
483 this has no impact on the validity of the transaction as a
484 whole. This is the recommended way to hook start-up of one
485 unit to the start-up of another unit.</para>
486
487 <para>Note that dependencies of this type may also be
488 configured outside of the unit configuration file by adding
489 symlinks to a <filename>.wants/</filename> directory
490 accompanying the unit file. For details, see
491 above.</para></listitem>
492 </varlistentry>
493
494 <varlistentry>
495 <term><varname>BindsTo=</varname></term>
496
497 <listitem><para>Configures requirement dependencies, very
498 similar in style to <varname>Requires=</varname>, however in
499 addition to this behavior, it also declares that this unit is
500 stopped when any of the units listed suddenly disappears.
501 Units can suddenly, unexpectedly disappear if a service
502 terminates on its own choice, a device is unplugged or a mount
503 point unmounted without involvement of
504 systemd.</para></listitem>
505 </varlistentry>
506
507 <varlistentry>
508 <term><varname>PartOf=</varname></term>
509
510 <listitem><para>Configures dependencies similar to
511 <varname>Requires=</varname>, but limited to stopping and
512 restarting of units. When systemd stops or restarts the units
513 listed here, the action is propagated to this unit. Note that
514 this is a one-way dependency — changes to this unit do not
515 affect the listed units. </para></listitem>
516 </varlistentry>
517
518 <varlistentry>
519 <term><varname>Conflicts=</varname></term>
520
521 <listitem><para>A space-separated list of unit names.
522 Configures negative requirement dependencies. If a unit has a
523 <varname>Conflicts=</varname> setting on another unit,
524 starting the former will stop the latter and vice versa. Note
525 that this setting is independent of and orthogonal to the
526 <varname>After=</varname> and <varname>Before=</varname>
527 ordering dependencies.</para>
528
529 <para>If a unit A that conflicts with a unit B is scheduled to
530 be started at the same time as B, the transaction will either
531 fail (in case both are required part of the transaction) or be
532 modified to be fixed (in case one or both jobs are not a
533 required part of the transaction). In the latter case, the job
534 that is not the required will be removed, or in case both are
535 not required, the unit that conflicts will be started and the
536 unit that is conflicted is stopped.</para></listitem>
537 </varlistentry>
538
539 <varlistentry>
540 <term><varname>Before=</varname></term>
541 <term><varname>After=</varname></term>
542
543 <listitem><para>A space-separated list of unit names.
544 Configures ordering dependencies between units. If a unit
545 <filename>foo.service</filename> contains a setting
546 <option>Before=bar.service</option> and both units are being
547 started, <filename>bar.service</filename>'s start-up is
548 delayed until <filename>foo.service</filename> is started up.
549 Note that this setting is independent of and orthogonal to the
550 requirement dependencies as configured by
551 <varname>Requires=</varname>. It is a common pattern to
552 include a unit name in both the <varname>After=</varname> and
553 <varname>Requires=</varname> option, in which case the unit
554 listed will be started before the unit that is configured with
555 these options. This option may be specified more than once, in
556 which case ordering dependencies for all listed names are
557 created. <varname>After=</varname> is the inverse of
558 <varname>Before=</varname>, i.e. while
559 <varname>After=</varname> ensures that the configured unit is
560 started after the listed unit finished starting up,
561 <varname>Before=</varname> ensures the opposite, i.e. that the
562 configured unit is fully started up before the listed unit is
563 started. Note that when two units with an ordering dependency
564 between them are shut down, the inverse of the start-up order
565 is applied. i.e. if a unit is configured with
566 <varname>After=</varname> on another unit, the former is
567 stopped before the latter if both are shut down. Given two units
568 with any ordering dependency between them, if one unit is shut
569 down and the other is started up, the shutdown is ordered
570 before the start-up. It doesn't matter if the ordering
571 dependency is <varname>After=</varname> or
572 <varname>Before=</varname>. It also doesn't matter which of the
573 two is shut down, as long as one is shut down and the other is
574 started up. The shutdown is ordered before the start-up in all
575 cases. If two units have no ordering dependencies between them,
576 they are shut down or started up simultaneously, and no ordering
577 takes place.
578 </para></listitem>
579 </varlistentry>
580
581 <varlistentry>
582 <term><varname>OnFailure=</varname></term>
583
584 <listitem><para>A space-separated list of one or more units
585 that are activated when this unit enters the
586 <literal>failed</literal> state.</para></listitem>
587 </varlistentry>
588
589 <varlistentry>
590 <term><varname>PropagatesReloadTo=</varname></term>
591 <term><varname>ReloadPropagatedFrom=</varname></term>
592
593 <listitem><para>A space-separated list of one or more units
594 where reload requests on this unit will be propagated to, or
595 reload requests on the other unit will be propagated to this
596 unit, respectively. Issuing a reload request on a unit will
597 automatically also enqueue a reload request on all units that
598 the reload request shall be propagated to via these two
599 settings.</para></listitem>
600 </varlistentry>
601
602 <varlistentry>
603 <term><varname>JoinsNamespaceOf=</varname></term>
604
605 <listitem><para>For units that start processes (such as
606 service units), lists one or more other units whose network
607 and/or temporary file namespace to join. This only applies to
608 unit types which support the
609 <varname>PrivateNetwork=</varname> and
610 <varname>PrivateTmp=</varname> directives (see
611 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
612 for details). If a unit that has this setting set is started,
613 its processes will see the same <filename>/tmp</filename>,
614 <filename>/var/tmp</filename> and network namespace as one
615 listed unit that is started. If multiple listed units are
616 already started, it is not defined which namespace is joined.
617 Note that this setting only has an effect if
618 <varname>PrivateNetwork=</varname> and/or
619 <varname>PrivateTmp=</varname> is enabled for both the unit
620 that joins the namespace and the unit whose namespace is
621 joined.</para></listitem>
622 </varlistentry>
623
624 <varlistentry>
625 <term><varname>RequiresMountsFor=</varname></term>
626
627 <listitem><para>Takes a space-separated list of absolute
628 paths. Automatically adds dependencies of type
629 <varname>Requires=</varname> and <varname>After=</varname> for
630 all mount units required to access the specified path.</para>
631
632 <para>Mount points marked with <option>noauto</option> are not
633 mounted automatically and will be ignored for the purposes of
634 this option. If such a mount should be a requirement for this
635 unit, direct dependencies on the mount units may be added
636 (<varname>Requires=</varname> and <varname>After=</varname> or
637 some other combination). </para></listitem>
638 </varlistentry>
639
640 <varlistentry>
641 <term><varname>OnFailureJobMode=</varname></term>
642
643 <listitem><para>Takes a value of
644 <literal>fail</literal>,
645 <literal>replace</literal>,
646 <literal>replace-irreversibly</literal>,
647 <literal>isolate</literal>,
648 <literal>flush</literal>,
649 <literal>ignore-dependencies</literal> or
650 <literal>ignore-requirements</literal>. Defaults to
651 <literal>replace</literal>. Specifies how the units listed in
652 <varname>OnFailure=</varname> will be enqueued. See
653 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
654 <option>--job-mode=</option> option for details on the
655 possible values. If this is set to <literal>isolate</literal>,
656 only a single unit may be listed in
657 <varname>OnFailure=</varname>..</para></listitem>
658 </varlistentry>
659
660 <varlistentry>
661 <term><varname>IgnoreOnIsolate=</varname></term>
662
663 <listitem><para>Takes a boolean argument. If
664 <option>true</option>, this unit will not be stopped when
665 isolating another unit. Defaults to
666 <option>false</option>.</para></listitem>
667 </varlistentry>
668
669 <varlistentry>
670 <term><varname>StopWhenUnneeded=</varname></term>
671
672 <listitem><para>Takes a boolean argument. If
673 <option>true</option>, this unit will be stopped when it is no
674 longer used. Note that, in order to minimize the work to be
675 executed, systemd will not stop units by default unless they
676 are conflicting with other units, or the user explicitly
677 requested their shut down. If this option is set, a unit will
678 be automatically cleaned up if no other active unit requires
679 it. Defaults to <option>false</option>.</para></listitem>
680 </varlistentry>
681
682 <varlistentry>
683 <term><varname>RefuseManualStart=</varname></term>
684 <term><varname>RefuseManualStop=</varname></term>
685
686 <listitem><para>Takes a boolean argument. If
687 <option>true</option>, this unit can only be activated or
688 deactivated indirectly. In this case, explicit start-up or
689 termination requested by the user is denied, however if it is
690 started or stopped as a dependency of another unit, start-up
691 or termination will succeed. This is mostly a safety feature
692 to ensure that the user does not accidentally activate units
693 that are not intended to be activated explicitly, and not
694 accidentally deactivate units that are not intended to be
695 deactivated. These options default to
696 <option>false</option>.</para></listitem>
697 </varlistentry>
698
699 <varlistentry>
700 <term><varname>AllowIsolate=</varname></term>
701
702 <listitem><para>Takes a boolean argument. If
703 <option>true</option>, this unit may be used with the
704 <command>systemctl isolate</command> command. Otherwise, this
705 will be refused. It probably is a good idea to leave this
706 disabled except for target units that shall be used similar to
707 runlevels in SysV init systems, just as a precaution to avoid
708 unusable system states. This option defaults to
709 <option>false</option>.</para></listitem>
710 </varlistentry>
711
712 <varlistentry>
713 <term><varname>DefaultDependencies=</varname></term>
714
715 <listitem><para>Takes a boolean argument. If
716 <option>true</option>, (the default), a few default
717 dependencies will implicitly be created for the unit. The
718 actual dependencies created depend on the unit type. For
719 example, for service units, these dependencies ensure that the
720 service is started only after basic system initialization is
721 completed and is properly terminated on system shutdown. See
722 the respective man pages for details. Generally, only services
723 involved with early boot or late shutdown should set this
724 option to <option>false</option>. It is highly recommended to
725 leave this option enabled for the majority of common units. If
726 set to <option>false</option>, this option does not disable
727 all implicit dependencies, just non-essential
728 ones.</para></listitem>
729 </varlistentry>
730
731 <varlistentry>
732 <term><varname>JobTimeoutSec=</varname></term>
733 <term><varname>JobTimeoutAction=</varname></term>
734 <term><varname>JobTimeoutRebootArgument=</varname></term>
735
736 <listitem><para>When a job for this unit is queued, a time-out may be configured. If this time limit is
737 reached, the job will be cancelled, the unit however will not change state or even enter the
738 <literal>failed</literal> mode. This value defaults to <literal>infinity</literal> (job timeouts disabled),
739 except for device units. NB: this timeout is independent from any unit-specific timeout (for example, the
740 timeout set with <varname>TimeoutStartSec=</varname> in service units) as the job timeout has no effect on the
741 unit itself, only on the job that might be pending for it. Or in other words: unit-specific timeouts are useful
742 to abort unit state changes, and revert them. The job timeout set with this option however is useful to abort
743 only the job waiting for the unit state to change.</para>
744
745 <para><varname>JobTimeoutAction=</varname>
746 optionally configures an additional
747 action to take when the time-out is
748 hit. It takes the same values as the
749 per-service
750 <varname>StartLimitAction=</varname>
751 setting, see
752 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
753 for details. Defaults to
754 <option>none</option>. <varname>JobTimeoutRebootArgument=</varname>
755 configures an optional reboot string
756 to pass to the
757 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
758 system call.</para></listitem>
759 </varlistentry>
760
761 <varlistentry>
762 <term><varname>StartLimitIntervalSec=</varname></term>
763 <term><varname>StartLimitBurst=</varname></term>
764
765 <listitem><para>Configure unit start rate limiting. By default, units which are started more than 5 times
766 within 10 seconds are not permitted to start any more times until the 10 second interval ends. With these two
767 options, this rate limiting may be modified. Use <varname>StartLimitIntervalSec=</varname> to configure the
768 checking interval (defaults to <varname>DefaultStartLimitIntervalSec=</varname> in manager configuration file,
769 set to 0 to disable any kind of rate limiting). Use <varname>StartLimitBurst=</varname> to configure how many
770 starts per interval are allowed (defaults to <varname>DefaultStartLimitBurst=</varname> in manager
771 configuration file). These configuration options are particularly useful in conjunction with the service
772 setting <varname>Restart=</varname> (see
773 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>); however,
774 they apply to all kinds of starts (including manual), not just those triggered by the
775 <varname>Restart=</varname> logic. Note that units which are configured for <varname>Restart=</varname> and
776 which reach the start limit are not attempted to be restarted anymore; however, they may still be restarted
777 manually at a later point, from which point on, the restart logic is again activated. Note that
778 <command>systemctl reset-failed</command> will cause the restart rate counter for a service to be flushed,
779 which is useful if the administrator wants to manually start a unit and the start limit interferes with
780 that. Note that this rate-limiting is enforced after any unit condition checks are executed, and hence unit
781 activations with failing conditions are not counted by this rate limiting. Slice, target, device and scope
782 units do not enforce this setting, as they are unit types whose activation may either never fail, or may
783 succeed only a single time.</para></listitem>
784 </varlistentry>
785
786 <varlistentry>
787 <term><varname>StartLimitAction=</varname></term>
788
789 <listitem><para>Configure the action to take if the rate limit configured with
790 <varname>StartLimitIntervalSec=</varname> and <varname>StartLimitBurst=</varname> is hit. Takes one of
791 <option>none</option>, <option>reboot</option>, <option>reboot-force</option>,
792 <option>reboot-immediate</option>, <option>poweroff</option>, <option>poweroff-force</option> or
793 <option>poweroff-immediate</option>. If <option>none</option> is set, hitting the rate limit will trigger no
794 action besides that the start will not be permitted. <option>reboot</option> causes a reboot following the
795 normal shutdown procedure (i.e. equivalent to <command>systemctl reboot</command>).
796 <option>reboot-force</option> causes a forced reboot which will terminate all processes forcibly but should
797 cause no dirty file systems on reboot (i.e. equivalent to <command>systemctl reboot -f</command>) and
798 <option>reboot-immediate</option> causes immediate execution of the
799 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call, which
800 might result in data loss. Similarly, <option>poweroff</option>, <option>poweroff-force</option>,
801 <option>poweroff-immediate</option> have the effect of powering down the system with similar
802 semantics. Defaults to <option>none</option>.</para></listitem>
803 </varlistentry>
804
805 <varlistentry>
806 <term><varname>RebootArgument=</varname></term>
807 <listitem><para>Configure the optional argument for the
808 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call if
809 <varname>StartLimitAction=</varname> or a service's <varname>FailureAction=</varname> is a reboot action. This
810 works just like the optional argument to <command>systemctl reboot</command> command.</para></listitem>
811 </varlistentry>
812
813 <varlistentry>
814 <term><varname>ConditionArchitecture=</varname></term>
815 <term><varname>ConditionVirtualization=</varname></term>
816 <term><varname>ConditionHost=</varname></term>
817 <term><varname>ConditionKernelCommandLine=</varname></term>
818 <term><varname>ConditionSecurity=</varname></term>
819 <term><varname>ConditionCapability=</varname></term>
820 <term><varname>ConditionACPower=</varname></term>
821 <term><varname>ConditionNeedsUpdate=</varname></term>
822 <term><varname>ConditionFirstBoot=</varname></term>
823 <term><varname>ConditionPathExists=</varname></term>
824 <term><varname>ConditionPathExistsGlob=</varname></term>
825 <term><varname>ConditionPathIsDirectory=</varname></term>
826 <term><varname>ConditionPathIsSymbolicLink=</varname></term>
827 <term><varname>ConditionPathIsMountPoint=</varname></term>
828 <term><varname>ConditionPathIsReadWrite=</varname></term>
829 <term><varname>ConditionDirectoryNotEmpty=</varname></term>
830 <term><varname>ConditionFileNotEmpty=</varname></term>
831 <term><varname>ConditionFileIsExecutable=</varname></term>
832
833 <!-- We do not document ConditionNull=
834 here, as it is not particularly
835 useful and probably just
836 confusing. -->
837
838 <listitem><para>Before starting a unit, verify that the specified condition is true. If it is not true, the
839 starting of the unit will be (mostly silently) skipped, however all ordering dependencies of it are still
840 respected. A failing condition will not result in the unit being moved into a failure state. The condition is
841 checked at the time the queued start job is to be executed. Use condition expressions in order to silently skip
842 units that do not apply to the local running system, for example because the kernel or runtime environment
843 doesn't require its functionality. Use the various <varname>AssertArchitecture=</varname>,
844 <varname>AssertVirtualization=</varname>, … options for a similar mechanism that puts the unit in a failure
845 state and logs about the failed check (see below).</para>
846
847 <para><varname>ConditionArchitecture=</varname> may be used to
848 check whether the system is running on a specific
849 architecture. Takes one of
850 <varname>x86</varname>,
851 <varname>x86-64</varname>,
852 <varname>ppc</varname>,
853 <varname>ppc-le</varname>,
854 <varname>ppc64</varname>,
855 <varname>ppc64-le</varname>,
856 <varname>ia64</varname>,
857 <varname>parisc</varname>,
858 <varname>parisc64</varname>,
859 <varname>s390</varname>,
860 <varname>s390x</varname>,
861 <varname>sparc</varname>,
862 <varname>sparc64</varname>,
863 <varname>mips</varname>,
864 <varname>mips-le</varname>,
865 <varname>mips64</varname>,
866 <varname>mips64-le</varname>,
867 <varname>alpha</varname>,
868 <varname>arm</varname>,
869 <varname>arm-be</varname>,
870 <varname>arm64</varname>,
871 <varname>arm64-be</varname>,
872 <varname>sh</varname>,
873 <varname>sh64</varname>,
874 <varname>m86k</varname>,
875 <varname>tilegx</varname>,
876 <varname>cris</varname> to test
877 against a specific architecture. The architecture is
878 determined from the information returned by
879 <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
880 and is thus subject to
881 <citerefentry><refentrytitle>personality</refentrytitle><manvolnum>2</manvolnum></citerefentry>.
882 Note that a <varname>Personality=</varname> setting in the
883 same unit file has no effect on this condition. A special
884 architecture name <varname>native</varname> is mapped to the
885 architecture the system manager itself is compiled for. The
886 test may be negated by prepending an exclamation mark.</para>
887
888 <para><varname>ConditionVirtualization=</varname> may be used
889 to check whether the system is executed in a virtualized
890 environment and optionally test whether it is a specific
891 implementation. Takes either boolean value to check if being
892 executed in any virtualized environment, or one of
893 <varname>vm</varname> and
894 <varname>container</varname> to test against a generic type of
895 virtualization solution, or one of
896 <varname>qemu</varname>,
897 <varname>kvm</varname>,
898 <varname>zvm</varname>,
899 <varname>vmware</varname>,
900 <varname>microsoft</varname>,
901 <varname>oracle</varname>,
902 <varname>xen</varname>,
903 <varname>bochs</varname>,
904 <varname>uml</varname>,
905 <varname>openvz</varname>,
906 <varname>lxc</varname>,
907 <varname>lxc-libvirt</varname>,
908 <varname>systemd-nspawn</varname>,
909 <varname>docker</varname>,
910 <varname>rkt</varname> to test
911 against a specific implementation, or
912 <varname>private-users</varname> to check whether we are running in a user namespace. See
913 <citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry>
914 for a full list of known virtualization technologies and their
915 identifiers. If multiple virtualization technologies are
916 nested, only the innermost is considered. The test may be
917 negated by prepending an exclamation mark.</para>
918
919 <para><varname>ConditionHost=</varname> may be used to match
920 against the hostname or machine ID of the host. This either
921 takes a hostname string (optionally with shell style globs)
922 which is tested against the locally set hostname as returned
923 by
924 <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
925 or a machine ID formatted as string (see
926 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
927 The test may be negated by prepending an exclamation
928 mark.</para>
929
930 <para><varname>ConditionKernelCommandLine=</varname> may be
931 used to check whether a specific kernel command line option is
932 set (or if prefixed with the exclamation mark unset). The
933 argument must either be a single word, or an assignment (i.e.
934 two words, separated <literal>=</literal>). In the former case
935 the kernel command line is searched for the word appearing as
936 is, or as left hand side of an assignment. In the latter case,
937 the exact assignment is looked for with right and left hand
938 side matching.</para>
939
940 <para><varname>ConditionSecurity=</varname> may be used to
941 check whether the given security module is enabled on the
942 system. Currently, the recognized values are
943 <varname>selinux</varname>,
944 <varname>apparmor</varname>,
945 <varname>ima</varname>,
946 <varname>smack</varname> and
947 <varname>audit</varname>. The test may be negated by
948 prepending an exclamation mark.</para>
949
950 <para><varname>ConditionCapability=</varname> may be used to
951 check whether the given capability exists in the capability
952 bounding set of the service manager (i.e. this does not check
953 whether capability is actually available in the permitted or
954 effective sets, see
955 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
956 for details). Pass a capability name such as
957 <literal>CAP_MKNOD</literal>, possibly prefixed with an
958 exclamation mark to negate the check.</para>
959
960 <para><varname>ConditionACPower=</varname> may be used to
961 check whether the system has AC power, or is exclusively
962 battery powered at the time of activation of the unit. This
963 takes a boolean argument. If set to <varname>true</varname>,
964 the condition will hold only if at least one AC connector of
965 the system is connected to a power source, or if no AC
966 connectors are known. Conversely, if set to
967 <varname>false</varname>, the condition will hold only if
968 there is at least one AC connector known and all AC connectors
969 are disconnected from a power source.</para>
970
971 <para><varname>ConditionNeedsUpdate=</varname> takes one of
972 <filename>/var</filename> or <filename>/etc</filename> as
973 argument, possibly prefixed with a <literal>!</literal> (for
974 inverting the condition). This condition may be used to
975 conditionalize units on whether the specified directory
976 requires an update because <filename>/usr</filename>'s
977 modification time is newer than the stamp file
978 <filename>.updated</filename> in the specified directory. This
979 is useful to implement offline updates of the vendor operating
980 system resources in <filename>/usr</filename> that require
981 updating of <filename>/etc</filename> or
982 <filename>/var</filename> on the next following boot. Units
983 making use of this condition should order themselves before
984 <citerefentry><refentrytitle>systemd-update-done.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
985 to make sure they run before the stamp file's modification
986 time gets reset indicating a completed update.</para>
987
988 <para><varname>ConditionFirstBoot=</varname> takes a boolean
989 argument. This condition may be used to conditionalize units
990 on whether the system is booting up with an unpopulated
991 <filename>/etc</filename> directory. This may be used to
992 populate <filename>/etc</filename> on the first boot after
993 factory reset, or when a new system instances boots up for the
994 first time.</para>
995
996 <para>With <varname>ConditionPathExists=</varname> a file
997 existence condition is checked before a unit is started. If
998 the specified absolute path name does not exist, the condition
999 will fail. If the absolute path name passed to
1000 <varname>ConditionPathExists=</varname> is prefixed with an
1001 exclamation mark (<literal>!</literal>), the test is negated,
1002 and the unit is only started if the path does not
1003 exist.</para>
1004
1005 <para><varname>ConditionPathExistsGlob=</varname> is similar
1006 to <varname>ConditionPathExists=</varname>, but checks for the
1007 existence of at least one file or directory matching the
1008 specified globbing pattern.</para>
1009
1010 <para><varname>ConditionPathIsDirectory=</varname> is similar
1011 to <varname>ConditionPathExists=</varname> but verifies
1012 whether a certain path exists and is a directory.</para>
1013
1014 <para><varname>ConditionPathIsSymbolicLink=</varname> is
1015 similar to <varname>ConditionPathExists=</varname> but
1016 verifies whether a certain path exists and is a symbolic
1017 link.</para>
1018
1019 <para><varname>ConditionPathIsMountPoint=</varname> is similar
1020 to <varname>ConditionPathExists=</varname> but verifies
1021 whether a certain path exists and is a mount point.</para>
1022
1023 <para><varname>ConditionPathIsReadWrite=</varname> is similar
1024 to <varname>ConditionPathExists=</varname> but verifies
1025 whether the underlying file system is readable and writable
1026 (i.e. not mounted read-only).</para>
1027
1028 <para><varname>ConditionDirectoryNotEmpty=</varname> is
1029 similar to <varname>ConditionPathExists=</varname> but
1030 verifies whether a certain path exists and is a non-empty
1031 directory.</para>
1032
1033 <para><varname>ConditionFileNotEmpty=</varname> is similar to
1034 <varname>ConditionPathExists=</varname> but verifies whether a
1035 certain path exists and refers to a regular file with a
1036 non-zero size.</para>
1037
1038 <para><varname>ConditionFileIsExecutable=</varname> is similar
1039 to <varname>ConditionPathExists=</varname> but verifies
1040 whether a certain path exists, is a regular file and marked
1041 executable.</para>
1042
1043 <para>If multiple conditions are specified, the unit will be
1044 executed if all of them apply (i.e. a logical AND is applied).
1045 Condition checks can be prefixed with a pipe symbol (|) in
1046 which case a condition becomes a triggering condition. If at
1047 least one triggering condition is defined for a unit, then the
1048 unit will be executed if at least one of the triggering
1049 conditions apply and all of the non-triggering conditions. If
1050 you prefix an argument with the pipe symbol and an exclamation
1051 mark, the pipe symbol must be passed first, the exclamation
1052 second. Except for
1053 <varname>ConditionPathIsSymbolicLink=</varname>, all path
1054 checks follow symlinks. If any of these options is assigned
1055 the empty string, the list of conditions is reset completely,
1056 all previous condition settings (of any kind) will have no
1057 effect.</para></listitem>
1058 </varlistentry>
1059
1060 <varlistentry>
1061 <term><varname>AssertArchitecture=</varname></term>
1062 <term><varname>AssertVirtualization=</varname></term>
1063 <term><varname>AssertHost=</varname></term>
1064 <term><varname>AssertKernelCommandLine=</varname></term>
1065 <term><varname>AssertSecurity=</varname></term>
1066 <term><varname>AssertCapability=</varname></term>
1067 <term><varname>AssertACPower=</varname></term>
1068 <term><varname>AssertNeedsUpdate=</varname></term>
1069 <term><varname>AssertFirstBoot=</varname></term>
1070 <term><varname>AssertPathExists=</varname></term>
1071 <term><varname>AssertPathExistsGlob=</varname></term>
1072 <term><varname>AssertPathIsDirectory=</varname></term>
1073 <term><varname>AssertPathIsSymbolicLink=</varname></term>
1074 <term><varname>AssertPathIsMountPoint=</varname></term>
1075 <term><varname>AssertPathIsReadWrite=</varname></term>
1076 <term><varname>AssertDirectoryNotEmpty=</varname></term>
1077 <term><varname>AssertFileNotEmpty=</varname></term>
1078 <term><varname>AssertFileIsExecutable=</varname></term>
1079
1080 <listitem><para>Similar to the <varname>ConditionArchitecture=</varname>,
1081 <varname>ConditionVirtualization=</varname>, …, condition settings described above, these settings add
1082 assertion checks to the start-up of the unit. However, unlike the conditions settings, any assertion setting
1083 that is not met results in failure of the start job (which means this is logged loudly). Use assertion
1084 expressions for units that cannot operate when specific requirements are not met, and when this is something
1085 the administrator or user should look into.</para></listitem>
1086 </varlistentry>
1087
1088 <varlistentry>
1089 <term><varname>SourcePath=</varname></term>
1090 <listitem><para>A path to a configuration file this unit has
1091 been generated from. This is primarily useful for
1092 implementation of generator tools that convert configuration
1093 from an external configuration file format into native unit
1094 files. This functionality should not be used in normal
1095 units.</para></listitem>
1096 </varlistentry>
1097
1098 </variablelist>
1099
1100 </refsect1>
1101
1102 <refsect1>
1103 <title>[Install] Section Options</title>
1104
1105 <para>Unit files may include an <literal>[Install]</literal> section, which carries installation information for
1106 the unit. This section is not interpreted by
1107 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> during runtime; it is
1108 used by the <command>enable</command> and <command>disable</command> commands of the
1109 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool during
1110 installation of a unit. Note that settings in the <literal>[Install]</literal> section may not appear in
1111 <filename>.d/*.conf</filename> unit file drop-ins (see above).</para>
1112
1113 <variablelist class='unit-directives'>
1114 <varlistentry>
1115 <term><varname>Alias=</varname></term>
1116
1117 <listitem><para>A space-separated list of additional names this unit shall be installed under. The names listed
1118 here must have the same suffix (i.e. type) as the unit file name. This option may be specified more than once,
1119 in which case all listed names are used. At installation time, <command>systemctl enable</command> will create
1120 symlinks from these names to the unit filename. Note that not all unit types support such alias names, and this
1121 setting is not supported for them. Specifically, mount, slice, swap, and automount units do not support
1122 aliasing.</para></listitem>
1123 </varlistentry>
1124
1125 <varlistentry>
1126 <term><varname>WantedBy=</varname></term>
1127 <term><varname>RequiredBy=</varname></term>
1128
1129 <listitem><para>This option may be used more than once, or a
1130 space-separated list of unit names may be given. A symbolic
1131 link is created in the <filename>.wants/</filename> or
1132 <filename>.requires/</filename> directory of each of the
1133 listed units when this unit is installed by <command>systemctl
1134 enable</command>. This has the effect that a dependency of
1135 type <varname>Wants=</varname> or <varname>Requires=</varname>
1136 is added from the listed unit to the current unit. The primary
1137 result is that the current unit will be started when the
1138 listed unit is started. See the description of
1139 <varname>Wants=</varname> and <varname>Requires=</varname> in
1140 the [Unit] section for details.</para>
1141
1142 <para><command>WantedBy=foo.service</command> in a service
1143 <filename>bar.service</filename> is mostly equivalent to
1144 <command>Alias=foo.service.wants/bar.service</command> in the
1145 same file. In case of template units, <command>systemctl
1146 enable</command> must be called with an instance name, and
1147 this instance will be added to the
1148 <filename>.wants/</filename> or
1149 <filename>.requires/</filename> list of the listed unit. E.g.
1150 <command>WantedBy=getty.target</command> in a service
1151 <filename>getty@.service</filename> will result in
1152 <command>systemctl enable getty@tty2.service</command>
1153 creating a
1154 <filename>getty.target.wants/getty@tty2.service</filename>
1155 link to <filename>getty@.service</filename>.
1156 </para></listitem>
1157 </varlistentry>
1158
1159 <varlistentry>
1160 <term><varname>Also=</varname></term>
1161
1162 <listitem><para>Additional units to install/deinstall when
1163 this unit is installed/deinstalled. If the user requests
1164 installation/deinstallation of a unit with this option
1165 configured, <command>systemctl enable</command> and
1166 <command>systemctl disable</command> will automatically
1167 install/uninstall units listed in this option as well.</para>
1168
1169 <para>This option may be used more than once, or a
1170 space-separated list of unit names may be
1171 given.</para></listitem>
1172 </varlistentry>
1173
1174 <varlistentry>
1175 <term><varname>DefaultInstance=</varname></term>
1176
1177 <listitem><para>In template unit files, this specifies for
1178 which instance the unit shall be enabled if the template is
1179 enabled without any explicitly set instance. This option has
1180 no effect in non-template unit files. The specified string
1181 must be usable as instance identifier.</para></listitem>
1182 </varlistentry>
1183 </variablelist>
1184
1185 <para>The following specifiers are interpreted in the Install
1186 section: %n, %N, %p, %i, %U, %u, %m, %H, %b, %v. For their meaning
1187 see the next section.
1188 </para>
1189 </refsect1>
1190
1191 <refsect1>
1192 <title>Specifiers</title>
1193
1194 <para>Many settings resolve specifiers which may be used to write
1195 generic unit files referring to runtime or unit parameters that
1196 are replaced when the unit files are loaded. The following
1197 specifiers are understood:</para>
1198
1199 <table>
1200 <title>Specifiers available in unit files</title>
1201 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
1202 <colspec colname="spec" />
1203 <colspec colname="mean" />
1204 <colspec colname="detail" />
1205 <thead>
1206 <row>
1207 <entry>Specifier</entry>
1208 <entry>Meaning</entry>
1209 <entry>Details</entry>
1210 </row>
1211 </thead>
1212 <tbody>
1213 <row>
1214 <entry><literal>%n</literal></entry>
1215 <entry>Full unit name</entry>
1216 <entry></entry>
1217 </row>
1218 <row>
1219 <entry><literal>%N</literal></entry>
1220 <entry>Unescaped full unit name</entry>
1221 <entry>Same as <literal>%n</literal>, but with escaping undone</entry>
1222 </row>
1223 <row>
1224 <entry><literal>%p</literal></entry>
1225 <entry>Prefix name</entry>
1226 <entry>For instantiated units, this refers to the string before the <literal>@</literal> character of the unit name. For non-instantiated units, this refers to the name of the unit with the type suffix removed.</entry>
1227 </row>
1228 <row>
1229 <entry><literal>%P</literal></entry>
1230 <entry>Unescaped prefix name</entry>
1231 <entry>Same as <literal>%p</literal>, but with escaping undone</entry>
1232 </row>
1233 <row>
1234 <entry><literal>%i</literal></entry>
1235 <entry>Instance name</entry>
1236 <entry>For instantiated units: this is the string between the <literal>@</literal> character and the suffix of the unit name.</entry>
1237 </row>
1238 <row>
1239 <entry><literal>%I</literal></entry>
1240 <entry>Unescaped instance name</entry>
1241 <entry>Same as <literal>%i</literal>, but with escaping undone</entry>
1242 </row>
1243 <row>
1244 <entry><literal>%f</literal></entry>
1245 <entry>Unescaped filename</entry>
1246 <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>.</entry>
1247 </row>
1248 <row>
1249 <entry><literal>%c</literal></entry>
1250 <entry>Control group path of the unit</entry>
1251 <entry>This path does not include the <filename>/sys/fs/cgroup/systemd/</filename> prefix.</entry>
1252 </row>
1253 <row>
1254 <entry><literal>%r</literal></entry>
1255 <entry>Control group path of the slice the unit is placed in</entry>
1256 <entry>This usually maps to the parent control group path of <literal>%c</literal>.</entry>
1257 </row>
1258 <row>
1259 <entry><literal>%R</literal></entry>
1260 <entry>Root control group path below which slices and units are placed</entry>
1261 <entry>For system instances, this resolves to <filename>/</filename>, except in containers, where this maps to the container's root control group path.</entry>
1262 </row>
1263 <row>
1264 <entry><literal>%t</literal></entry>
1265 <entry>Runtime directory</entry>
1266 <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>
1267 </row>
1268 <row>
1269 <entry><literal>%u</literal></entry>
1270 <entry>User name</entry>
1271 <entry>This is the name of the user running the service manager instance. In case of the system manager this resolves to <literal>root</literal>.</entry>
1272 </row>
1273 <row>
1274 <entry><literal>%U</literal></entry>
1275 <entry>User UID</entry>
1276 <entry>This is the numeric UID of the user running the service manager instance. In case of the system manager this resolves to <literal>0</literal>.</entry>
1277 </row>
1278 <row>
1279 <entry><literal>%h</literal></entry>
1280 <entry>User home directory</entry>
1281 <entry>This is the home directory of the user running the service manager instance. In case of the system manager this resolves to <literal>/root</literal>.</entry>
1282 </row>
1283 <row>
1284 <entry><literal>%s</literal></entry>
1285 <entry>User shell</entry>
1286 <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>
1287 </row>
1288 <row>
1289 <entry><literal>%m</literal></entry>
1290 <entry>Machine ID</entry>
1291 <entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
1292 </row>
1293 <row>
1294 <entry><literal>%b</literal></entry>
1295 <entry>Boot ID</entry>
1296 <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
1297 </row>
1298 <row>
1299 <entry><literal>%H</literal></entry>
1300 <entry>Host name</entry>
1301 <entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry>
1302 </row>
1303 <row>
1304 <entry><literal>%v</literal></entry>
1305 <entry>Kernel release</entry>
1306 <entry>Identical to <command>uname -r</command> output</entry>
1307 </row>
1308 <row>
1309 <entry><literal>%%</literal></entry>
1310 <entry>Single percent sign</entry>
1311 <entry>Use <literal>%%</literal> in place of <literal>%</literal> to specify a single percent sign.</entry>
1312 </row>
1313 </tbody>
1314 </tgroup>
1315 </table>
1316
1317 <para>Please note that specifiers <literal>%U</literal>,
1318 <literal>%h</literal>, <literal>%s</literal> are mostly useless
1319 when systemd is running in system mode. PID 1 cannot query the
1320 user account database for information, so the specifiers only work
1321 as shortcuts for things which are already specified in a different
1322 way in the unit file. They are fully functional when systemd is
1323 running in <option>--user</option> mode.</para>
1324 </refsect1>
1325
1326 <refsect1>
1327 <title>Examples</title>
1328
1329 <example>
1330 <title>Allowing units to be enabled</title>
1331
1332 <para>The following snippet (highlighted) allows a unit (e.g.
1333 <filename>foo.service</filename>) to be enabled via
1334 <command>systemctl enable</command>:</para>
1335
1336 <programlisting>[Unit]
1337 Description=Foo
1338
1339 [Service]
1340 ExecStart=/usr/sbin/foo-daemon
1341
1342 <emphasis>[Install]</emphasis>
1343 <emphasis>WantedBy=multi-user.target</emphasis></programlisting>
1344
1345 <para>After running <command>systemctl enable</command>, a
1346 symlink
1347 <filename>/etc/systemd/system/multi-user.target.wants/foo.service</filename>
1348 linking to the actual unit will be created. It tells systemd to
1349 pull in the unit when starting
1350 <filename>multi-user.target</filename>. The inverse
1351 <command>systemctl disable</command> will remove that symlink
1352 again.</para>
1353 </example>
1354
1355 <example>
1356 <title>Overriding vendor settings</title>
1357
1358 <para>There are two methods of overriding vendor settings in
1359 unit files: copying the unit file from
1360 <filename>/usr/lib/systemd/system</filename> to
1361 <filename>/etc/systemd/system</filename> and modifying the
1362 chosen settings. Alternatively, one can create a directory named
1363 <filename><replaceable>unit</replaceable>.d/</filename> within
1364 <filename>/etc/systemd/system</filename> and place a drop-in
1365 file <filename><replaceable>name</replaceable>.conf</filename>
1366 there that only changes the specific settings one is interested
1367 in. Note that multiple such drop-in files are read if
1368 present.</para>
1369
1370 <para>The advantage of the first method is that one easily
1371 overrides the complete unit, the vendor unit is not parsed at
1372 all anymore. It has the disadvantage that improvements to the
1373 unit file by the vendor are not automatically incorporated on
1374 updates.</para>
1375
1376 <para>The advantage of the second method is that one only
1377 overrides the settings one specifically wants, where updates to
1378 the unit by the vendor automatically apply. This has the
1379 disadvantage that some future updates by the vendor might be
1380 incompatible with the local changes.</para>
1381
1382 <para>Note that for drop-in files, if one wants to remove
1383 entries from a setting that is parsed as a list (and is not a
1384 dependency), such as <varname>ConditionPathExists=</varname> (or
1385 e.g. <varname>ExecStart=</varname> in service units), one needs
1386 to first clear the list before re-adding all entries except the
1387 one that is to be removed. See below for an example.</para>
1388
1389 <para>This also applies for user instances of systemd, but with
1390 different locations for the unit files. See the section on unit
1391 load paths for further details.</para>
1392
1393 <para>Suppose there is a vendor-supplied unit
1394 <filename>/usr/lib/systemd/system/httpd.service</filename> with
1395 the following contents:</para>
1396
1397 <programlisting>[Unit]
1398 Description=Some HTTP server
1399 After=remote-fs.target sqldb.service
1400 Requires=sqldb.service
1401 AssertPathExists=/srv/webserver
1402
1403 [Service]
1404 Type=notify
1405 ExecStart=/usr/sbin/some-fancy-httpd-server
1406 Nice=5
1407
1408 [Install]
1409 WantedBy=multi-user.target</programlisting>
1410
1411 <para>Now one wants to change some settings as an administrator:
1412 firstly, in the local setup, <filename>/srv/webserver</filename>
1413 might not exist, because the HTTP server is configured to use
1414 <filename>/srv/www</filename> instead. Secondly, the local
1415 configuration makes the HTTP server also depend on a memory
1416 cache service, <filename>memcached.service</filename>, that
1417 should be pulled in (<varname>Requires=</varname>) and also be
1418 ordered appropriately (<varname>After=</varname>). Thirdly, in
1419 order to harden the service a bit more, the administrator would
1420 like to set the <varname>PrivateTmp=</varname> setting (see
1421 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1422 for details). And lastly, the administrator would like to reset
1423 the niceness of the service to its default value of 0.</para>
1424
1425 <para>The first possibility is to copy the unit file to
1426 <filename>/etc/systemd/system/httpd.service</filename> and
1427 change the chosen settings:</para>
1428
1429 <programlisting>[Unit]
1430 Description=Some HTTP server
1431 After=remote-fs.target sqldb.service <emphasis>memcached.service</emphasis>
1432 Requires=sqldb.service <emphasis>memcached.service</emphasis>
1433 AssertPathExists=<emphasis>/srv/www</emphasis>
1434
1435 [Service]
1436 Type=notify
1437 ExecStart=/usr/sbin/some-fancy-httpd-server
1438 <emphasis>Nice=0</emphasis>
1439 <emphasis>PrivateTmp=yes</emphasis>
1440
1441 [Install]
1442 WantedBy=multi-user.target</programlisting>
1443
1444 <para>Alternatively, the administrator could create a drop-in
1445 file
1446 <filename>/etc/systemd/system/httpd.service.d/local.conf</filename>
1447 with the following contents:</para>
1448
1449 <programlisting>[Unit]
1450 After=memcached.service
1451 Requires=memcached.service
1452 # Reset all assertions and then re-add the condition we want
1453 AssertPathExists=
1454 AssertPathExists=/srv/www
1455
1456 [Service]
1457 Nice=0
1458 PrivateTmp=yes</programlisting>
1459
1460 <para>Note that dependencies (<varname>After=</varname>, etc.)
1461 cannot be reset to an empty list, so dependencies can only be
1462 added in drop-ins. If you want to remove dependencies, you have
1463 to override the entire unit.</para>
1464
1465 </example>
1466 </refsect1>
1467
1468 <refsect1>
1469 <title>See Also</title>
1470 <para>
1471 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1472 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1473 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1474 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1475 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1476 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1477 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1478 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1479 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1480 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1481 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1482 <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1483 <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1484 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1485 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1486 <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1487 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1488 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1489 <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1490 </para>
1491 </refsect1>
1492
1493 </refentry>