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