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