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