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