]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.unit.xml
Merge pull request #7881 from keszybz/pcre
[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 SPDX-License-Identifier: LGPL-2.1+
10
11 This file is part of systemd.
12
13 Copyright 2010 Lennart Poettering
14
15 systemd is free software; you can redistribute it and/or modify it
16 under the terms of the GNU Lesser General Public License as published by
17 the Free Software Foundation; either version 2.1 of the License, or
18 (at your option) any later version.
19
20 systemd is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 Lesser General Public License for more details.
24
25 You should have received a copy of the GNU Lesser General Public License
26 along with systemd; If not, see <http://www.gnu.org/licenses/>.
27 -->
28
29 <refentry id="systemd.unit">
30
31 <refentryinfo>
32 <title>systemd.unit</title>
33 <productname>systemd</productname>
34
35 <authorgroup>
36 <author>
37 <contrib>Developer</contrib>
38 <firstname>Lennart</firstname>
39 <surname>Poettering</surname>
40 <email>lennart@poettering.net</email>
41 </author>
42 </authorgroup>
43 </refentryinfo>
44
45 <refmeta>
46 <refentrytitle>systemd.unit</refentrytitle>
47 <manvolnum>5</manvolnum>
48 </refmeta>
49
50 <refnamediv>
51 <refname>systemd.unit</refname>
52 <refpurpose>Unit configuration</refpurpose>
53 </refnamediv>
54
55 <refsynopsisdiv>
56 <para><filename><replaceable>service</replaceable>.service</filename>,
57 <filename><replaceable>socket</replaceable>.socket</filename>,
58 <filename><replaceable>device</replaceable>.device</filename>,
59 <filename><replaceable>mount</replaceable>.mount</filename>,
60 <filename><replaceable>automount</replaceable>.automount</filename>,
61 <filename><replaceable>swap</replaceable>.swap</filename>,
62 <filename><replaceable>target</replaceable>.target</filename>,
63 <filename><replaceable>path</replaceable>.path</filename>,
64 <filename><replaceable>timer</replaceable>.timer</filename>,
65 <filename><replaceable>slice</replaceable>.slice</filename>,
66 <filename><replaceable>scope</replaceable>.scope</filename></para>
67
68 <para><literallayout><filename>/etc/systemd/system/*</filename>
69 <filename>/run/systemd/system/*</filename>
70 <filename>/usr/lib/systemd/system/*</filename>
71 <filename></filename>
72 </literallayout></para>
73
74 <para><literallayout><filename>~/.config/systemd/user/*</filename>
75 <filename>/etc/systemd/user/*</filename>
76 <filename>$XDG_RUNTIME_DIR/systemd/user/*</filename>
77 <filename>/run/systemd/user/*</filename>
78 <filename>~/.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 various formats. A stand-alone
150 number specifies a time in seconds. If suffixed with a time unit, the unit is honored. A
151 concatenation of multiple values with units is supported, in which case the values are added
152 up. Example: <literal>50</literal> refers to 50 seconds; <literal>2min 200ms</literal> refers to
153 2 minutes and 200 milliseconds, i.e. 120200 ms. The following time units are understood:
154 <literal>s</literal>, <literal>min</literal>, <literal>h</literal>, <literal>d</literal>,
155 <literal>w</literal>, <literal>ms</literal>, <literal>us</literal>. For details see
156 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
157
158 <para>Empty lines and lines starting with <literal>#</literal> or <literal>;</literal> are
159 ignored. This may be used for commenting. Lines ending in a backslash are concatenated with the
160 following line while reading and the backslash is replaced by a space character. This may be
161 used to wrap long lines.</para>
162
163 <para>Units can be aliased (have an alternative name), by creating a symlink from the new name
164 to the existing name in one of the unit search paths. For example,
165 <filename>systemd-networkd.service</filename> has the alias
166 <filename>dbus-org.freedesktop.network1.service</filename>, created during installation as the
167 symlink <filename>/usr/lib/systemd/system/dbus-org.freedesktop.network1.service</filename>. In
168 addition, unit files may specify aliases through the <varname>Alias=</varname> directive in the
169 [Install] section; those aliases are only effective when the unit is enabled. When the unit is
170 enabled, symlinks will be created for those names, and removed when the unit is disabled. For
171 example, <filename>reboot.target</filename> specifies
172 <varname>Alias=ctrl-alt-del.target</varname>, so when enabled it will be invoked whenever
173 CTRL+ALT+DEL is pressed. Alias names may be used in commands like <command>enable</command>,
174 <command>disable</command>, <command>start</command>, <command>stop</command>,
175 <command>status</command>, …, and in unit dependency directives <varname>Wants=</varname>,
176 <varname>Requires=</varname>, <varname>Before=</varname>, <varname>After=</varname>, …, with the
177 limitation that aliases specified through <varname>Alias=</varname> are only effective when the
178 unit is enabled. Aliases cannot be used with the <command>preset</command> command.</para>
179
180 <para>Along with a unit file <filename>foo.service</filename>, the directory
181 <filename>foo.service.wants/</filename> may exist. All unit files symlinked from such a
182 directory are implicitly added as dependencies of type <varname>Wants=</varname> to the unit.
183 This is useful to hook units into the start-up of other units, without having to modify their
184 unit files. For details about the semantics of <varname>Wants=</varname>, see below. The
185 preferred way to create symlinks in the <filename>.wants/</filename> directory of a unit file is
186 with the <command>enable</command> command of the
187 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
188 tool which reads information from the [Install] section of unit files (see below). A similar
189 functionality exists for <varname>Requires=</varname> type dependencies as well, the directory
190 suffix is <filename>.requires/</filename> in this case.</para>
191
192 <para>Along with a unit file <filename>foo.service</filename>, a "drop-in" directory
193 <filename>foo.service.d/</filename> may exist. All files with the suffix
194 <literal>.conf</literal> from this directory will be parsed after the file itself is
195 parsed. This is useful to alter or add configuration settings for a unit, without having to
196 modify unit files. Each drop-in file must have appropriate section headers. Note that for
197 instantiated units, this logic will first look for the instance <literal>.d/</literal>
198 subdirectory and read its <literal>.conf</literal> files, followed by the template
199 <literal>.d/</literal> subdirectory and the <literal>.conf</literal> files there.</para>
200
201 <para>In addition to <filename>/etc/systemd/system</filename>, the drop-in <literal>.d</literal>
202 directories for system services can be placed in <filename>/usr/lib/systemd/system</filename> or
203 <filename>/run/systemd/system</filename> directories. Drop-in files in <filename>/etc</filename>
204 take precedence over those in <filename>/run</filename> which in turn take precedence over those
205 in <filename>/usr/lib</filename>. Drop-in files under any of these directories take precedence
206 over unit files wherever located. Multiple drop-in files with different names are applied in
207 lexicographic order, regardless of which of the directories they reside in.</para>
208
209 <!-- Note that we do not document .include here, as we consider it mostly obsolete, and want
210 people to use .d/ drop-ins instead. -->
211
212 <para>Note that while systemd offers a flexible dependency system
213 between units it is recommended to use this functionality only
214 sparingly and instead rely on techniques such as bus-based or
215 socket-based activation which make dependencies implicit,
216 resulting in a both simpler and more flexible system.</para>
217
218 <para>Optionally, units may be instantiated from a
219 template file at runtime. This allows creation of
220 multiple units from a single configuration file. If
221 systemd looks for a unit configuration file, it will
222 first search for the literal unit name in the
223 file system. If that yields no success and the unit
224 name contains an <literal>@</literal> character, systemd will look for a
225 unit template that shares the same name but with the
226 instance string (i.e. the part between the <literal>@</literal> character
227 and the suffix) removed. Example: if a service
228 <filename>getty@tty3.service</filename> is requested
229 and no file by that name is found, systemd will look
230 for <filename>getty@.service</filename> and
231 instantiate a service from that configuration file if
232 it is found.</para>
233
234 <para>To refer to the instance string from within the
235 configuration file you may use the special <literal>%i</literal>
236 specifier in many of the configuration options. See below for
237 details.</para>
238
239 <para>If a unit file is empty (i.e. has the file size 0) or is
240 symlinked to <filename>/dev/null</filename>, its configuration
241 will not be loaded and it appears with a load state of
242 <literal>masked</literal>, and cannot be activated. Use this as an
243 effective way to fully disable a unit, making it impossible to
244 start it even manually.</para>
245
246 <para>The unit file format is covered by the
247 <ulink
248 url="https://www.freedesktop.org/wiki/Software/systemd/InterfaceStabilityPromise">Interface
249 Stability Promise</ulink>.</para>
250
251 </refsect1>
252
253 <refsect1>
254 <title>String Escaping for Inclusion in Unit Names</title>
255
256 <para>Sometimes it is useful to convert arbitrary strings into unit names. To facilitate this, a method of string
257 escaping is used, in order to map strings containing arbitrary byte values (except NUL) into valid unit names and
258 their restricted character set. A common special case are unit names that reflect paths to objects in the file
259 system hierarchy. Example: a device unit <filename>dev-sda.device</filename> refers to a device with the device
260 node <filename noindex='true'>/dev/sda</filename> in the file system.</para>
261
262 <para>The escaping algorithm operates as follows: given a string, any <literal>/</literal> character is replaced by
263 <literal>-</literal>, and all other characters which are not ASCII alphanumerics or <literal>_</literal> are
264 replaced by C-style <literal>\x2d</literal> escapes. In addition, <literal>.</literal> is replaced with such a
265 C-style escape when it would appear as the first character in the escaped string.</para>
266
267 <para>When the input qualifies as absolute file system path, this algorithm is extended slightly: the path to the
268 root directory <literal>/</literal> is encoded as single dash <literal>-</literal>. In addition, any leading,
269 trailing or duplicate <literal>/</literal> characters are removed from the string before transformation. Example:
270 <filename>/foo//bar/baz/</filename> becomes <literal>foo-bar-baz</literal>.</para>
271
272 <para>This escaping is fully reversible, as long as it is known whether the escaped string was a path (the
273 unescaping results are different for paths and non-path strings). The
274 <citerefentry><refentrytitle>systemd-escape</refentrytitle><manvolnum>1</manvolnum></citerefentry> command may be
275 used to apply and reverse escaping on arbitrary strings. Use <command>systemd-escape --path</command> to escape
276 path strings, and <command>systemd-escape</command> without <option>--path</option> otherwise.</para>
277 </refsect1>
278
279 <refsect1>
280 <title>Implicit Dependencies</title>
281
282 <para>A number of unit dependencies are implicitly established,
283 depending on unit type and unit configuration. These implicit
284 dependencies can make unit configuration file cleaner. For the
285 implicit dependencies in each unit type, please refer to
286 section "Implicit Dependencies" in respective man pages.</para>
287
288 <para>For example, service units with <varname>Type=dbus</varname>
289 automatically acquire dependencies of type <varname>Requires=</varname>
290 and <varname>After=</varname> on <filename>dbus.socket</filename>. See
291 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
292 for details.</para>
293 </refsect1>
294
295 <refsect1>
296 <title>Default Dependencies</title>
297
298 <para>Default dependencies are similar to implicit dependencies,
299 but can be turned on and off by setting
300 <varname>DefaultDependencies=</varname> to <varname>yes</varname>
301 (the default) and <varname>no</varname>, while implicit dependencies
302 are always in effect. See section "Default Dependencies" in respective
303 man pages for the effect of enabling
304 <varname>DefaultDependencies=</varname> in each unit types.</para>
305
306 <para>For example, target units will complement all configured
307 dependencies of type <varname>Wants=</varname> or
308 <varname>Requires=</varname> with dependencies of type
309 <varname>After=</varname> unless <varname>DefaultDependencies=no</varname>
310 is set in the specified units. See
311 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>
312 for details. Note that this behavior can be turned off by setting
313 <varname>DefaultDependencies=no</varname>.</para>
314 </refsect1>
315
316 <refsect1>
317 <title>Unit File Load Path</title>
318
319 <para>Unit files are loaded from a set of paths determined during
320 compilation, described in the two tables below. Unit files found
321 in directories listed earlier override files with the same name in
322 directories lower in the list.</para>
323
324 <para>When the variable <varname>$SYSTEMD_UNIT_PATH</varname> is set,
325 the contents of this variable overrides the unit load path. If
326 <varname>$SYSTEMD_UNIT_PATH</varname> ends with an empty component
327 (<literal>:</literal>), the usual unit load path will be appended
328 to the contents of the variable.</para>
329
330 <table>
331 <title>
332 Load path when running in system mode (<option>--system</option>).
333 </title>
334
335 <tgroup cols='2'>
336 <colspec colname='path' />
337 <colspec colname='expl' />
338 <thead>
339 <row>
340 <entry>Path</entry>
341 <entry>Description</entry>
342 </row>
343 </thead>
344 <tbody>
345 <row>
346 <entry><filename>/etc/systemd/system</filename></entry>
347 <entry>Local configuration</entry>
348 </row>
349 <row>
350 <entry><filename>/run/systemd/system</filename></entry>
351 <entry>Runtime units</entry>
352 </row>
353 <row>
354 <entry><filename>/usr/lib/systemd/system</filename></entry>
355 <entry>Units of installed packages</entry>
356 </row>
357 </tbody>
358 </tgroup>
359 </table>
360
361 <table>
362 <title>
363 Load path when running in user mode (<option>--user</option>).
364 </title>
365
366 <tgroup cols='2'>
367 <colspec colname='path' />
368 <colspec colname='expl' />
369 <thead>
370 <row>
371 <entry>Path</entry>
372 <entry>Description</entry>
373 </row>
374 </thead>
375 <tbody>
376 <row>
377 <entry><filename>$XDG_CONFIG_HOME/systemd/user</filename></entry>
378 <entry>User configuration (only used when $XDG_CONFIG_HOME is set)</entry>
379 </row>
380 <row>
381 <entry><filename>$HOME/.config/systemd/user</filename></entry>
382 <entry>User configuration (only used when $XDG_CONFIG_HOME is not set)</entry>
383 </row>
384 <row>
385 <entry><filename>/etc/systemd/user</filename></entry>
386 <entry>Local configuration</entry>
387 </row>
388 <row>
389 <entry><filename>$XDG_RUNTIME_DIR/systemd/user</filename></entry>
390 <entry>Runtime units (only used when $XDG_RUNTIME_DIR is set)</entry>
391 </row>
392 <row>
393 <entry><filename>/run/systemd/user</filename></entry>
394 <entry>Runtime units</entry>
395 </row>
396 <row>
397 <entry><filename>$XDG_DATA_HOME/systemd/user</filename></entry>
398 <entry>Units of packages that have been installed in the home directory (only used when $XDG_DATA_HOME is set)</entry>
399 </row>
400 <row>
401 <entry><filename>$HOME/.local/share/systemd/user</filename></entry>
402 <entry>Units of packages that have been installed in the home directory (only used when $XDG_DATA_HOME is not set)</entry>
403 </row>
404 <row>
405 <entry><filename>/usr/lib/systemd/user</filename></entry>
406 <entry>Units of packages that have been installed system-wide</entry>
407 </row>
408 </tbody>
409 </tgroup>
410 </table>
411
412 <para>Additional units might be loaded into systemd ("linked")
413 from directories not on the unit load path. See the
414 <command>link</command> command for
415 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
416 Also, some units are dynamically created via a
417 <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
418 </para>
419 </refsect1>
420
421 <refsect1>
422 <title>Unit Garbage Collection</title>
423
424 <para>The system and service manager loads a unit's configuration automatically when a unit is referenced for the
425 first time. It will automatically unload the unit configuration and state again when the unit is not needed anymore
426 ("garbage collection"). A unit may be referenced through a number of different mechanisms:</para>
427
428 <orderedlist>
429 <listitem><para>Another loaded unit references it with a dependency such as <varname>After=</varname>,
430 <varname>Wants=</varname>, …</para></listitem>
431
432 <listitem><para>The unit is currently starting, running, reloading or stopping.</para></listitem>
433
434 <listitem><para>The unit is currently in the <constant>failed</constant> state. (But see below.)</para></listitem>
435
436 <listitem><para>A job for the unit is pending.</para></listitem>
437
438 <listitem><para>The unit is pinned by an active IPC client program.</para></listitem>
439
440 <listitem><para>The unit is a special "perpetual" unit that is always active and loaded. Examples for perpetual
441 units are the root mount unit <filename>-.mount</filename> or the scope unit <filename>init.scope</filename> that
442 the service manager itself lives in.</para></listitem>
443
444 <listitem><para>The unit has running processes associated with it.</para></listitem>
445 </orderedlist>
446
447 <para>The garbage collection logic may be altered with the <varname>CollectMode=</varname> option, which allows
448 configuration whether automatic unloading of units that are in <constant>failed</constant> state is permissible,
449 see below.</para>
450
451 <para>Note that when a unit's configuration and state is unloaded, all execution results, such as exit codes, exit
452 signals, resource consumption and other statistics are lost, except for what is stored in the log subsystem.</para>
453
454 <para>Use <command>systemctl daemon-reload</command> or an equivalent command to reload unit configuration while
455 the unit is already loaded. In this case all configuration settings are flushed out and replaced with the new
456 configuration (which however might not be in effect immediately), however all runtime state is
457 saved/restored.</para>
458 </refsect1>
459
460 <refsect1>
461 <title>[Unit] Section Options</title>
462
463 <para>The unit file may include a [Unit] section, which carries
464 generic information about the unit that is not dependent on the
465 type of unit:</para>
466
467 <variablelist class='unit-directives'>
468
469 <varlistentry>
470 <term><varname>Description=</varname></term>
471 <listitem><para>A free-form string describing the unit. This
472 is intended for use in UIs to show descriptive information
473 along with the unit name. The description should contain a
474 name that means something to the end user. <literal>Apache2
475 Web Server</literal> is a good example. Bad examples are
476 <literal>high-performance light-weight HTTP server</literal>
477 (too generic) or <literal>Apache2</literal> (too specific and
478 meaningless for people who do not know
479 Apache).</para></listitem>
480 </varlistentry>
481
482 <varlistentry>
483 <term><varname>Documentation=</varname></term>
484 <listitem><para>A space-separated list of URIs referencing
485 documentation for this unit or its configuration. Accepted are
486 only URIs of the types <literal>http://</literal>,
487 <literal>https://</literal>, <literal>file:</literal>,
488 <literal>info:</literal>, <literal>man:</literal>. For more
489 information about the syntax of these URIs, see <citerefentry
490 project='man-pages'><refentrytitle>uri</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
491 The URIs should be listed in order of relevance, starting with
492 the most relevant. It is a good idea to first reference
493 documentation that explains what the unit's purpose is,
494 followed by how it is configured, followed by any other
495 related documentation. This option may be specified more than
496 once, in which case the specified list of URIs is merged. If
497 the empty string is assigned to this option, the list is reset
498 and all prior assignments will have no
499 effect.</para></listitem>
500 </varlistentry>
501
502 <varlistentry>
503 <term><varname>Requires=</varname></term>
504
505 <listitem><para>Configures requirement dependencies on other units. If this unit gets activated, the units
506 listed here will be activated as well. If one of the other units fails to activate, and an ordering dependency
507 <varname>After=</varname> on the failing unit is set, this unit will not be started. Besides, with or without
508 specifying <varname>After=</varname>, this unit will be stopped if one of the other units is explicitly
509 stopped. This option may be specified more than once or multiple space-separated units may be
510 specified in one option in which case requirement dependencies for all listed names will be created. Note that
511 requirement dependencies do not influence the order in which services are started or stopped. This has to be
512 configured independently with the <varname>After=</varname> or <varname>Before=</varname> options. If a unit
513 <filename>foo.service</filename> requires a unit <filename>bar.service</filename> as configured with
514 <varname>Requires=</varname> and no ordering is configured with <varname>After=</varname> or
515 <varname>Before=</varname>, then both units will be started simultaneously and without any delay between them
516 if <filename>foo.service</filename> is activated. Often, it is a better choice to use <varname>Wants=</varname>
517 instead of <varname>Requires=</varname> in order to achieve a system that is more robust when dealing with
518 failing services.</para>
519
520 <para>Note that this dependency type does not imply that the other unit always has to be in active state when
521 this unit is running. Specifically: failing condition checks (such as <varname>ConditionPathExists=</varname>,
522 <varname>ConditionPathIsSymbolicLink=</varname>, … — see below) do not cause the start job of a unit with a
523 <varname>Requires=</varname> dependency on it to fail. Also, some unit types may deactivate on their own (for
524 example, a service process may decide to exit cleanly, or a device may be unplugged by the user), which is not
525 propagated to units having a <varname>Requires=</varname> dependency. Use the <varname>BindsTo=</varname>
526 dependency type together with <varname>After=</varname> to ensure that a unit may never be in active state
527 without a specific other unit also in active state (see below).</para>
528
529 <para>Note that dependencies of this type may also be configured outside of the unit configuration file by
530 adding a symlink to a <filename>.requires/</filename> directory accompanying the unit file. For details, see
531 above.</para></listitem>
532 </varlistentry>
533
534 <varlistentry>
535 <term><varname>Requisite=</varname></term>
536
537 <listitem><para>Similar to <varname>Requires=</varname>.
538 However, if the units listed here are not started already,
539 they will not be started and the transaction will fail
540 immediately.</para>
541
542 <para>When <varname>Requisite=b.service</varname> is used on
543 <filename>a.service</filename>, this dependency will show as
544 <varname>RequisiteOf=a.service</varname> in property listing of
545 <filename>b.service</filename>. <varname>RequisiteOf=</varname>
546 dependency cannot be specified directly.</para>
547 </listitem>
548 </varlistentry>
549
550 <varlistentry>
551 <term><varname>Wants=</varname></term>
552
553 <listitem><para>A weaker version of
554 <varname>Requires=</varname>. Units listed in this option will
555 be started if the configuring unit is. However, if the listed
556 units fail to start or cannot be added to the transaction,
557 this has no impact on the validity of the transaction as a
558 whole. This is the recommended way to hook start-up of one
559 unit to the start-up of another unit.</para>
560
561 <para>Note that dependencies of this type may also be
562 configured outside of the unit configuration file by adding
563 symlinks to a <filename>.wants/</filename> directory
564 accompanying the unit file. For details, see
565 above.</para></listitem>
566 </varlistentry>
567
568 <varlistentry>
569 <term><varname>BindsTo=</varname></term>
570
571 <listitem><para>Configures requirement dependencies, very similar in style to
572 <varname>Requires=</varname>. However, this dependency type is stronger: in addition to the effect of
573 <varname>Requires=</varname> it declares that if the unit bound to is stopped, this unit will be stopped
574 too. This means a unit bound to another unit that suddenly enters inactive state will be stopped too.
575 Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit
576 might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of
577 a mount unit might be unmounted without involvement of the system and service manager.</para>
578
579 <para>When used in conjunction with <varname>After=</varname> on the same unit the behaviour of
580 <varname>BindsTo=</varname> is even stronger. In this case, the unit bound to strictly has to be in active
581 state for this unit to also be in active state. This not only means a unit bound to another unit that suddenly
582 enters inactive state, but also one that is bound to another unit that gets skipped due to a failed condition
583 check (such as <varname>ConditionPathExists=</varname>, <varname>ConditionPathIsSymbolicLink=</varname>, … —
584 see below) will be stopped, should it be running. Hence, in many cases it is best to combine
585 <varname>BindsTo=</varname> with <varname>After=</varname>.</para>
586
587 <para>When <varname>BindsTo=b.service</varname> is used on
588 <filename>a.service</filename>, this dependency will show as
589 <varname>BoundBy=a.service</varname> in property listing of
590 <filename>b.service</filename>. <varname>BoundBy=</varname>
591 dependency cannot be specified directly.</para>
592 </listitem>
593 </varlistentry>
594
595 <varlistentry>
596 <term><varname>PartOf=</varname></term>
597
598 <listitem><para>Configures dependencies similar to
599 <varname>Requires=</varname>, but limited to stopping and
600 restarting of units. When systemd stops or restarts the units
601 listed here, the action is propagated to this unit. Note that
602 this is a one-way dependency — changes to this unit do not
603 affect the listed units.</para>
604
605 <para>When <varname>PartOf=b.service</varname> is used on
606 <filename>a.service</filename>, this dependency will show as
607 <varname>ConsistsOf=a.service</varname> in property listing of
608 <filename>b.service</filename>. <varname>ConsistsOf=</varname>
609 dependency cannot be specified directly.</para>
610 </listitem>
611 </varlistentry>
612
613 <varlistentry>
614 <term><varname>Conflicts=</varname></term>
615
616 <listitem><para>A space-separated list of unit names.
617 Configures negative requirement dependencies. If a unit has a
618 <varname>Conflicts=</varname> setting on another unit,
619 starting the former will stop the latter and vice versa. Note
620 that this setting is independent of and orthogonal to the
621 <varname>After=</varname> and <varname>Before=</varname>
622 ordering dependencies.</para>
623
624 <para>If a unit A that conflicts with a unit B is scheduled to
625 be started at the same time as B, the transaction will either
626 fail (in case both are required part of the transaction) or be
627 modified to be fixed (in case one or both jobs are not a
628 required part of the transaction). In the latter case, the job
629 that is not the required will be removed, or in case both are
630 not required, the unit that conflicts will be started and the
631 unit that is conflicted is stopped.</para></listitem>
632 </varlistentry>
633
634 <varlistentry>
635 <term><varname>Before=</varname></term>
636 <term><varname>After=</varname></term>
637
638 <listitem><para>These two settings expect a space-separated list of unit names. They configure ordering
639 dependencies between units. If a unit <filename>foo.service</filename> contains a setting
640 <option>Before=bar.service</option> and both units are being started, <filename>bar.service</filename>'s
641 start-up is delayed until <filename>foo.service</filename> has finished starting up. Note that this setting is
642 independent of and orthogonal to the requirement dependencies as configured by <varname>Requires=</varname>,
643 <varname>Wants=</varname> or <varname>BindsTo=</varname>. It is a common pattern to include a unit name in both
644 the <varname>After=</varname> and <varname>Requires=</varname> options, in which case the unit listed will be
645 started before the unit that is configured with these options. This option may be specified more than once, in
646 which case ordering dependencies for all listed names are created. <varname>After=</varname> is the inverse of
647 <varname>Before=</varname>, i.e. while <varname>After=</varname> ensures that the configured unit is started
648 after the listed unit finished starting up, <varname>Before=</varname> ensures the opposite, that the
649 configured unit is fully started up before the listed unit is started. Note that when two units with an
650 ordering dependency between them are shut down, the inverse of the start-up order is applied. i.e. if a unit is
651 configured with <varname>After=</varname> on another unit, the former is stopped before the latter if both are
652 shut down. Given two units with any ordering dependency between them, if one unit is shut down and the other is
653 started up, the shutdown is ordered before the start-up. It doesn't matter if the ordering dependency is
654 <varname>After=</varname> or <varname>Before=</varname>, in this case. It also doesn't matter which of the two
655 is shut down, as long as one is shut down and the other is started up. The shutdown is ordered before the
656 start-up in all cases. If two units have no ordering dependencies between them, they are shut down or started
657 up simultaneously, and no ordering takes place. It depends on the unit type when precisely a unit has finished
658 starting up. Most importantly, for service units start-up is considered completed for the purpose of
659 <varname>Before=</varname>/<varname>After=</varname> when all its configured start-up commands have been
660 invoked and they either failed or reported start-up success.</para></listitem>
661 </varlistentry>
662
663 <varlistentry>
664 <term><varname>OnFailure=</varname></term>
665
666 <listitem><para>A space-separated list of one or more units
667 that are activated when this unit enters the
668 <literal>failed</literal> state. A service unit using
669 <varname>Restart=</varname> enters the failed state only after
670 the start limits are reached.</para></listitem>
671 </varlistentry>
672
673 <varlistentry>
674 <term><varname>PropagatesReloadTo=</varname></term>
675 <term><varname>ReloadPropagatedFrom=</varname></term>
676
677 <listitem><para>A space-separated list of one or more units
678 where reload requests on this unit will be propagated to, or
679 reload requests on the other unit will be propagated to this
680 unit, respectively. Issuing a reload request on a unit will
681 automatically also enqueue a reload request on all units that
682 the reload request shall be propagated to via these two
683 settings.</para></listitem>
684 </varlistentry>
685
686 <varlistentry>
687 <term><varname>JoinsNamespaceOf=</varname></term>
688
689 <listitem><para>For units that start processes (such as
690 service units), lists one or more other units whose network
691 and/or temporary file namespace to join. This only applies to
692 unit types which support the
693 <varname>PrivateNetwork=</varname> and
694 <varname>PrivateTmp=</varname> directives (see
695 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
696 for details). If a unit that has this setting set is started,
697 its processes will see the same <filename>/tmp</filename>,
698 <filename>/var/tmp</filename> and network namespace as one
699 listed unit that is started. If multiple listed units are
700 already started, it is not defined which namespace is joined.
701 Note that this setting only has an effect if
702 <varname>PrivateNetwork=</varname> and/or
703 <varname>PrivateTmp=</varname> is enabled for both the unit
704 that joins the namespace and the unit whose namespace is
705 joined.</para></listitem>
706 </varlistentry>
707
708 <varlistentry>
709 <term><varname>RequiresMountsFor=</varname></term>
710
711 <listitem><para>Takes a space-separated list of absolute
712 paths. Automatically adds dependencies of type
713 <varname>Requires=</varname> and <varname>After=</varname> for
714 all mount units required to access the specified path.</para>
715
716 <para>Mount points marked with <option>noauto</option> are not
717 mounted automatically through <filename>local-fs.target</filename>,
718 but are still honored for the purposes of this option, i.e. they
719 will be pulled in by this unit.</para></listitem>
720 </varlistentry>
721
722 <varlistentry>
723 <term><varname>OnFailureJobMode=</varname></term>
724
725 <listitem><para>Takes a value of
726 <literal>fail</literal>,
727 <literal>replace</literal>,
728 <literal>replace-irreversibly</literal>,
729 <literal>isolate</literal>,
730 <literal>flush</literal>,
731 <literal>ignore-dependencies</literal> or
732 <literal>ignore-requirements</literal>. Defaults to
733 <literal>replace</literal>. Specifies how the units listed in
734 <varname>OnFailure=</varname> will be enqueued. See
735 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
736 <option>--job-mode=</option> option for details on the
737 possible values. If this is set to <literal>isolate</literal>,
738 only a single unit may be listed in
739 <varname>OnFailure=</varname>..</para></listitem>
740 </varlistentry>
741
742 <varlistentry>
743 <term><varname>IgnoreOnIsolate=</varname></term>
744
745 <listitem><para>Takes a boolean argument. If <option>true</option>, this unit
746 will not be stopped when isolating another unit. Defaults to
747 <option>false</option> for service, target, socket, busname, timer, and path
748 units, and <option>true</option> for slice, scope, device, swap, mount, and
749 automount units.</para></listitem>
750 </varlistentry>
751
752 <varlistentry>
753 <term><varname>StopWhenUnneeded=</varname></term>
754
755 <listitem><para>Takes a boolean argument. If
756 <option>true</option>, this unit will be stopped when it is no
757 longer used. Note that, in order to minimize the work to be
758 executed, systemd will not stop units by default unless they
759 are conflicting with other units, or the user explicitly
760 requested their shut down. If this option is set, a unit will
761 be automatically cleaned up if no other active unit requires
762 it. Defaults to <option>false</option>.</para></listitem>
763 </varlistentry>
764
765 <varlistentry>
766 <term><varname>RefuseManualStart=</varname></term>
767 <term><varname>RefuseManualStop=</varname></term>
768
769 <listitem><para>Takes a boolean argument. If
770 <option>true</option>, this unit can only be activated or
771 deactivated indirectly. In this case, explicit start-up or
772 termination requested by the user is denied, however if it is
773 started or stopped as a dependency of another unit, start-up
774 or termination will succeed. This is mostly a safety feature
775 to ensure that the user does not accidentally activate units
776 that are not intended to be activated explicitly, and not
777 accidentally deactivate units that are not intended to be
778 deactivated. These options default to
779 <option>false</option>.</para></listitem>
780 </varlistentry>
781
782 <varlistentry>
783 <term><varname>AllowIsolate=</varname></term>
784
785 <listitem><para>Takes a boolean argument. If
786 <option>true</option>, this unit may be used with the
787 <command>systemctl isolate</command> command. Otherwise, this
788 will be refused. It probably is a good idea to leave this
789 disabled except for target units that shall be used similar to
790 runlevels in SysV init systems, just as a precaution to avoid
791 unusable system states. This option defaults to
792 <option>false</option>.</para></listitem>
793 </varlistentry>
794
795 <varlistentry>
796 <term><varname>DefaultDependencies=</varname></term>
797
798 <listitem><para>Takes a boolean argument. If
799 <option>true</option>, (the default), a few default
800 dependencies will implicitly be created for the unit. The
801 actual dependencies created depend on the unit type. For
802 example, for service units, these dependencies ensure that the
803 service is started only after basic system initialization is
804 completed and is properly terminated on system shutdown. See
805 the respective man pages for details. Generally, only services
806 involved with early boot or late shutdown should set this
807 option to <option>false</option>. It is highly recommended to
808 leave this option enabled for the majority of common units. If
809 set to <option>false</option>, this option does not disable
810 all implicit dependencies, just non-essential
811 ones.</para></listitem>
812 </varlistentry>
813
814 <varlistentry>
815 <term><varname>CollectMode=</varname></term>
816
817 <listitem><para>Tweaks the "garbage collection" algorithm for this unit. Takes one of <option>inactive</option>
818 or <option>inactive-or-failed</option>. If set to <option>inactive</option> the unit will be unloaded if it is
819 in the <constant>inactive</constant> state and is not referenced by clients, jobs or other units — however it
820 is not unloaded if it is in the <constant>failed</constant> state. In <option>failed</option> mode, failed
821 units are not unloaded until the user invoked <command>systemctl reset-failed</command> on them to reset the
822 <constant>failed</constant> state, or an equivalent command. This behaviour is altered if this option is set to
823 <option>inactive-or-failed</option>: in this case the unit is unloaded even if the unit is in a
824 <constant>failed</constant> state, and thus an explicitly resetting of the <constant>failed</constant> state is
825 not necessary. Note that if this mode is used unit results (such as exit codes, exit signals, consumed
826 resources, …) are flushed out immediately after the unit completed, except for what is stored in the logging
827 subsystem. Defaults to <option>inactive</option>.</para>
828 </listitem>
829 </varlistentry>
830
831 <varlistentry>
832 <term><varname>JobTimeoutSec=</varname></term>
833 <term><varname>JobRunningTimeoutSec=</varname></term>
834 <term><varname>JobTimeoutAction=</varname></term>
835 <term><varname>JobTimeoutRebootArgument=</varname></term>
836
837 <listitem><para>When a job for this unit is queued, a time-out <varname>JobTimeoutSec=</varname> may be
838 configured. Similarly, <varname>JobRunningTimeoutSec=</varname> starts counting when the queued job is actually
839 started. If either time limit is reached, the job will be cancelled, the unit however will not change state or
840 even enter the <literal>failed</literal> mode. This value defaults to <literal>infinity</literal> (job timeouts
841 disabled), except for device units (<varname>JobRunningTimeoutSec=</varname> defaults to
842 <varname>DefaultTimeoutStartSec=</varname>). NB: this timeout is independent from any unit-specific timeout
843 (for example, the timeout set with <varname>TimeoutStartSec=</varname> in service units) as the job timeout has
844 no effect on the unit itself, only on the job that might be pending for it. Or in other words: unit-specific
845 timeouts are useful to abort unit state changes, and revert them. The job timeout set with this option however
846 is useful to abort only the job waiting for the unit state to change.</para>
847
848 <para><varname>JobTimeoutAction=</varname> optionally configures an additional action to take when the time-out
849 is hit. It takes the same values as <varname>StartLimitAction=</varname>. Defaults to <option>none</option>.
850 <varname>JobTimeoutRebootArgument=</varname> configures an optional reboot string to pass to the
851 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
852 system call.</para></listitem>
853 </varlistentry>
854
855 <varlistentry>
856 <term><varname>StartLimitIntervalSec=<replaceable>interval</replaceable></varname></term>
857 <term><varname>StartLimitBurst=<replaceable>burst</replaceable></varname></term>
858
859 <listitem><para>Configure unit start rate limiting. Units which are started more than
860 <replaceable>burst</replaceable> times within an <replaceable>interval</replaceable> time interval are not
861 permitted to start any more. Use <varname>StartLimitIntervalSec=</varname> to configure the checking interval
862 (defaults to <varname>DefaultStartLimitIntervalSec=</varname> in manager configuration file, set it to 0 to
863 disable any kind of rate limiting). Use <varname>StartLimitBurst=</varname> to configure how many starts per
864 interval are allowed (defaults to <varname>DefaultStartLimitBurst=</varname> in manager configuration
865 file). These configuration options are particularly useful in conjunction with the service setting
866 <varname>Restart=</varname> (see
867 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>); however,
868 they apply to all kinds of starts (including manual), not just those triggered by the
869 <varname>Restart=</varname> logic. Note that units which are configured for <varname>Restart=</varname> and
870 which reach the start limit are not attempted to be restarted anymore; however, they may still be restarted
871 manually at a later point, after the <replaceable>interval</replaceable> has passed. From this point on, the
872 restart logic is activated again. Note that <command>systemctl reset-failed</command> will cause the restart
873 rate counter for a service to be flushed, which is useful if the administrator wants to manually start a unit
874 and the start limit interferes with that. Note that this rate-limiting is enforced after any unit condition
875 checks are executed, and hence unit activations with failing conditions do not count towards this rate
876 limit. This setting does not apply to slice, target, device, and scope units, since they are unit types whose
877 activation may either never fail, or may succeed only a single time.</para>
878
879 <para>When a unit is unloaded due to the garbage collection logic (see above) its rate limit counters are
880 flushed out too. This means that configuring start rate limiting for a unit that is not referenced continously
881 has no effect.</para></listitem>
882 </varlistentry>
883
884 <varlistentry>
885 <term><varname>StartLimitAction=</varname></term>
886
887 <listitem><para>Configure the action to take if the rate limit configured with
888 <varname>StartLimitIntervalSec=</varname> and <varname>StartLimitBurst=</varname> is hit. Takes one of
889 <option>none</option>, <option>reboot</option>, <option>reboot-force</option>,
890 <option>reboot-immediate</option>, <option>poweroff</option>, <option>poweroff-force</option> or
891 <option>poweroff-immediate</option>. If <option>none</option> is set, hitting the rate limit will trigger no
892 action besides that the start will not be permitted. <option>reboot</option> causes a reboot following the
893 normal shutdown procedure (i.e. equivalent to <command>systemctl reboot</command>).
894 <option>reboot-force</option> causes a forced reboot which will terminate all processes forcibly but should
895 cause no dirty file systems on reboot (i.e. equivalent to <command>systemctl reboot -f</command>) and
896 <option>reboot-immediate</option> causes immediate execution of the
897 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call, which
898 might result in data loss. Similarly, <option>poweroff</option>, <option>poweroff-force</option>,
899 <option>poweroff-immediate</option> have the effect of powering down the system with similar
900 semantics. Defaults to <option>none</option>.</para></listitem>
901 </varlistentry>
902
903 <varlistentry>
904 <term><varname>FailureAction=</varname></term>
905 <term><varname>SuccessAction=</varname></term>
906 <listitem><para>Configure the action to take when the unit stops and enters a failed state or inactive
907 state. Takes the same values as the setting <varname>StartLimitAction=</varname> setting and executes the same
908 actions (see
909 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>). Both options
910 default to <option>none</option>.</para></listitem>
911 </varlistentry>
912
913 <varlistentry>
914 <term><varname>RebootArgument=</varname></term>
915 <listitem><para>Configure the optional argument for the
916 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call if
917 <varname>StartLimitAction=</varname> or <varname>FailureAction=</varname> is a reboot action. This
918 works just like the optional argument to <command>systemctl reboot</command> command.</para></listitem>
919 </varlistentry>
920
921 <varlistentry>
922 <term><varname>ConditionArchitecture=</varname></term>
923 <term><varname>ConditionVirtualization=</varname></term>
924 <term><varname>ConditionHost=</varname></term>
925 <term><varname>ConditionKernelCommandLine=</varname></term>
926 <term><varname>ConditionKernelVersion=</varname></term>
927 <term><varname>ConditionSecurity=</varname></term>
928 <term><varname>ConditionCapability=</varname></term>
929 <term><varname>ConditionACPower=</varname></term>
930 <term><varname>ConditionNeedsUpdate=</varname></term>
931 <term><varname>ConditionFirstBoot=</varname></term>
932 <term><varname>ConditionPathExists=</varname></term>
933 <term><varname>ConditionPathExistsGlob=</varname></term>
934 <term><varname>ConditionPathIsDirectory=</varname></term>
935 <term><varname>ConditionPathIsSymbolicLink=</varname></term>
936 <term><varname>ConditionPathIsMountPoint=</varname></term>
937 <term><varname>ConditionPathIsReadWrite=</varname></term>
938 <term><varname>ConditionDirectoryNotEmpty=</varname></term>
939 <term><varname>ConditionFileNotEmpty=</varname></term>
940 <term><varname>ConditionFileIsExecutable=</varname></term>
941 <term><varname>ConditionUser=</varname></term>
942 <term><varname>ConditionGroup=</varname></term>
943 <term><varname>ConditionControlGroupController=</varname></term>
944
945 <!-- We do not document ConditionNull=
946 here, as it is not particularly
947 useful and probably just
948 confusing. -->
949
950 <listitem><para>Before starting a unit, verify that the specified condition is true. If it is not true, the
951 starting of the unit will be (mostly silently) skipped, however all ordering dependencies of it are still
952 respected. A failing condition will not result in the unit being moved into a failure state. The condition is
953 checked at the time the queued start job is to be executed. Use condition expressions in order to silently skip
954 units that do not apply to the local running system, for example because the kernel or runtime environment
955 doesn't require its functionality. Use the various <varname>AssertArchitecture=</varname>,
956 <varname>AssertVirtualization=</varname>, … options for a similar mechanism that puts the unit in a failure
957 state and logs about the failed check (see below).</para>
958
959 <para><varname>ConditionArchitecture=</varname> may be used to
960 check whether the system is running on a specific
961 architecture. Takes one of
962 <varname>x86</varname>,
963 <varname>x86-64</varname>,
964 <varname>ppc</varname>,
965 <varname>ppc-le</varname>,
966 <varname>ppc64</varname>,
967 <varname>ppc64-le</varname>,
968 <varname>ia64</varname>,
969 <varname>parisc</varname>,
970 <varname>parisc64</varname>,
971 <varname>s390</varname>,
972 <varname>s390x</varname>,
973 <varname>sparc</varname>,
974 <varname>sparc64</varname>,
975 <varname>mips</varname>,
976 <varname>mips-le</varname>,
977 <varname>mips64</varname>,
978 <varname>mips64-le</varname>,
979 <varname>alpha</varname>,
980 <varname>arm</varname>,
981 <varname>arm-be</varname>,
982 <varname>arm64</varname>,
983 <varname>arm64-be</varname>,
984 <varname>sh</varname>,
985 <varname>sh64</varname>,
986 <varname>m68k</varname>,
987 <varname>tilegx</varname>,
988 <varname>cris</varname>,
989 <varname>arc</varname>,
990 <varname>arc-be</varname> to test
991 against a specific architecture. The architecture is
992 determined from the information returned by
993 <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
994 and is thus subject to
995 <citerefentry><refentrytitle>personality</refentrytitle><manvolnum>2</manvolnum></citerefentry>.
996 Note that a <varname>Personality=</varname> setting in the
997 same unit file has no effect on this condition. A special
998 architecture name <varname>native</varname> is mapped to the
999 architecture the system manager itself is compiled for. The
1000 test may be negated by prepending an exclamation mark.</para>
1001
1002 <para><varname>ConditionVirtualization=</varname> may be used
1003 to check whether the system is executed in a virtualized
1004 environment and optionally test whether it is a specific
1005 implementation. Takes either boolean value to check if being
1006 executed in any virtualized environment, or one of
1007 <varname>vm</varname> and
1008 <varname>container</varname> to test against a generic type of
1009 virtualization solution, or one of
1010 <varname>qemu</varname>,
1011 <varname>kvm</varname>,
1012 <varname>zvm</varname>,
1013 <varname>vmware</varname>,
1014 <varname>microsoft</varname>,
1015 <varname>oracle</varname>,
1016 <varname>xen</varname>,
1017 <varname>bochs</varname>,
1018 <varname>uml</varname>,
1019 <varname>openvz</varname>,
1020 <varname>lxc</varname>,
1021 <varname>lxc-libvirt</varname>,
1022 <varname>systemd-nspawn</varname>,
1023 <varname>docker</varname>,
1024 <varname>rkt</varname> to test
1025 against a specific implementation, or
1026 <varname>private-users</varname> to check whether we are running in a user namespace. See
1027 <citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1028 for a full list of known virtualization technologies and their
1029 identifiers. If multiple virtualization technologies are
1030 nested, only the innermost is considered. The test may be
1031 negated by prepending an exclamation mark.</para>
1032
1033 <para><varname>ConditionHost=</varname> may be used to match
1034 against the hostname or machine ID of the host. This either
1035 takes a hostname string (optionally with shell style globs)
1036 which is tested against the locally set hostname as returned
1037 by
1038 <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1039 or a machine ID formatted as string (see
1040 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
1041 The test may be negated by prepending an exclamation
1042 mark.</para>
1043
1044 <para><varname>ConditionKernelCommandLine=</varname> may be
1045 used to check whether a specific kernel command line option is
1046 set (or if prefixed with the exclamation mark unset). The
1047 argument must either be a single word, or an assignment (i.e.
1048 two words, separated <literal>=</literal>). In the former case
1049 the kernel command line is searched for the word appearing as
1050 is, or as left hand side of an assignment. In the latter case,
1051 the exact assignment is looked for with right and left hand
1052 side matching.</para>
1053
1054 <para><varname>ConditionKernelVersion=</varname> may be used to check whether the kernel version (as reported
1055 by <command>uname -r</command>) matches a certain expression (or if prefixed with the exclamation mark does not
1056 match it). The argument must be a single string. If the string starts with one of <literal>&lt;</literal>,
1057 <literal>&lt;=</literal>, <literal>=</literal>, <literal>&gt;=</literal>, <literal>&gt;</literal> a relative
1058 version comparison is done, otherwise the specified string is matched with shell-style globs.</para>
1059
1060 <para>Note that using the kernel version string is an unreliable way to determine which features are supported
1061 by a kernel, because of the widespread practice of backporting drivers, features, and fixes from newer upstream
1062 kernels into older versions provided by distributions. Hence, this check is inherently unportable and should
1063 not be used for units which may be used on different distributions.</para>
1064
1065 <para><varname>ConditionSecurity=</varname> may be used to
1066 check whether the given security module is enabled on the
1067 system. Currently, the recognized values are
1068 <varname>selinux</varname>,
1069 <varname>apparmor</varname>,
1070 <varname>tomoyo</varname>,
1071 <varname>ima</varname>,
1072 <varname>smack</varname> and
1073 <varname>audit</varname>. The test may be negated by
1074 prepending an exclamation mark.</para>
1075
1076 <para><varname>ConditionCapability=</varname> may be used to
1077 check whether the given capability exists in the capability
1078 bounding set of the service manager (i.e. this does not check
1079 whether capability is actually available in the permitted or
1080 effective sets, see
1081 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
1082 for details). Pass a capability name such as
1083 <literal>CAP_MKNOD</literal>, possibly prefixed with an
1084 exclamation mark to negate the check.</para>
1085
1086 <para><varname>ConditionACPower=</varname> may be used to
1087 check whether the system has AC power, or is exclusively
1088 battery powered at the time of activation of the unit. This
1089 takes a boolean argument. If set to <varname>true</varname>,
1090 the condition will hold only if at least one AC connector of
1091 the system is connected to a power source, or if no AC
1092 connectors are known. Conversely, if set to
1093 <varname>false</varname>, the condition will hold only if
1094 there is at least one AC connector known and all AC connectors
1095 are disconnected from a power source.</para>
1096
1097 <para><varname>ConditionNeedsUpdate=</varname> takes one of
1098 <filename>/var</filename> or <filename>/etc</filename> as
1099 argument, possibly prefixed with a <literal>!</literal> (for
1100 inverting the condition). This condition may be used to
1101 conditionalize units on whether the specified directory
1102 requires an update because <filename>/usr</filename>'s
1103 modification time is newer than the stamp file
1104 <filename>.updated</filename> in the specified directory. This
1105 is useful to implement offline updates of the vendor operating
1106 system resources in <filename>/usr</filename> that require
1107 updating of <filename>/etc</filename> or
1108 <filename>/var</filename> on the next following boot. Units
1109 making use of this condition should order themselves before
1110 <citerefentry><refentrytitle>systemd-update-done.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1111 to make sure they run before the stamp file's modification
1112 time gets reset indicating a completed update.</para>
1113
1114 <para><varname>ConditionFirstBoot=</varname> takes a boolean argument. This condition may be used to
1115 conditionalize units on whether the system is booting up with an unpopulated <filename>/etc</filename>
1116 directory (specifically: an <filename>/etc</filename> with no <filename>/etc/machine-id</filename>). This may
1117 be used to populate <filename>/etc</filename> on the first boot after factory reset, or when a new system
1118 instance boots up for the first time.</para>
1119
1120 <para>With <varname>ConditionPathExists=</varname> a file
1121 existence condition is checked before a unit is started. If
1122 the specified absolute path name does not exist, the condition
1123 will fail. If the absolute path name passed to
1124 <varname>ConditionPathExists=</varname> is prefixed with an
1125 exclamation mark (<literal>!</literal>), the test is negated,
1126 and the unit is only started if the path does not
1127 exist.</para>
1128
1129 <para><varname>ConditionPathExistsGlob=</varname> is similar
1130 to <varname>ConditionPathExists=</varname>, but checks for the
1131 existence of at least one file or directory matching the
1132 specified globbing pattern.</para>
1133
1134 <para><varname>ConditionPathIsDirectory=</varname> is similar
1135 to <varname>ConditionPathExists=</varname> but verifies
1136 whether a certain path exists and is a directory.</para>
1137
1138 <para><varname>ConditionPathIsSymbolicLink=</varname> is
1139 similar to <varname>ConditionPathExists=</varname> but
1140 verifies whether a certain path exists and is a symbolic
1141 link.</para>
1142
1143 <para><varname>ConditionPathIsMountPoint=</varname> is similar
1144 to <varname>ConditionPathExists=</varname> but verifies
1145 whether a certain path exists and is a mount point.</para>
1146
1147 <para><varname>ConditionPathIsReadWrite=</varname> is similar
1148 to <varname>ConditionPathExists=</varname> but verifies
1149 whether the underlying file system is readable and writable
1150 (i.e. not mounted read-only).</para>
1151
1152 <para><varname>ConditionDirectoryNotEmpty=</varname> is
1153 similar to <varname>ConditionPathExists=</varname> but
1154 verifies whether a certain path exists and is a non-empty
1155 directory.</para>
1156
1157 <para><varname>ConditionFileNotEmpty=</varname> is similar to
1158 <varname>ConditionPathExists=</varname> but verifies whether a
1159 certain path exists and refers to a regular file with a
1160 non-zero size.</para>
1161
1162 <para><varname>ConditionFileIsExecutable=</varname> is similar
1163 to <varname>ConditionPathExists=</varname> but verifies
1164 whether a certain path exists, is a regular file and marked
1165 executable.</para>
1166
1167 <para><varname>ConditionUser=</varname> takes a numeric
1168 <literal>UID</literal>, a UNIX user name, or the special value
1169 <literal>@system</literal>. This condition may be used to check
1170 whether the service manager is running as the given user. The
1171 special value <literal>@system</literal> can be used to check
1172 if the user id is within the system user range. This option is not
1173 useful for system services, as the system manager exclusively
1174 runs as the root user, and thus the test result is constant.</para>
1175
1176 <para><varname>ConditionGroup=</varname> is similar
1177 to <varname>ConditionUser=</varname> but verifies that the
1178 service manager's real or effective group, or any of its
1179 auxiliary groups match the specified group or GID. This setting
1180 does not have a special value <literal>@system</literal>.</para>
1181
1182 <para><varname>ConditionControlGroupController=</varname> takes a
1183 cgroup controller name (eg. <option>cpu</option>), verifying that it is
1184 available for use on the system. For example, a particular controller
1185 may not be available if it was disabled on the kernel command line with
1186 <literal>cgroup_disable=</literal><replaceable>controller</replaceable>.
1187 Multiple controllers may be passed with a space separating them; in
1188 this case the condition will only pass if all listed controllers are
1189 available for use. Controllers unknown to systemd are ignored. Valid
1190 controllers are <option>cpu</option>, <option>cpuacct</option>,
1191 <option>io</option>, <option>blkio</option>, <option>memory</option>,
1192 <option>devices</option>, and <option>pids</option>.</para>
1193
1194 <para>If multiple conditions are specified, the unit will be
1195 executed if all of them apply (i.e. a logical AND is applied).
1196 Condition checks can be prefixed with a pipe symbol (|) in
1197 which case a condition becomes a triggering condition. If at
1198 least one triggering condition is defined for a unit, then the
1199 unit will be executed if at least one of the triggering
1200 conditions apply and all of the non-triggering conditions. If
1201 you prefix an argument with the pipe symbol and an exclamation
1202 mark, the pipe symbol must be passed first, the exclamation
1203 second. Except for
1204 <varname>ConditionPathIsSymbolicLink=</varname>, all path
1205 checks follow symlinks. If any of these options is assigned
1206 the empty string, the list of conditions is reset completely,
1207 all previous condition settings (of any kind) will have no
1208 effect.</para></listitem>
1209 </varlistentry>
1210
1211 <varlistentry>
1212 <term><varname>AssertArchitecture=</varname></term>
1213 <term><varname>AssertVirtualization=</varname></term>
1214 <term><varname>AssertHost=</varname></term>
1215 <term><varname>AssertKernelCommandLine=</varname></term>
1216 <term><varname>AssertKernelVersion=</varname></term>
1217 <term><varname>AssertSecurity=</varname></term>
1218 <term><varname>AssertCapability=</varname></term>
1219 <term><varname>AssertACPower=</varname></term>
1220 <term><varname>AssertNeedsUpdate=</varname></term>
1221 <term><varname>AssertFirstBoot=</varname></term>
1222 <term><varname>AssertPathExists=</varname></term>
1223 <term><varname>AssertPathExistsGlob=</varname></term>
1224 <term><varname>AssertPathIsDirectory=</varname></term>
1225 <term><varname>AssertPathIsSymbolicLink=</varname></term>
1226 <term><varname>AssertPathIsMountPoint=</varname></term>
1227 <term><varname>AssertPathIsReadWrite=</varname></term>
1228 <term><varname>AssertDirectoryNotEmpty=</varname></term>
1229 <term><varname>AssertFileNotEmpty=</varname></term>
1230 <term><varname>AssertFileIsExecutable=</varname></term>
1231 <term><varname>AssertUser=</varname></term>
1232 <term><varname>AssertGroup=</varname></term>
1233 <term><varname>AssertControlGroupController=</varname></term>
1234
1235 <listitem><para>Similar to the <varname>ConditionArchitecture=</varname>,
1236 <varname>ConditionVirtualization=</varname>, …, condition settings described above, these settings add
1237 assertion checks to the start-up of the unit. However, unlike the conditions settings, any assertion setting
1238 that is not met results in failure of the start job (which means this is logged loudly). Use assertion
1239 expressions for units that cannot operate when specific requirements are not met, and when this is something
1240 the administrator or user should look into.</para></listitem>
1241 </varlistentry>
1242
1243 <varlistentry>
1244 <term><varname>SourcePath=</varname></term>
1245 <listitem><para>A path to a configuration file this unit has
1246 been generated from. This is primarily useful for
1247 implementation of generator tools that convert configuration
1248 from an external configuration file format into native unit
1249 files. This functionality should not be used in normal
1250 units.</para></listitem>
1251 </varlistentry>
1252 </variablelist>
1253 </refsect1>
1254
1255 <refsect1>
1256 <title>Mapping of unit properties to their inverses</title>
1257
1258 <para>Unit settings that create a relationship with a second unit usually show up
1259 in properties of both units, for example in <command>systemctl show</command>
1260 output. In some cases the name of the property is the same as the name of the
1261 configuration setting, but not always. This table lists the pairs of properties
1262 that are shown on two units which are connected through some dependency, and shows
1263 which property on "source" unit corresponds to which property on the "target" unit.
1264 </para>
1265
1266 <table>
1267 <title>
1268 "Forward" and "reverse" unit properties
1269 </title>
1270
1271 <tgroup cols='2'>
1272 <colspec colname='forward' />
1273 <colspec colname='reverse' />
1274 <colspec colname='notes' />
1275 <thead>
1276 <row>
1277 <entry>"Forward" property</entry>
1278 <entry>"Reverse" property</entry>
1279 <entry>Where used</entry>
1280 </row>
1281 </thead>
1282 <tbody>
1283 <row>
1284 <entry><varname>Before=</varname></entry>
1285 <entry><varname>After=</varname></entry>
1286 <entry morerows='1' valign='middle'>Both are unit file options</entry>
1287 </row>
1288 <row>
1289 <entry><varname>After=</varname></entry>
1290 <entry><varname>Before=</varname></entry>
1291 </row>
1292 <row>
1293 <entry><varname>Requires=</varname></entry>
1294 <entry><varname>RequiredBy=</varname></entry>
1295 <entry>A unit file option; an option in the [Install] section</entry>
1296 </row>
1297 <row>
1298 <entry><varname>Wants=</varname></entry>
1299 <entry><varname>WantedBy=</varname></entry>
1300 <entry>A unit file option; an option in the [Install] section</entry>
1301 </row>
1302 <row>
1303 <entry><varname>PartOf=</varname></entry>
1304 <entry><varname>ConsistsOf=</varname></entry>
1305 <entry>A unit file option; an automatic property</entry>
1306 </row>
1307 <row>
1308 <entry><varname>BindsTo=</varname></entry>
1309 <entry><varname>BoundBy=</varname></entry>
1310 <entry>A unit file option; an automatic property</entry>
1311 </row>
1312 <row>
1313 <entry><varname>Requisite=</varname></entry>
1314 <entry><varname>RequisiteOf=</varname></entry>
1315 <entry>A unit file option; an automatic property</entry>
1316 </row>
1317 <row>
1318 <entry><varname>Triggers=</varname></entry>
1319 <entry><varname>TriggeredBy=</varname></entry>
1320 <entry>Automatic properties, see notes below</entry>
1321 </row>
1322 <row>
1323 <entry><varname>Conflicts=</varname></entry>
1324 <entry><varname>ConflictedBy=</varname></entry>
1325 <entry>A unit file option; an automatic property</entry>
1326 </row>
1327 <row>
1328 <entry><varname>PropagatesReloadTo=</varname></entry>
1329 <entry><varname>ReloadPropagatedFrom=</varname></entry>
1330 <entry morerows='1' valign='middle'>Both are unit file options</entry>
1331 </row>
1332 <row>
1333 <entry><varname>ReloadPropagatedFrom=</varname></entry>
1334 <entry><varname>PropagatesReloadTo=</varname></entry>
1335 </row>
1336 </tbody>
1337 </tgroup>
1338 </table>
1339
1340 <para>Note: <varname>WantedBy=</varname> and <varname>RequiredBy=</varname> are
1341 used in the [Install] section to create symlinks in <filename>.wants/</filename>
1342 and <filename>.requires/</filename> directories. They cannot be used directly as a
1343 unit configuration setting.</para>
1344
1345 <para>Note: <varname>ConsistsOf=</varname>, <varname>BoundBy=</varname>,
1346 <varname>RequisiteOf=</varname>, <varname>ConflictedBy=</varname> are created
1347 implicitly along with their reverse and cannot be specified directly.</para>
1348
1349 <para>Note: <varname>Triggers=</varname> is created implicitly between a socket,
1350 path unit, or an automount unit, and the unit they activate. By default a unit
1351 with the same name is triggered, but this can be overriden using
1352 <varname>Sockets=</varname>, <varname>Service=</varname>, and <varname>Unit=</varname>
1353 settings. See
1354 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1355 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1356 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1357 and
1358 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1359 for details. <varname>TriggersBy=</varname> is created implicitly on the
1360 triggered unit.</para>
1361 </refsect1>
1362
1363 <refsect1>
1364 <title>[Install] Section Options</title>
1365
1366 <para>Unit files may include an <literal>[Install]</literal> section, which carries installation information for
1367 the unit. This section is not interpreted by
1368 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> during runtime; it is
1369 used by the <command>enable</command> and <command>disable</command> commands of the
1370 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool during
1371 installation of a unit.</para>
1372
1373 <variablelist class='unit-directives'>
1374 <varlistentry>
1375 <term><varname>Alias=</varname></term>
1376
1377 <listitem><para>A space-separated list of additional names this unit shall be installed under. The names listed
1378 here must have the same suffix (i.e. type) as the unit filename. This option may be specified more than once,
1379 in which case all listed names are used. At installation time, <command>systemctl enable</command> will create
1380 symlinks from these names to the unit filename. Note that not all unit types support such alias names, and this
1381 setting is not supported for them. Specifically, mount, slice, swap, and automount units do not support
1382 aliasing.</para></listitem>
1383 </varlistentry>
1384
1385 <varlistentry>
1386 <term><varname>WantedBy=</varname></term>
1387 <term><varname>RequiredBy=</varname></term>
1388
1389 <listitem><para>This option may be used more than once, or a
1390 space-separated list of unit names may be given. A symbolic
1391 link is created in the <filename>.wants/</filename> or
1392 <filename>.requires/</filename> directory of each of the
1393 listed units when this unit is installed by <command>systemctl
1394 enable</command>. This has the effect that a dependency of
1395 type <varname>Wants=</varname> or <varname>Requires=</varname>
1396 is added from the listed unit to the current unit. The primary
1397 result is that the current unit will be started when the
1398 listed unit is started. See the description of
1399 <varname>Wants=</varname> and <varname>Requires=</varname> in
1400 the [Unit] section for details.</para>
1401
1402 <para><command>WantedBy=foo.service</command> in a service
1403 <filename>bar.service</filename> is mostly equivalent to
1404 <command>Alias=foo.service.wants/bar.service</command> in the
1405 same file. In case of template units, <command>systemctl
1406 enable</command> must be called with an instance name, and
1407 this instance will be added to the
1408 <filename>.wants/</filename> or
1409 <filename>.requires/</filename> list of the listed unit. E.g.
1410 <command>WantedBy=getty.target</command> in a service
1411 <filename>getty@.service</filename> will result in
1412 <command>systemctl enable getty@tty2.service</command>
1413 creating a
1414 <filename>getty.target.wants/getty@tty2.service</filename>
1415 link to <filename>getty@.service</filename>.
1416 </para></listitem>
1417 </varlistentry>
1418
1419 <varlistentry>
1420 <term><varname>Also=</varname></term>
1421
1422 <listitem><para>Additional units to install/deinstall when
1423 this unit is installed/deinstalled. If the user requests
1424 installation/deinstallation of a unit with this option
1425 configured, <command>systemctl enable</command> and
1426 <command>systemctl disable</command> will automatically
1427 install/uninstall units listed in this option as well.</para>
1428
1429 <para>This option may be used more than once, or a
1430 space-separated list of unit names may be
1431 given.</para></listitem>
1432 </varlistentry>
1433
1434 <varlistentry>
1435 <term><varname>DefaultInstance=</varname></term>
1436
1437 <listitem><para>In template unit files, this specifies for
1438 which instance the unit shall be enabled if the template is
1439 enabled without any explicitly set instance. This option has
1440 no effect in non-template unit files. The specified string
1441 must be usable as instance identifier.</para></listitem>
1442 </varlistentry>
1443 </variablelist>
1444
1445 <para>The following specifiers are interpreted in the Install
1446 section: %n, %N, %p, %i, %U, %u, %m, %H, %b, %v. For their meaning
1447 see the next section.
1448 </para>
1449 </refsect1>
1450
1451 <refsect1>
1452 <title>Specifiers</title>
1453
1454 <para>Many settings resolve specifiers which may be used to write
1455 generic unit files referring to runtime or unit parameters that
1456 are replaced when the unit files are loaded. Specifiers must be known
1457 and resolvable for the setting to be valid. The following
1458 specifiers are understood:</para>
1459
1460 <table>
1461 <title>Specifiers available in unit files</title>
1462 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
1463 <colspec colname="spec" />
1464 <colspec colname="mean" />
1465 <colspec colname="detail" />
1466 <thead>
1467 <row>
1468 <entry>Specifier</entry>
1469 <entry>Meaning</entry>
1470 <entry>Details</entry>
1471 </row>
1472 </thead>
1473 <tbody>
1474 <row>
1475 <entry><literal>%n</literal></entry>
1476 <entry>Full unit name</entry>
1477 <entry></entry>
1478 </row>
1479 <row>
1480 <entry><literal>%N</literal></entry>
1481 <entry>Unescaped full unit name</entry>
1482 <entry>Same as <literal>%n</literal>, but with escaping undone. This undoes the escaping used when generating unit names from arbitrary strings (see above). </entry>
1483 </row>
1484 <row>
1485 <entry><literal>%p</literal></entry>
1486 <entry>Prefix name</entry>
1487 <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>
1488 </row>
1489 <row>
1490 <entry><literal>%P</literal></entry>
1491 <entry>Unescaped prefix name</entry>
1492 <entry>Same as <literal>%p</literal>, but with escaping undone</entry>
1493 </row>
1494 <row>
1495 <entry><literal>%i</literal></entry>
1496 <entry>Instance name</entry>
1497 <entry>For instantiated units: this is the string between the <literal>@</literal> character and the suffix of the unit name.</entry>
1498 </row>
1499 <row>
1500 <entry><literal>%I</literal></entry>
1501 <entry>Unescaped instance name</entry>
1502 <entry>Same as <literal>%i</literal>, but with escaping undone</entry>
1503 </row>
1504 <row>
1505 <entry><literal>%f</literal></entry>
1506 <entry>Unescaped filename</entry>
1507 <entry>This is either the unescaped instance name (if applicable) with <filename>/</filename> prepended (if applicable), or the unescaped prefix name prepended with <filename>/</filename>. This implements unescaping according to the rules for escaping absolute file system paths discussed above.</entry>
1508 </row>
1509 <row>
1510 <entry><literal>%t</literal></entry>
1511 <entry>Runtime directory root</entry>
1512 <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>
1513 </row>
1514 <row>
1515 <entry><literal>%S</literal></entry>
1516 <entry>State directory root</entry>
1517 <entry>This is either <filename>/var/lib</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to (for user managers).</entry>
1518 </row>
1519 <row>
1520 <entry><literal>%C</literal></entry>
1521 <entry>Cache directory root</entry>
1522 <entry>This is either <filename>/var/cache</filename> (for the system manager) or the path <literal>$XDG_CACHE_HOME</literal> resolves to (for user managers).</entry>
1523 </row>
1524 <row>
1525 <entry><literal>%L</literal></entry>
1526 <entry>Log directory root</entry>
1527 <entry>This is either <filename>/var/log</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to with <filename noindex='true'>/log</filename> appended (for user managers).</entry>
1528 </row>
1529 <row>
1530 <entry><literal>%u</literal></entry>
1531 <entry>User name</entry>
1532 <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>
1533 </row>
1534 <row>
1535 <entry><literal>%U</literal></entry>
1536 <entry>User UID</entry>
1537 <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>
1538 </row>
1539 <row>
1540 <entry><literal>%h</literal></entry>
1541 <entry>User home directory</entry>
1542 <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>
1543 </row>
1544 <row>
1545 <entry><literal>%s</literal></entry>
1546 <entry>User shell</entry>
1547 <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>
1548 </row>
1549 <row>
1550 <entry><literal>%m</literal></entry>
1551 <entry>Machine ID</entry>
1552 <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>
1553 </row>
1554 <row>
1555 <entry><literal>%b</literal></entry>
1556 <entry>Boot ID</entry>
1557 <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
1558 </row>
1559 <row>
1560 <entry><literal>%H</literal></entry>
1561 <entry>Host name</entry>
1562 <entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry>
1563 </row>
1564 <row>
1565 <entry><literal>%v</literal></entry>
1566 <entry>Kernel release</entry>
1567 <entry>Identical to <command>uname -r</command> output</entry>
1568 </row>
1569 <row>
1570 <entry><literal>%%</literal></entry>
1571 <entry>Single percent sign</entry>
1572 <entry>Use <literal>%%</literal> in place of <literal>%</literal> to specify a single percent sign.</entry>
1573 </row>
1574 </tbody>
1575 </tgroup>
1576 </table>
1577 </refsect1>
1578
1579 <refsect1>
1580 <title>Examples</title>
1581
1582 <example>
1583 <title>Allowing units to be enabled</title>
1584
1585 <para>The following snippet (highlighted) allows a unit (e.g.
1586 <filename>foo.service</filename>) to be enabled via
1587 <command>systemctl enable</command>:</para>
1588
1589 <programlisting>[Unit]
1590 Description=Foo
1591
1592 [Service]
1593 ExecStart=/usr/sbin/foo-daemon
1594
1595 <emphasis>[Install]</emphasis>
1596 <emphasis>WantedBy=multi-user.target</emphasis></programlisting>
1597
1598 <para>After running <command>systemctl enable</command>, a
1599 symlink
1600 <filename>/etc/systemd/system/multi-user.target.wants/foo.service</filename>
1601 linking to the actual unit will be created. It tells systemd to
1602 pull in the unit when starting
1603 <filename>multi-user.target</filename>. The inverse
1604 <command>systemctl disable</command> will remove that symlink
1605 again.</para>
1606 </example>
1607
1608 <example>
1609 <title>Overriding vendor settings</title>
1610
1611 <para>There are two methods of overriding vendor settings in
1612 unit files: copying the unit file from
1613 <filename>/usr/lib/systemd/system</filename> to
1614 <filename>/etc/systemd/system</filename> and modifying the
1615 chosen settings. Alternatively, one can create a directory named
1616 <filename><replaceable>unit</replaceable>.d/</filename> within
1617 <filename>/etc/systemd/system</filename> and place a drop-in
1618 file <filename><replaceable>name</replaceable>.conf</filename>
1619 there that only changes the specific settings one is interested
1620 in. Note that multiple such drop-in files are read if
1621 present, processed in lexicographic order of their filename.</para>
1622
1623 <para>The advantage of the first method is that one easily
1624 overrides the complete unit, the vendor unit is not parsed at
1625 all anymore. It has the disadvantage that improvements to the
1626 unit file by the vendor are not automatically incorporated on
1627 updates.</para>
1628
1629 <para>The advantage of the second method is that one only
1630 overrides the settings one specifically wants, where updates to
1631 the unit by the vendor automatically apply. This has the
1632 disadvantage that some future updates by the vendor might be
1633 incompatible with the local changes.</para>
1634
1635 <para>This also applies for user instances of systemd, but with
1636 different locations for the unit files. See the section on unit
1637 load paths for further details.</para>
1638
1639 <para>Suppose there is a vendor-supplied unit
1640 <filename>/usr/lib/systemd/system/httpd.service</filename> with
1641 the following contents:</para>
1642
1643 <programlisting>[Unit]
1644 Description=Some HTTP server
1645 After=remote-fs.target sqldb.service
1646 Requires=sqldb.service
1647 AssertPathExists=/srv/webserver
1648
1649 [Service]
1650 Type=notify
1651 ExecStart=/usr/sbin/some-fancy-httpd-server
1652 Nice=5
1653
1654 [Install]
1655 WantedBy=multi-user.target</programlisting>
1656
1657 <para>Now one wants to change some settings as an administrator:
1658 firstly, in the local setup, <filename>/srv/webserver</filename>
1659 might not exist, because the HTTP server is configured to use
1660 <filename>/srv/www</filename> instead. Secondly, the local
1661 configuration makes the HTTP server also depend on a memory
1662 cache service, <filename>memcached.service</filename>, that
1663 should be pulled in (<varname>Requires=</varname>) and also be
1664 ordered appropriately (<varname>After=</varname>). Thirdly, in
1665 order to harden the service a bit more, the administrator would
1666 like to set the <varname>PrivateTmp=</varname> setting (see
1667 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1668 for details). And lastly, the administrator would like to reset
1669 the niceness of the service to its default value of 0.</para>
1670
1671 <para>The first possibility is to copy the unit file to
1672 <filename>/etc/systemd/system/httpd.service</filename> and
1673 change the chosen settings:</para>
1674
1675 <programlisting>[Unit]
1676 Description=Some HTTP server
1677 After=remote-fs.target sqldb.service <emphasis>memcached.service</emphasis>
1678 Requires=sqldb.service <emphasis>memcached.service</emphasis>
1679 AssertPathExists=<emphasis>/srv/www</emphasis>
1680
1681 [Service]
1682 Type=notify
1683 ExecStart=/usr/sbin/some-fancy-httpd-server
1684 <emphasis>Nice=0</emphasis>
1685 <emphasis>PrivateTmp=yes</emphasis>
1686
1687 [Install]
1688 WantedBy=multi-user.target</programlisting>
1689
1690 <para>Alternatively, the administrator could create a drop-in
1691 file
1692 <filename>/etc/systemd/system/httpd.service.d/local.conf</filename>
1693 with the following contents:</para>
1694
1695 <programlisting>[Unit]
1696 After=memcached.service
1697 Requires=memcached.service
1698 # Reset all assertions and then re-add the condition we want
1699 AssertPathExists=
1700 AssertPathExists=/srv/www
1701
1702 [Service]
1703 Nice=0
1704 PrivateTmp=yes</programlisting>
1705
1706 <para>Note that for drop-in files, if one wants to remove
1707 entries from a setting that is parsed as a list (and is not a
1708 dependency), such as <varname>AssertPathExists=</varname> (or
1709 e.g. <varname>ExecStart=</varname> in service units), one needs
1710 to first clear the list before re-adding all entries except the
1711 one that is to be removed. Dependencies (<varname>After=</varname>, etc.)
1712 cannot be reset to an empty list, so dependencies can only be
1713 added in drop-ins. If you want to remove dependencies, you have
1714 to override the entire unit.</para>
1715
1716 </example>
1717 </refsect1>
1718
1719 <refsect1>
1720 <title>See Also</title>
1721 <para>
1722 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1723 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1724 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1725 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1726 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1727 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1728 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1729 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1730 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1731 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1732 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1733 <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1734 <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1735 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1736 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1737 <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1738 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1739 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1740 <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1741 </para>
1742 </refsect1>
1743
1744 </refentry>