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