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