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