]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.unit.xml
man: use <literal> not <filename> for suffixes
[thirdparty/systemd.git] / man / systemd.unit.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
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>snapshot</replaceable>.snapshot</filename></para>
64
65 <para><literallayout><filename>/etc/systemd/system/*</filename>
66 <filename>/run/systemd/system/*</filename>
67 <filename>/usr/lib/systemd/system/*</filename>
68 <filename>...</filename>
69 </literallayout></para>
70
71 <para><literallayout><filename>/etc/systemd/user/*</filename>
72 <filename>/run/systemd/user/*</filename>
73 <filename>/usr/lib/systemd/user/*</filename>
74 <filename>...</filename>
75 </literallayout></para>
76 </refsynopsisdiv>
77
78 <refsect1>
79 <title>Description</title>
80
81 <para>A unit configuration file encodes information
82 about a service, a socket, a device, a mount point, an
83 automount point, a swap file or partition, a start-up
84 target, a file system path, or a timer controlled and
85 supervised by
86 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The
87 syntax is inspired by <ulink
88 url="http://standards.freedesktop.org/desktop-entry-spec/latest/">XDG
89 Desktop Entry Specification</ulink> <filename>.desktop</filename> files, which are in turn
90 inspired by Microsoft Windows
91 <filename>.ini</filename> files.</para>
92
93 <para>This man page lists the common configuration
94 options of all the unit types. These options need to
95 be configured in the [Unit] or [Install]
96 sections of the unit files.</para>
97
98 <para>In addition to the generic [Unit] and [Install]
99 sections described here, each unit may have a
100 type-specific section, e.g. [Service] for a service
101 unit. See the respective man pages for more
102 information:
103 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
104 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
105 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
106 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
107 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
108 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
109 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
110 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
111 <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
112 <citerefentry><refentrytitle>systemd.snapshot</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
113 </para>
114
115 <para>Unit files are loaded from a set of paths
116 determined during compilation, described in the next section.
117 </para>
118
119 <para>Unit files may contain additional options on top
120 of those listed here. If systemd encounters an unknown
121 option it will write a warning log message but
122 continue loading the unit. If an option is prefixed
123 with <option>X-</option> it is ignored completely by
124 systemd. Applications may use this to include
125 additional information in the unit files.</para>
126
127 <para>Boolean arguments used in unit files can be
128 written in various formats. For positive settings the
129 strings <option>1</option>, <option>yes</option>,
130 <option>true</option> and <option>on</option> are
131 equivalent. For negative settings the strings
132 <option>0</option>, <option>no</option>,
133 <option>false</option> and <option>off</option> are
134 equivalent.</para>
135
136 <para>Time span values encoded in unit files can be
137 written in various formats. A stand-alone number
138 specifies a time in seconds. If suffixed with a time
139 unit, the unit is honored. A concatenation of multiple
140 values with units is supported, in which case the
141 values are added up. Example: "50" refers to 50
142 seconds; "2min 200ms" refers to 2 minutes plus 200
143 milliseconds, i.e. 120200ms. The following time units
144 are understood: s, min, h, d, w, ms, us. For details
145 see
146 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
147
148 <para>Empty lines and lines starting with # or ; are
149 ignored. This may be used for commenting. Lines ending
150 in a backslash are concatenated with the following
151 line while reading and the backslash is replaced by a
152 space character. This may be used to wrap long lines.</para>
153
154 <para>Along with a unit file
155 <filename>foo.service</filename> the directory
156 <filename>foo.service.wants/</filename> may exist. All
157 unit files symlinked from such a directory are
158 implicitly added as dependencies of type
159 <varname>Wanted=</varname> to the unit. This is useful
160 to hook units into the start-up of other units,
161 without having to modify their unit files. For details
162 about the semantics of <varname>Wanted=</varname> see
163 below. The preferred way to create symlinks in the
164 <filename>.wants/</filename> directory of a unit file
165 is with the <command>enable</command> command of the
166 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
167 tool which reads information from the [Install]
168 section of unit files (see below). A similar
169 functionality exists for <varname>Requires=</varname>
170 type dependencies as well, the directory suffix is
171 <filename>.requires/</filename> in this case.</para>
172
173 <para>Along with a unit file
174 <filename>foo.service</filename> a directory
175 <filename>foo.service.d/</filename> may exist. All
176 files with the suffix <literal>.conf</literal> from
177 this directory will be parsed after the file itself is
178 parsed. This is useful to alter or add configuration
179 settings to a unit, without having to modify their
180 unit files. Make sure that the file that is included
181 has the appropriate section headers before any
182 directive.</para>
183
184 <para>If a line starts with <option>.include</option>
185 followed by a filename, the specified file will be
186 parsed at this point. Make sure that the file that is
187 included has the appropriate section headers before
188 any directives.</para>
189
190 <para>Note that while systemd offers a flexible
191 dependency system between units it is recommended to
192 use this functionality only sparingly and instead rely
193 on techniques such as bus-based or socket-based
194 activation which make dependencies implicit, resulting
195 in a both simpler and more flexible system.</para>
196
197 <para>Some unit names reflect paths existing in the
198 file system namespace. Example: a device unit
199 <filename>dev-sda.device</filename> refers to a device
200 with the device node <filename noindex='true'>/dev/sda</filename> in
201 the file system namespace. If this applies a special
202 way to escape the path name is used, so that the
203 result is usable as part of a filename. Basically,
204 given a path, "/" is replaced by "-", and all
205 unprintable characters and the "-" are replaced by
206 C-style "\x20" escapes. The root directory "/" is
207 encoded as single dash, while otherwise the initial
208 and ending "/" is removed from all paths during
209 transformation. This escaping is reversible.</para>
210
211 <para>Optionally, units may be instantiated from a
212 template file at runtime. This allows creation of
213 multiple units from a single configuration file. If
214 systemd looks for a unit configuration file it will
215 first search for the literal unit name in the
216 filesystem. If that yields no success and the unit
217 name contains an <literal>@</literal> character, systemd will look for a
218 unit template that shares the same name but with the
219 instance string (i.e. the part between the <literal>@</literal> character
220 and the suffix) removed. Example: if a service
221 <filename>getty@tty3.service</filename> is requested
222 and no file by that name is found, systemd will look
223 for <filename>getty@.service</filename> and
224 instantiate a service from that configuration file if
225 it is found.</para>
226
227 <para>To refer to the instance string from
228 within the configuration file you may use the special
229 <literal>%i</literal> specifier in many of the
230 configuration options. See below for details.</para>
231
232 <para>If a unit file is empty (i.e. has the file size
233 0) or is symlinked to <filename>/dev/null</filename>
234 its configuration will not be loaded and it appears
235 with a load state of <literal>masked</literal>, and
236 cannot be activated. Use this as an effective way to
237 fully disable a unit, making it impossible to start it
238 even manually.</para>
239
240 <para>The unit file format is covered by the
241 <ulink
242 url="http://www.freedesktop.org/wiki/Software/systemd/InterfaceStabilityPromise">Interface
243 Stability Promise</ulink>.</para>
244
245 </refsect1>
246
247 <refsect1>
248 <title>Unit Load Path</title>
249
250 <para>Unit files are loaded from a set of paths
251 determined during compilation, described in the two
252 tables below. Unit files found in directories higher
253 in the hierarchy override files with the same name
254 lower in the hierarchy, thus allowing overrides.
255 </para>
256
257 <para>When systemd is running in user mode
258 (<option>--user</option>) and the variable
259 <varname>$SYSTEMD_UNIT_PATH</varname> is set, this
260 contents of this variable overrides the unit load
261 path.
262 </para>
263
264 <table>
265 <title>
266 Load path when running in system mode (<option>--system</option>).
267 </title>
268
269 <tgroup cols='2'>
270 <colspec colname='path' />
271 <colspec colname='expl' />
272 <thead>
273 <row>
274 <entry>Path</entry>
275 <entry>Description</entry>
276 </row>
277 </thead>
278 <tbody>
279 <row>
280 <entry><filename>/run/systemd/generator.early</filename></entry>
281 <entry>Generated units (early)</entry>
282 </row>
283 <row>
284 <entry><filename>/etc/systemd/system</filename></entry>
285 <entry>Local configuration</entry>
286 </row>
287 <row>
288 <entry><filename>/run/systemd/systemd</filename></entry>
289 <entry>Volatile units</entry>
290 </row>
291 <row>
292 <entry><filename>/run/systemd/generator</filename></entry>
293 <entry>Generated units (middle)</entry>
294 </row>
295 <row>
296 <entry><filename>/usr/local/lib/systemd/system</filename></entry>
297 <entry>Units for local packages</entry>
298 </row>
299 <row>
300 <entry><filename>/usr/lib/systemd/system</filename></entry>
301 <entry>Units for installed packages</entry>
302 </row>
303 <row>
304 <entry><filename>/run/systemd/generator.late</filename></entry>
305 <entry>Generated units (late)</entry>
306 </row>
307 </tbody>
308 </tgroup>
309 </table>
310
311 <table>
312 <title>
313 Load path when running in session mode (<option>--user</option>).
314 </title>
315
316 <tgroup cols='2'>
317 <colspec colname='path' />
318 <colspec colname='expl' />
319 <thead>
320 <row>
321 <entry>Path</entry>
322 <entry>Description</entry>
323 </row>
324 </thead>
325 <tbody>
326 <row>
327 <entry><filename>/tmp/systemd-generator.early.<replaceable>XXXXXX</replaceable></filename></entry>
328 <entry>Generated units (early)</entry>
329 </row>
330 <row>
331 <entry><filename>/etc/systemd/user</filename></entry>
332 <entry>Local configuration</entry>
333 </row>
334 <row>
335 <entry><filename>/run/systemd/user</filename></entry>
336 <entry>Volatile units</entry>
337 </row>
338 <row>
339 <entry><filename>/tmp/systemd-generator.<replaceable>XXXXXX</replaceable></filename></entry>
340 <entry>Generated units (middle)</entry>
341 </row>
342 <row>
343 <entry><filename>/usr/local/lib/systemd/user</filename></entry>
344 <entry>Units for local packages</entry>
345 </row>
346 <row>
347 <entry><filename>/usr/lib/systemd/user</filename></entry>
348 <entry>Units for installed packages</entry>
349 </row>
350 <row>
351 <entry><filename>/tmp/systemd-generator.late.<replaceable>XXXXXX</replaceable></filename></entry>
352 <entry>Generated units (late)</entry>
353 </row>
354 </tbody>
355 </tgroup>
356 </table>
357
358 <para>Additional units might be loaded into systemd
359 ("linked") from directories not on the unit load
360 path. See the <command>link</command> command for
361 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
362 </para>
363 </refsect1>
364
365 <refsect1>
366 <title>Options</title>
367
368 <para>Unit file may include a [Unit] section, which
369 carries generic information about the unit that is not
370 dependent on the type of unit:</para>
371
372 <variablelist class='unit-directives'>
373
374 <varlistentry>
375 <term><varname>Description=</varname></term>
376 <listitem><para>A free-form string
377 describing the unit. This is intended
378 for use in UIs to show descriptive
379 information along with the unit
380 name.</para></listitem>
381 </varlistentry>
382
383 <varlistentry>
384 <term><varname>Documentation=</varname></term>
385 <listitem><para>A space-separated list
386 of URIs referencing documentation for
387 this unit or its
388 configuration. Accepted are only URIs
389 of the types
390 <literal>http://</literal>,
391 <literal>https://</literal>,
392 <literal>file:</literal>,
393 <literal>info:</literal>,
394 <literal>man:</literal>. For more
395 information about the syntax of these
396 URIs, see
397 <citerefentry><refentrytitle>uri</refentrytitle><manvolnum>7</manvolnum></citerefentry>. The
398 URIs should be listed in order of
399 relevance, starting with the most
400 relevant. It is a good idea to first
401 reference documentation that explains
402 what the unit's purpose is, followed
403 by how it is configured, followed by
404 any other related documentation. This
405 option may be specified more than once
406 in which case the specified list of
407 URIs is merged. If the empty string is
408 assigned to this option, the list is
409 reset and all prior assignments will
410 have no effect.</para></listitem>
411 </varlistentry>
412
413 <varlistentry>
414 <term><varname>Requires=</varname></term>
415
416 <listitem><para>Configures requirement
417 dependencies on other units. If this
418 unit gets activated, the units listed
419 here will be activated as well. If one
420 of the other units gets deactivated or
421 its activation fails, this unit will
422 be deactivated. This option may be
423 specified more than once, in which
424 case requirement dependencies for all
425 listed names are created. Note that
426 requirement dependencies do not
427 influence the order in which services
428 are started or stopped. This has to be
429 configured independently with the
430 <varname>After=</varname> or
431 <varname>Before=</varname> options. If
432 a unit
433 <filename>foo.service</filename>
434 requires a unit
435 <filename>bar.service</filename> as
436 configured with
437 <varname>Requires=</varname> and no
438 ordering is configured with
439 <varname>After=</varname> or
440 <varname>Before=</varname>, then both
441 units will be started simultaneously
442 and without any delay between them if
443 <filename>foo.service</filename> is
444 activated. Often it is a better choice
445 to use <varname>Wants=</varname>
446 instead of
447 <varname>Requires=</varname> in order
448 to achieve a system that is more
449 robust when dealing with failing
450 services.</para>
451
452 <para>Note that dependencies of this
453 type may also be configured outside of
454 the unit configuration file by
455 adding a symlink to a
456 <filename>.requires/</filename> directory
457 accompanying the unit file. For
458 details see above.</para></listitem>
459 </varlistentry>
460
461 <varlistentry>
462 <term><varname>RequiresOverridable=</varname></term>
463
464 <listitem><para>Similar to
465 <varname>Requires=</varname>.
466 Dependencies listed in
467 <varname>RequiresOverridable=</varname>
468 which cannot be fulfilled or fail to
469 start are ignored if the startup was
470 explicitly requested by the user. If
471 the start-up was pulled in indirectly
472 by some dependency or automatic
473 start-up of units that is not
474 requested by the user this dependency
475 must be fulfilled and otherwise the
476 transaction fails. Hence, this option
477 may be used to configure dependencies
478 that are normally honored unless the
479 user explicitly starts up the unit, in
480 which case whether they failed or not
481 is irrelevant.</para></listitem>
482
483 </varlistentry>
484 <varlistentry>
485 <term><varname>Requisite=</varname></term>
486 <term><varname>RequisiteOverridable=</varname></term>
487
488 <listitem><para>Similar to
489 <varname>Requires=</varname>
490 and <varname>RequiresOverridable=</varname>, respectively. However,
491 if a unit listed here is not started
492 already it will not be started and the
493 transaction fails
494 immediately.</para></listitem>
495 </varlistentry>
496
497 <varlistentry>
498 <term><varname>Wants=</varname></term>
499
500 <listitem><para>A weaker version of
501 <varname>Requires=</varname>. A unit
502 listed in this option will be started
503 if the configuring unit is. However,
504 if the listed unit fails to start up
505 or cannot be added to the transaction
506 this has no impact on the validity of
507 the transaction as a whole. This is
508 the recommended way to hook start-up
509 of one unit to the start-up of another
510 unit.</para>
511
512 <para>Note that dependencies of this
513 type may also be configured outside of
514 the unit configuration file by
515 adding a symlink to a
516 <filename>.wants/</filename> directory
517 accompanying the unit file. For
518 details see above.</para></listitem>
519 </varlistentry>
520
521 <varlistentry>
522 <term><varname>BindsTo=</varname></term>
523
524 <listitem><para>Configures requirement
525 dependencies, very similar in style to
526 <varname>Requires=</varname>, however
527 in addition to this behavior it also
528 declares that this unit is stopped
529 when any of the units listed suddenly
530 disappears. Units can suddenly,
531 unexpectedly disappear if a service
532 terminates on its own choice, a device
533 is unplugged or a mount point
534 unmounted without involvement of
535 systemd.</para></listitem>
536 </varlistentry>
537
538 <varlistentry>
539 <term><varname>PartOf=</varname></term>
540
541 <listitem><para>Configures dependencies
542 similar to <varname>Requires=</varname>,
543 but limited to stopping and restarting
544 of units. When systemd stops or restarts
545 the units listed here, the action is
546 propagated to this unit.
547 Note that this is a one way dependency -
548 changes to this unit do not affect the
549 listed units.
550 </para></listitem>
551 </varlistentry>
552
553 <varlistentry>
554 <term><varname>Conflicts=</varname></term>
555
556 <listitem><para>Configures negative
557 requirement dependencies. If a unit
558 has a
559 <varname>Conflicts=</varname> setting
560 on another unit, starting the former
561 will stop the latter and vice
562 versa. Note that this setting is
563 independent of and orthogonal to the
564 <varname>After=</varname> and
565 <varname>Before=</varname> ordering
566 dependencies.</para>
567
568 <para>If a unit A that conflicts with
569 a unit B is scheduled to be started at
570 the same time as B, the transaction
571 will either fail (in case both are
572 required part of the transaction) or
573 be modified to be fixed (in case one
574 or both jobs are not a required part
575 of the transaction). In the latter
576 case the job that is not the required
577 will be removed, or in case both are
578 not required the unit that conflicts
579 will be started and the unit that is
580 conflicted is
581 stopped.</para></listitem>
582 </varlistentry>
583
584 <varlistentry>
585 <term><varname>Before=</varname></term>
586 <term><varname>After=</varname></term>
587
588 <listitem><para>Configures ordering
589 dependencies between units. If a unit
590 <filename>foo.service</filename>
591 contains a setting
592 <option>Before=bar.service</option>
593 and both units are being started,
594 <filename>bar.service</filename>'s
595 start-up is delayed until
596 <filename>foo.service</filename> is
597 started up. Note that this setting is
598 independent of and orthogonal to the
599 requirement dependencies as configured
600 by <varname>Requires=</varname>. It is
601 a common pattern to include a unit
602 name in both the
603 <varname>After=</varname> and
604 <varname>Requires=</varname> option in
605 which case the unit listed will be
606 started before the unit that is
607 configured with these options. This
608 option may be specified more than
609 once, in which case ordering
610 dependencies for all listed names are
611 created. <varname>After=</varname> is
612 the inverse of
613 <varname>Before=</varname>, i.e. while
614 <varname>After=</varname> ensures that
615 the configured unit is started after
616 the listed unit finished starting up,
617 <varname>Before=</varname> ensures the
618 opposite, i.e. that the configured
619 unit is fully started up before the
620 listed unit is started. Note that when
621 two units with an ordering dependency
622 between them are shut down, the
623 inverse of the start-up order is
624 applied. i.e. if a unit is configured
625 with <varname>After=</varname> on
626 another unit, the former is stopped
627 before the latter if both are shut
628 down. If one unit with an ordering
629 dependency on another unit is shut
630 down while the latter is started up,
631 the shut down is ordered before the
632 start-up regardless whether the
633 ordering dependency is actually of
634 type <varname>After=</varname> or
635 <varname>Before=</varname>. If two
636 units have no ordering dependencies
637 between them they are shut down
638 or started up simultaneously, and
639 no ordering takes
640 place. </para></listitem>
641 </varlistentry>
642
643 <varlistentry>
644 <term><varname>OnFailure=</varname></term>
645
646 <listitem><para>Lists one or more
647 units that are activated when this
648 unit enters the
649 <literal>failed</literal>
650 state.</para></listitem>
651 </varlistentry>
652
653 <varlistentry>
654 <term><varname>PropagatesReloadTo=</varname></term>
655 <term><varname>ReloadPropagatedFrom=</varname></term>
656
657 <listitem><para>Lists one or more
658 units where reload requests on the
659 unit will be propagated to/on the
660 other unit will be propagated
661 from. Issuing a reload request on a
662 unit will automatically also enqueue a
663 reload request on all units that the
664 reload request shall be propagated to
665 via these two
666 settings.</para></listitem>
667 </varlistentry>
668
669 <varlistentry>
670 <term><varname>RequiresMountsFor=</varname></term>
671
672 <listitem><para>Takes a space-separated
673 list of absolute paths. Automatically
674 adds dependencies of type
675 <varname>Requires=</varname> and
676 <varname>After=</varname> for all
677 mount units required to access the
678 specified path.</para></listitem>
679 </varlistentry>
680
681 <varlistentry>
682 <term><varname>OnFailureIsolate=</varname></term>
683
684 <listitem><para>Takes a boolean
685 argument. If <option>true</option> the
686 unit listed in
687 <varname>OnFailure=</varname> will be
688 enqueued in isolation mode, i.e. all
689 units that are not its dependency will
690 be stopped. If this is set only a
691 single unit may be listed in
692 <varname>OnFailure=</varname>. Defaults
693 to
694 <option>false</option>.</para></listitem>
695 </varlistentry>
696
697 <varlistentry>
698 <term><varname>IgnoreOnIsolate=</varname></term>
699
700 <listitem><para>Takes a boolean
701 argument. If <option>true</option>
702 this unit will not be stopped when
703 isolating another unit. Defaults to
704 <option>false</option>.</para></listitem>
705 </varlistentry>
706
707 <varlistentry>
708 <term><varname>IgnoreOnSnapshot=</varname></term>
709
710 <listitem><para>Takes a boolean
711 argument. If <option>true</option>
712 this unit will not be included in
713 snapshots. Defaults to
714 <option>true</option> for device and
715 snapshot units, <option>false</option>
716 for the others.</para></listitem>
717 </varlistentry>
718
719 <varlistentry>
720 <term><varname>StopWhenUnneeded=</varname></term>
721
722 <listitem><para>Takes a boolean
723 argument. If <option>true</option>
724 this unit will be stopped when it is
725 no longer used. Note that in order to
726 minimize the work to be executed,
727 systemd will not stop units by default
728 unless they are conflicting with other
729 units, or the user explicitly
730 requested their shut down. If this
731 option is set, a unit will be
732 automatically cleaned up if no other
733 active unit requires it. Defaults to
734 <option>false</option>.</para></listitem>
735 </varlistentry>
736
737 <varlistentry>
738 <term><varname>RefuseManualStart=</varname></term>
739 <term><varname>RefuseManualStop=</varname></term>
740
741 <listitem><para>Takes a boolean
742 argument. If <option>true</option>
743 this unit can only be activated
744 or deactivated indirectly. In
745 this case explicit start-up
746 or termination requested by the
747 user is denied, however if it is
748 started or stopped as a
749 dependency of another unit, start-up
750 or termination will succeed. This
751 is mostly a safety feature to ensure
752 that the user does not accidentally
753 activate units that are not intended
754 to be activated explicitly, and not
755 accidentally deactivate units that are
756 not intended to be deactivated.
757 These options default to
758 <option>false</option>.</para></listitem>
759 </varlistentry>
760
761 <varlistentry>
762 <term><varname>AllowIsolate=</varname></term>
763
764 <listitem><para>Takes a boolean
765 argument. If <option>true</option>
766 this unit may be used with the
767 <command>systemctl isolate</command>
768 command. Otherwise this will be
769 refused. It probably is a good idea to
770 leave this disabled except for target
771 units that shall be used similar to
772 runlevels in SysV init systems, just
773 as a precaution to avoid unusable
774 system states. This option defaults to
775 <option>false</option>.</para></listitem>
776 </varlistentry>
777
778 <varlistentry>
779 <term><varname>DefaultDependencies=</varname></term>
780
781 <listitem><para>Takes a boolean
782 argument. If <option>true</option>
783 (the default), a few default
784 dependencies will implicitly be
785 created for the unit. The actual
786 dependencies created depend on the
787 unit type. For example, for service
788 units, these dependencies ensure that
789 the service is started only after
790 basic system initialization is
791 completed and is properly terminated on
792 system shutdown. See the respective
793 man pages for details. Generally, only
794 services involved with early boot or
795 late shutdown should set this option
796 to <option>false</option>. It is
797 highly recommended to leave this
798 option enabled for the majority of
799 common units. If set to
800 <option>false</option>, this option
801 does not disable all implicit
802 dependencies, just non-essential
803 ones.</para></listitem>
804 </varlistentry>
805
806 <varlistentry>
807 <term><varname>JobTimeoutSec=</varname></term>
808
809 <listitem><para>When clients are
810 waiting for a job of this unit to
811 complete, time out after the specified
812 time. If this time limit is reached
813 the job will be cancelled, the unit
814 however will not change state or even
815 enter the <literal>failed</literal>
816 mode. This value defaults to 0 (job
817 timeouts disabled), except for device
818 units. NB: this timeout is independent
819 from any unit-specific timeout (for
820 example, the timeout set with
821 <varname>Timeout=</varname> in service
822 units) as the job timeout has no
823 effect on the unit itself, only on the
824 job that might be pending for it. Or
825 in other words: unit-specific timeouts
826 are useful to abort unit state
827 changes, and revert them. The job
828 timeout set with this option however
829 is useful to abort only the job
830 waiting for the unit state to
831 change.</para></listitem>
832 </varlistentry>
833
834 <varlistentry>
835 <term><varname>ConditionPathExists=</varname></term>
836 <term><varname>ConditionPathExistsGlob=</varname></term>
837 <term><varname>ConditionPathIsDirectory=</varname></term>
838 <term><varname>ConditionPathIsSymbolicLink=</varname></term>
839 <term><varname>ConditionPathIsMountPoint=</varname></term>
840 <term><varname>ConditionPathIsReadWrite=</varname></term>
841 <term><varname>ConditionDirectoryNotEmpty=</varname></term>
842 <term><varname>ConditionFileNotEmpty=</varname></term>
843 <term><varname>ConditionFileIsExecutable=</varname></term>
844 <term><varname>ConditionKernelCommandLine=</varname></term>
845 <term><varname>ConditionVirtualization=</varname></term>
846 <term><varname>ConditionSecurity=</varname></term>
847 <term><varname>ConditionCapability=</varname></term>
848 <term><varname>ConditionHost=</varname></term>
849 <term><varname>ConditionACPower=</varname></term>
850 <term><varname>ConditionNull=</varname></term>
851
852 <listitem><para>Before starting a unit
853 verify that the specified condition is
854 true. If it is not true the starting
855 of the unit will be skipped, however
856 all ordering dependencies of it are
857 still respected. A failing condition
858 will not result in the unit being
859 moved into a failure state. The
860 condition is checked at the time the
861 queued start job is to be
862 executed.</para>
863
864 <para>With
865 <varname>ConditionPathExists=</varname>
866 a file existence condition is
867 checked before a unit is started. If
868 the specified absolute path name does
869 not exist the condition will
870 fail. If the absolute path name passed
871 to
872 <varname>ConditionPathExists=</varname>
873 is prefixed with an exclamation mark
874 (<literal>!</literal>), the test is negated, and the unit
875 is only started if the path does not
876 exist.</para>
877
878 <para><varname>ConditionPathExistsGlob=</varname>
879 is similar to
880 <varname>ConditionPathExists=</varname>,
881 but checks for the existence of at
882 least one file or directory matching
883 the specified globbing pattern.</para>
884
885 <para><varname>ConditionPathIsDirectory=</varname>
886 is similar to
887 <varname>ConditionPathExists=</varname>
888 but verifies whether a certain path
889 exists and is a
890 directory.</para>
891
892 <para><varname>ConditionPathIsSymbolicLink=</varname>
893 is similar to
894 <varname>ConditionPathExists=</varname>
895 but verifies whether a certain path
896 exists and is a symbolic
897 link.</para>
898
899 <para><varname>ConditionPathIsMountPoint=</varname>
900 is similar to
901 <varname>ConditionPathExists=</varname>
902 but verifies whether a certain path
903 exists and is a mount
904 point.</para>
905
906 <para><varname>ConditionPathIsReadWrite=</varname>
907 is similar to
908 <varname>ConditionPathExists=</varname>
909 but verifies whether the underlying
910 file system is readable and writable
911 (i.e. not mounted
912 read-only).</para>
913
914 <para><varname>ConditionDirectoryNotEmpty=</varname>
915 is similar to
916 <varname>ConditionPathExists=</varname>
917 but verifies whether a certain path
918 exists and is a non-empty
919 directory.</para>
920
921 <para><varname>ConditionFileNotEmpty=</varname>
922 is similar to
923 <varname>ConditionPathExists=</varname>
924 but verifies whether a certain path
925 exists and refers to a regular file
926 with a non-zero size.</para>
927
928 <para><varname>ConditionFileIsExecutable=</varname>
929 is similar to
930 <varname>ConditionPathExists=</varname>
931 but verifies whether a certain path
932 exists, is a regular file and marked
933 executable.</para>
934
935 <para>Similar,
936 <varname>ConditionKernelCommandLine=</varname>
937 may be used to check whether a
938 specific kernel command line option is
939 set (or if prefixed with the
940 exclamation mark unset). The argument
941 must either be a single word, or an
942 assignment (i.e. two words, separated
943 <literal>=</literal>). In the former
944 case the kernel command line is
945 searched for the word appearing as is,
946 or as left hand side of an
947 assignment. In the latter case the
948 exact assignment is looked for with
949 right and left hand side
950 matching.</para>
951
952 <para><varname>ConditionVirtualization=</varname>
953 may be used to check whether the
954 system is executed in a virtualized
955 environment and optionally test
956 whether it is a specific
957 implementation. Takes either boolean
958 value to check if being executed in
959 any virtualized environment, or one of
960 <varname>vm</varname> and
961 <varname>container</varname> to test
962 against a generic type of
963 virtualization solution, or one of
964 <varname>qemu</varname>,
965 <varname>kvm</varname>,
966 <varname>vmware</varname>,
967 <varname>microsoft</varname>,
968 <varname>oracle</varname>,
969 <varname>xen</varname>,
970 <varname>bochs</varname>,
971 <varname>chroot</varname>,
972 <varname>openvz</varname>,
973 <varname>lxc</varname>,
974 <varname>lxc-libvirt</varname>,
975 <varname>systemd-nspawn</varname> to
976 test against a specific
977 implementation. If multiple
978 virtualization technologies are nested
979 only the innermost is considered. The
980 test may be negated by prepending an
981 exclamation mark.</para>
982
983 <para><varname>ConditionSecurity=</varname>
984 may be used to check whether the given
985 security module is enabled on the
986 system. Currently the recognized values
987 values are <varname>selinux</varname>,
988 <varname>apparmor</varname>,
989 <varname>ima</varname> and
990 <varname>smack</varname>.
991 The test may be negated by prepending
992 an exclamation
993 mark.</para>
994
995 <para><varname>ConditionCapability=</varname>
996 may be used to check whether the given
997 capability exists in the capability
998 bounding set of the service manager
999 (i.e. this does not check whether
1000 capability is actually available in
1001 the permitted or effective sets, see
1002 <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
1003 for details). Pass a capability name
1004 such as <literal>CAP_MKNOD</literal>,
1005 possibly prefixed with an exclamation
1006 mark to negate the check.</para>
1007
1008 <para><varname>ConditionHost=</varname>
1009 may be used to match against the
1010 hostname or machine ID of the
1011 host. This either takes a hostname
1012 string (optionally with shell style
1013 globs) which is tested against the
1014 locally set hostname as returned by
1015 <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1016 or a machine ID formatted as string
1017 (see
1018 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
1019 The test may be negated by prepending
1020 an exclamation mark.</para>
1021
1022 <para><varname>ConditionACPower=</varname>
1023 may be used to check whether the
1024 system has AC power, or is exclusively
1025 battery powered at the time of
1026 activation of the unit. This takes a
1027 boolean argument. If set to
1028 <varname>true</varname> the condition
1029 will hold only if at least one AC
1030 connector of the system is connected
1031 to a power source, or if no AC
1032 connectors are known. Conversely, if
1033 set to <varname>false</varname> the
1034 condition will hold only if there is
1035 at least one AC connector known and
1036 all AC connectors are disconnected
1037 from a power source.</para>
1038
1039 <para>Finally,
1040 <varname>ConditionNull=</varname> may
1041 be used to add a constant condition
1042 check value to the unit. It takes a
1043 boolean argument. If set to
1044 <varname>false</varname> the condition
1045 will always fail, otherwise
1046 succeed.</para>
1047
1048 <para>If multiple conditions are
1049 specified the unit will be executed if
1050 all of them apply (i.e. a logical AND
1051 is applied). Condition checks can be
1052 prefixed with a pipe symbol (|) in
1053 which case a condition becomes a
1054 triggering condition. If at least one
1055 triggering condition is defined for a
1056 unit then the unit will be executed if
1057 at least one of the triggering
1058 conditions apply and all of the
1059 non-triggering conditions. If you
1060 prefix an argument with the pipe
1061 symbol and an exclamation mark the
1062 pipe symbol must be passed first, the
1063 exclamation second. Except for
1064 <varname>ConditionPathIsSymbolicLink=</varname>,
1065 all path checks follow symlinks. If
1066 any of these options is assigned the
1067 empty string the list of conditions is
1068 reset completely, all previous
1069 condition settings (of any kind) will
1070 have no effect.</para></listitem>
1071 </varlistentry>
1072
1073 <varlistentry>
1074 <term><varname>SourcePath=</varname></term>
1075 <listitem><para>A path to a
1076 configuration file this unit has been
1077 generated from. This is primarily
1078 useful for implementation of generator
1079 tools that convert configuration from
1080 an external configuration file format
1081 into native unit files. Thus
1082 functionality should not be used in
1083 normal units.</para></listitem>
1084 </varlistentry>
1085 </variablelist>
1086
1087 <para>Unit file may include a [Install] section, which
1088 carries installation information for the unit. This
1089 section is not interpreted by
1090 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1091 during runtime. It is used exclusively by the
1092 <command>enable</command> and
1093 <command>disable</command> commands of the
1094 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1095 tool during installation of a unit:</para>
1096
1097 <variablelist class='unit-directives'>
1098 <varlistentry>
1099 <term><varname>Alias=</varname></term>
1100
1101 <listitem><para>Additional names this
1102 unit shall be installed under. The
1103 names listed here must have the same
1104 suffix (i.e. type) as the unit file
1105 name. This option may be specified
1106 more than once, in which case all
1107 listed names are used. At installation
1108 time,
1109 <command>systemctl enable</command>
1110 will create symlinks from these names
1111 to the unit filename.</para></listitem>
1112 </varlistentry>
1113
1114 <varlistentry>
1115 <term><varname>WantedBy=</varname></term>
1116 <term><varname>RequiredBy=</varname></term>
1117
1118 <listitem><para>Installs a symlink in
1119 the <filename>.wants/</filename>
1120 or <filename>.requires/</filename>
1121 subdirectory for a unit, respectively. This has the
1122 effect that when the listed unit name
1123 is activated the unit listing it is
1124 activated
1125 too. <command>WantedBy=foo.service</command>
1126 in a service
1127 <filename>bar.service</filename> is
1128 mostly equivalent to
1129 <command>Alias=foo.service.wants/bar.service</command>
1130 in the same file.</para></listitem>
1131 </varlistentry>
1132
1133 <varlistentry>
1134 <term><varname>Also=</varname></term>
1135
1136 <listitem><para>Additional units to
1137 install/deinstall when this unit is
1138 installed/deinstalled. If the user
1139 requests installation/deinstallation
1140 of a unit with this option configured,
1141 <command>systemctl enable</command>
1142 and <command>systemctl
1143 disable</command> will automatically
1144 install/uninstall units listed in this option as
1145 well.</para></listitem>
1146 </varlistentry>
1147 </variablelist>
1148
1149 <para>The following specifiers are interpreted in the
1150 Install section: %n, %N, %p, %i, %U, %u, %m, %H, %b.
1151 For their meaning see the next section.
1152 </para>
1153 </refsect1>
1154
1155 <refsect1>
1156 <title>Specifiers</title>
1157
1158 <para>Many settings resolve specifiers which may be
1159 used to write generic unit files referring to runtime
1160 or unit parameters that are replaced when the unit
1161 files are loaded. The following specifiers are
1162 understood:</para>
1163
1164 <table>
1165 <title>Specifiers available in unit files</title>
1166 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
1167 <colspec colname="spec" />
1168 <colspec colname="mean" />
1169 <colspec colname="detail" />
1170 <thead>
1171 <row>
1172 <entry>Specifier</entry>
1173 <entry>Meaning</entry>
1174 <entry>Details</entry>
1175 </row>
1176 </thead>
1177 <tbody>
1178 <row>
1179 <entry><literal>%n</literal></entry>
1180 <entry>Full unit name</entry>
1181 <entry></entry>
1182 </row>
1183 <row>
1184 <entry><literal>%N</literal></entry>
1185 <entry>Unescaped full unit name</entry>
1186 <entry></entry>
1187 </row>
1188 <row>
1189 <entry><literal>%p</literal></entry>
1190 <entry>Prefix name</entry>
1191 <entry>For instantiated units this refers to the string before the @. For non-instantiated units this refers to to the name of the unit with the type suffix removed.</entry>
1192 </row>
1193 <row>
1194 <entry><literal>%P</literal></entry>
1195 <entry>Unescaped prefix name</entry>
1196 <entry></entry>
1197 </row>
1198 <row>
1199 <entry><literal>%i</literal></entry>
1200 <entry>Instance name</entry>
1201 <entry>For instantiated units: this is the string between the <literal>@</literal> character and the suffix.</entry>
1202 </row>
1203 <row>
1204 <entry><literal>%I</literal></entry>
1205 <entry>Unescaped instance name</entry>
1206 <entry></entry>
1207 </row>
1208 <row>
1209 <entry><literal>%f</literal></entry>
1210 <entry>Unescaped filename</entry>
1211 <entry>This is either the unescaped instance name (if applicable) with <filename>/</filename> prepended (if applicable), or the prefix name similarly prepended with <filename>/</filename>.</entry>
1212 </row>
1213 <row>
1214 <entry><literal>%c</literal></entry>
1215 <entry>Control group path of the unit</entry>
1216 <entry></entry>
1217 </row>
1218 <row>
1219 <entry><literal>%r</literal></entry>
1220 <entry>Root control group path where units are placed.</entry>
1221 <entry>For system instances this usually resolves to <filename>/system</filename>, except in containers, where the path might be prefixed with the container's root control group.</entry>
1222 </row>
1223 <row>
1224 <entry><literal>%R</literal></entry>
1225 <entry>Parent directory of the control group path where units are placed.</entry>
1226 <entry>For system instances this usually resolves to <filename>/</filename>, except in containers, where this resolves to the container's root directory. This specifier is particularly useful in the <varname>ControlGroup=</varname> setting (see <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>).</entry>
1227 </row>
1228 <row>
1229 <entry><literal>%t</literal></entry>
1230 <entry>Runtime socket dir</entry>
1231 <entry>This is either <filename>/run</filename> (for the system manager) or <literal>$XDG_RUNTIME_DIR</literal> (for user managers).</entry>
1232 </row>
1233 <row>
1234 <entry><literal>%u</literal></entry>
1235 <entry>User name</entry>
1236 <entry>This is the name of the configured user of the unit, or (if none is set) the user running the systemd instance.</entry>
1237 </row>
1238 <row>
1239 <entry><literal>%U</literal></entry>
1240 <entry>User UID</entry>
1241 <entry>This is the UID of the configured user of the unit, or (if none is set) the user running the systemd instance.</entry>
1242 </row>
1243 <row>
1244 <entry><literal>%h</literal></entry>
1245 <entry>User home directory</entry>
1246 <entry>This is the home directory of the configured user of the unit, or (if none is set) the user running the systemd instance.</entry>
1247 </row>
1248 <row>
1249 <entry><literal>%s</literal></entry>
1250 <entry>User shell</entry>
1251 <entry>This is the shell of the configured user of the unit, or (if none is set) the user running the systemd instance. If the user is <literal>root</literal> (UID equal to 0), the shell configured in account database is ignored and <filename>/bin/sh</filename> is always used.</entry>
1252 </row>
1253 <row>
1254 <entry><literal>%m</literal></entry>
1255 <entry>Machine ID</entry>
1256 <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>
1257 </row>
1258 <row>
1259 <entry><literal>%b</literal></entry>
1260 <entry>Boot ID</entry>
1261 <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
1262 </row>
1263 <row>
1264 <entry><literal>%H</literal></entry>
1265 <entry>Host name</entry>
1266 <entry>The hostname of the running system.</entry>
1267 </row>
1268 <row>
1269 <entry><literal>%%</literal></entry>
1270 <entry>Escaped %</entry>
1271 <entry>Single percent sign.</entry>
1272 </row>
1273 </tbody>
1274 </tgroup>
1275 </table>
1276 </refsect1>
1277
1278 <refsect1>
1279 <title>See Also</title>
1280 <para>
1281 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1282 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1283 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1284 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1285 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1286 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1287 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1288 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1289 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1290 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1291 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1292 <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1293 <citerefentry><refentrytitle>systemd.snapshot</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1294 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1295 <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1296 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
1297 </para>
1298 </refsect1>
1299
1300 </refentry>