]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.unit.xml
shared: small typo
[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
140 <command>enable</command>, <command>disable</command>, <command>start</command>, <command>stop</command>,
141 <command>status</command>, and similar, and in all unit dependency directives, including
142 <varname>Wants=</varname>, <varname>Requires=</varname>, <varname>Before=</varname>,
143 <varname>After=</varname>. Aliases cannot be used with the <command>preset</command> command.</para>
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'>
519
520 <varlistentry>
521 <term><varname>Description=</varname></term>
c43acf69
ZJS
522 <listitem><para>A human readable name for the unit. This is used by
523 <command>systemd</command> (and other UIs) as the label for the unit, so this string should
524 identify the unit rather than describe it, despite the name. <literal>Apache2 Web
525 Server</literal> is a good example. Bad examples are <literal>high-performance light-weight
526 HTTP server</literal> (too generic) or <literal>Apache2</literal> (too specific and
527 meaningless for people who do not know Apache). <command>systemd</command> will use this
528 string as a noun in status messages (<literal>Starting
529 <replaceable>description</replaceable>...</literal>, <literal>Started
530 <replaceable>description</replaceable>.</literal>, <literal>Reached target
531 <replaceable>description</replaceable>.</literal>, <literal>Failed to start
532 <replaceable>description</replaceable>.</literal>), so it should be capitalized, and should
5238e957 533 not be a full sentence or a phrase with a continuous verb. Bad examples include
c43acf69
ZJS
534 <literal>exiting the container</literal> or <literal>updating the database once per
535 day.</literal>.</para>
536 </listitem>
798d3a52
ZJS
537 </varlistentry>
538
539 <varlistentry>
540 <term><varname>Documentation=</varname></term>
541 <listitem><para>A space-separated list of URIs referencing
542 documentation for this unit or its configuration. Accepted are
543 only URIs of the types <literal>http://</literal>,
544 <literal>https://</literal>, <literal>file:</literal>,
545 <literal>info:</literal>, <literal>man:</literal>. For more
546 information about the syntax of these URIs, see <citerefentry
547 project='man-pages'><refentrytitle>uri</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
548 The URIs should be listed in order of relevance, starting with
549 the most relevant. It is a good idea to first reference
550 documentation that explains what the unit's purpose is,
551 followed by how it is configured, followed by any other
552 related documentation. This option may be specified more than
553 once, in which case the specified list of URIs is merged. If
554 the empty string is assigned to this option, the list is reset
555 and all prior assignments will have no
556 effect.</para></listitem>
557 </varlistentry>
558
559 <varlistentry>
560 <term><varname>Requires=</varname></term>
561
62d3ca24 562 <listitem><para>Configures requirement dependencies on other units. If this unit gets activated, the units
a195dd8e 563 listed here will be activated as well. If one of the other units fails to activate, and an ordering dependency
e79eabdb 564 <varname>After=</varname> on the failing unit is set, this unit will not be started. Besides, with or without
22a70563
ZJS
565 specifying <varname>After=</varname>, this unit will be stopped if one of the other units is explicitly
566 stopped. This option may be specified more than once or multiple space-separated units may be
62d3ca24
LP
567 specified in one option in which case requirement dependencies for all listed names will be created. Note that
568 requirement dependencies do not influence the order in which services are started or stopped. This has to be
569 configured independently with the <varname>After=</varname> or <varname>Before=</varname> options. If a unit
570 <filename>foo.service</filename> requires a unit <filename>bar.service</filename> as configured with
571 <varname>Requires=</varname> and no ordering is configured with <varname>After=</varname> or
572 <varname>Before=</varname>, then both units will be started simultaneously and without any delay between them
573 if <filename>foo.service</filename> is activated. Often, it is a better choice to use <varname>Wants=</varname>
574 instead of <varname>Requires=</varname> in order to achieve a system that is more robust when dealing with
575 failing services.</para>
576
577 <para>Note that this dependency type does not imply that the other unit always has to be in active state when
578 this unit is running. Specifically: failing condition checks (such as <varname>ConditionPathExists=</varname>,
6b5bb2f9 579 <varname>ConditionPathIsSymbolicLink=</varname>, … — see below) do not cause the start job of a unit with a
62d3ca24
LP
580 <varname>Requires=</varname> dependency on it to fail. Also, some unit types may deactivate on their own (for
581 example, a service process may decide to exit cleanly, or a device may be unplugged by the user), which is not
582 propagated to units having a <varname>Requires=</varname> dependency. Use the <varname>BindsTo=</varname>
583 dependency type together with <varname>After=</varname> to ensure that a unit may never be in active state
584 without a specific other unit also in active state (see below).</para>
585
586 <para>Note that dependencies of this type may also be configured outside of the unit configuration file by
587 adding a symlink to a <filename>.requires/</filename> directory accompanying the unit file. For details, see
798d3a52
ZJS
588 above.</para></listitem>
589 </varlistentry>
590
798d3a52
ZJS
591 <varlistentry>
592 <term><varname>Requisite=</varname></term>
798d3a52 593
706a3df4
ZJS
594 <listitem><para>Similar to <varname>Requires=</varname>. However, if the units listed here
595 are not started already, they will not be started and the starting of this unit will fail
596 immediately. <varname>Requisite=</varname> does not imply an ordering dependency, even if
597 both units are started in the same transaction. Hence this setting should usually be
598 combined with <varname>After=</varname>, to ensure this unit is not started before the other
599 unit.</para>
b2920668
ZJS
600
601 <para>When <varname>Requisite=b.service</varname> is used on
602 <filename>a.service</filename>, this dependency will show as
603 <varname>RequisiteOf=a.service</varname> in property listing of
604 <filename>b.service</filename>. <varname>RequisiteOf=</varname>
605 dependency cannot be specified directly.</para>
606 </listitem>
798d3a52
ZJS
607 </varlistentry>
608
609 <varlistentry>
610 <term><varname>Wants=</varname></term>
611
612 <listitem><para>A weaker version of
613 <varname>Requires=</varname>. Units listed in this option will
614 be started if the configuring unit is. However, if the listed
615 units fail to start or cannot be added to the transaction,
616 this has no impact on the validity of the transaction as a
617 whole. This is the recommended way to hook start-up of one
618 unit to the start-up of another unit.</para>
619
620 <para>Note that dependencies of this type may also be
621 configured outside of the unit configuration file by adding
622 symlinks to a <filename>.wants/</filename> directory
623 accompanying the unit file. For details, see
624 above.</para></listitem>
625 </varlistentry>
626
627 <varlistentry>
628 <term><varname>BindsTo=</varname></term>
629
62d3ca24
LP
630 <listitem><para>Configures requirement dependencies, very similar in style to
631 <varname>Requires=</varname>. However, this dependency type is stronger: in addition to the effect of
632 <varname>Requires=</varname> it declares that if the unit bound to is stopped, this unit will be stopped
633 too. This means a unit bound to another unit that suddenly enters inactive state will be stopped too.
634 Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit
635 might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of
636 a mount unit might be unmounted without involvement of the system and service manager.</para>
637
638 <para>When used in conjunction with <varname>After=</varname> on the same unit the behaviour of
639 <varname>BindsTo=</varname> is even stronger. In this case, the unit bound to strictly has to be in active
640 state for this unit to also be in active state. This not only means a unit bound to another unit that suddenly
641 enters inactive state, but also one that is bound to another unit that gets skipped due to a failed condition
642 check (such as <varname>ConditionPathExists=</varname>, <varname>ConditionPathIsSymbolicLink=</varname>, … —
643 see below) will be stopped, should it be running. Hence, in many cases it is best to combine
b2920668
ZJS
644 <varname>BindsTo=</varname> with <varname>After=</varname>.</para>
645
646 <para>When <varname>BindsTo=b.service</varname> is used on
647 <filename>a.service</filename>, this dependency will show as
648 <varname>BoundBy=a.service</varname> in property listing of
649 <filename>b.service</filename>. <varname>BoundBy=</varname>
650 dependency cannot be specified directly.</para>
651 </listitem>
798d3a52
ZJS
652 </varlistentry>
653
654 <varlistentry>
655 <term><varname>PartOf=</varname></term>
656
657 <listitem><para>Configures dependencies similar to
658 <varname>Requires=</varname>, but limited to stopping and
659 restarting of units. When systemd stops or restarts the units
660 listed here, the action is propagated to this unit. Note that
661 this is a one-way dependency — changes to this unit do not
b2920668
ZJS
662 affect the listed units.</para>
663
664 <para>When <varname>PartOf=b.service</varname> is used on
665 <filename>a.service</filename>, this dependency will show as
666 <varname>ConsistsOf=a.service</varname> in property listing of
667 <filename>b.service</filename>. <varname>ConsistsOf=</varname>
668 dependency cannot be specified directly.</para>
669 </listitem>
798d3a52
ZJS
670 </varlistentry>
671
672 <varlistentry>
673 <term><varname>Conflicts=</varname></term>
674
675 <listitem><para>A space-separated list of unit names.
676 Configures negative requirement dependencies. If a unit has a
677 <varname>Conflicts=</varname> setting on another unit,
678 starting the former will stop the latter and vice versa. Note
679 that this setting is independent of and orthogonal to the
680 <varname>After=</varname> and <varname>Before=</varname>
681 ordering dependencies.</para>
682
683 <para>If a unit A that conflicts with a unit B is scheduled to
684 be started at the same time as B, the transaction will either
46054ac0 685 fail (in case both are required parts of the transaction) or be
798d3a52
ZJS
686 modified to be fixed (in case one or both jobs are not a
687 required part of the transaction). In the latter case, the job
46054ac0 688 that is not required will be removed, or in case both are
798d3a52
ZJS
689 not required, the unit that conflicts will be started and the
690 unit that is conflicted is stopped.</para></listitem>
691 </varlistentry>
692
693 <varlistentry>
694 <term><varname>Before=</varname></term>
695 <term><varname>After=</varname></term>
696
2eb6ff5e
LP
697 <listitem><para>These two settings expect a space-separated list of unit names. They configure ordering
698 dependencies between units. If a unit <filename>foo.service</filename> contains a setting
699 <option>Before=bar.service</option> and both units are being started, <filename>bar.service</filename>'s
700 start-up is delayed until <filename>foo.service</filename> has finished starting up. Note that this setting is
701 independent of and orthogonal to the requirement dependencies as configured by <varname>Requires=</varname>,
702 <varname>Wants=</varname> or <varname>BindsTo=</varname>. It is a common pattern to include a unit name in both
703 the <varname>After=</varname> and <varname>Requires=</varname> options, in which case the unit listed will be
704 started before the unit that is configured with these options. This option may be specified more than once, in
705 which case ordering dependencies for all listed names are created. <varname>After=</varname> is the inverse of
706 <varname>Before=</varname>, i.e. while <varname>After=</varname> ensures that the configured unit is started
707 after the listed unit finished starting up, <varname>Before=</varname> ensures the opposite, that the
708 configured unit is fully started up before the listed unit is started. Note that when two units with an
709 ordering dependency between them are shut down, the inverse of the start-up order is applied. i.e. if a unit is
710 configured with <varname>After=</varname> on another unit, the former is stopped before the latter if both are
711 shut down. Given two units with any ordering dependency between them, if one unit is shut down and the other is
712 started up, the shutdown is ordered before the start-up. It doesn't matter if the ordering dependency is
713 <varname>After=</varname> or <varname>Before=</varname>, in this case. It also doesn't matter which of the two
714 is shut down, as long as one is shut down and the other is started up. The shutdown is ordered before the
715 start-up in all cases. If two units have no ordering dependencies between them, they are shut down or started
716 up simultaneously, and no ordering takes place. It depends on the unit type when precisely a unit has finished
717 starting up. Most importantly, for service units start-up is considered completed for the purpose of
718 <varname>Before=</varname>/<varname>After=</varname> when all its configured start-up commands have been
719 invoked and they either failed or reported start-up success.</para></listitem>
798d3a52
ZJS
720 </varlistentry>
721
722 <varlistentry>
723 <term><varname>OnFailure=</varname></term>
724
725 <listitem><para>A space-separated list of one or more units
726 that are activated when this unit enters the
bd2538b5
KBM
727 <literal>failed</literal> state. A service unit using
728 <varname>Restart=</varname> enters the failed state only after
729 the start limits are reached.</para></listitem>
798d3a52
ZJS
730 </varlistentry>
731
732 <varlistentry>
733 <term><varname>PropagatesReloadTo=</varname></term>
734 <term><varname>ReloadPropagatedFrom=</varname></term>
735
736 <listitem><para>A space-separated list of one or more units
737 where reload requests on this unit will be propagated to, or
738 reload requests on the other unit will be propagated to this
739 unit, respectively. Issuing a reload request on a unit will
740 automatically also enqueue a reload request on all units that
741 the reload request shall be propagated to via these two
742 settings.</para></listitem>
743 </varlistentry>
744
745 <varlistentry>
746 <term><varname>JoinsNamespaceOf=</varname></term>
747
4107452e
LP
748 <listitem><para>For units that start processes (such as service units), lists one or more other units
749 whose network and/or temporary file namespace to join. This only applies to unit types which support
750 the <varname>PrivateNetwork=</varname>, <varname>NetworkNamespacePath=</varname> and
798d3a52 751 <varname>PrivateTmp=</varname> directives (see
4107452e
LP
752 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
753 details). If a unit that has this setting set is started, its processes will see the same
754 <filename>/tmp</filename>, <filename>/var/tmp</filename> and network namespace as one listed unit
755 that is started. If multiple listed units are already started, it is not defined which namespace is
756 joined. Note that this setting only has an effect if
757 <varname>PrivateNetwork=</varname>/<varname>NetworkNamespacePath=</varname> and/or
758 <varname>PrivateTmp=</varname> is enabled for both the unit that joins the namespace and the unit
759 whose namespace is joined.</para></listitem>
798d3a52
ZJS
760 </varlistentry>
761
762 <varlistentry>
763 <term><varname>RequiresMountsFor=</varname></term>
764
765 <listitem><para>Takes a space-separated list of absolute
766 paths. Automatically adds dependencies of type
767 <varname>Requires=</varname> and <varname>After=</varname> for
768 all mount units required to access the specified path.</para>
769
770 <para>Mount points marked with <option>noauto</option> are not
88e328fd
ZJS
771 mounted automatically through <filename>local-fs.target</filename>,
772 but are still honored for the purposes of this option, i.e. they
773 will be pulled in by this unit.</para></listitem>
798d3a52
ZJS
774 </varlistentry>
775
776 <varlistentry>
777 <term><varname>OnFailureJobMode=</varname></term>
778
779 <listitem><para>Takes a value of
780 <literal>fail</literal>,
781 <literal>replace</literal>,
782 <literal>replace-irreversibly</literal>,
783 <literal>isolate</literal>,
784 <literal>flush</literal>,
785 <literal>ignore-dependencies</literal> or
786 <literal>ignore-requirements</literal>. Defaults to
787 <literal>replace</literal>. Specifies how the units listed in
788 <varname>OnFailure=</varname> will be enqueued. See
789 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
790 <option>--job-mode=</option> option for details on the
791 possible values. If this is set to <literal>isolate</literal>,
792 only a single unit may be listed in
793 <varname>OnFailure=</varname>..</para></listitem>
794 </varlistentry>
795
796 <varlistentry>
797 <term><varname>IgnoreOnIsolate=</varname></term>
798
26adf774
ZJS
799 <listitem><para>Takes a boolean argument. If <option>true</option>, this unit
800 will not be stopped when isolating another unit. Defaults to
801 <option>false</option> for service, target, socket, busname, timer, and path
802 units, and <option>true</option> for slice, scope, device, swap, mount, and
803 automount units.</para></listitem>
798d3a52
ZJS
804 </varlistentry>
805
798d3a52
ZJS
806 <varlistentry>
807 <term><varname>StopWhenUnneeded=</varname></term>
808
809 <listitem><para>Takes a boolean argument. If
810 <option>true</option>, this unit will be stopped when it is no
b938cb90 811 longer used. Note that, in order to minimize the work to be
798d3a52
ZJS
812 executed, systemd will not stop units by default unless they
813 are conflicting with other units, or the user explicitly
814 requested their shut down. If this option is set, a unit will
815 be automatically cleaned up if no other active unit requires
816 it. Defaults to <option>false</option>.</para></listitem>
817 </varlistentry>
818
819 <varlistentry>
820 <term><varname>RefuseManualStart=</varname></term>
821 <term><varname>RefuseManualStop=</varname></term>
822
823 <listitem><para>Takes a boolean argument. If
824 <option>true</option>, this unit can only be activated or
825 deactivated indirectly. In this case, explicit start-up or
826 termination requested by the user is denied, however if it is
827 started or stopped as a dependency of another unit, start-up
828 or termination will succeed. This is mostly a safety feature
829 to ensure that the user does not accidentally activate units
830 that are not intended to be activated explicitly, and not
831 accidentally deactivate units that are not intended to be
832 deactivated. These options default to
833 <option>false</option>.</para></listitem>
834 </varlistentry>
835
836 <varlistentry>
837 <term><varname>AllowIsolate=</varname></term>
838
839 <listitem><para>Takes a boolean argument. If
840 <option>true</option>, this unit may be used with the
841 <command>systemctl isolate</command> command. Otherwise, this
842 will be refused. It probably is a good idea to leave this
843 disabled except for target units that shall be used similar to
844 runlevels in SysV init systems, just as a precaution to avoid
845 unusable system states. This option defaults to
846 <option>false</option>.</para></listitem>
847 </varlistentry>
848
849 <varlistentry>
850 <term><varname>DefaultDependencies=</varname></term>
851
852 <listitem><para>Takes a boolean argument. If
c13fb257 853 <option>yes</option>, (the default), a few default
798d3a52
ZJS
854 dependencies will implicitly be created for the unit. The
855 actual dependencies created depend on the unit type. For
856 example, for service units, these dependencies ensure that the
857 service is started only after basic system initialization is
858 completed and is properly terminated on system shutdown. See
859 the respective man pages for details. Generally, only services
860 involved with early boot or late shutdown should set this
c13fb257 861 option to <option>no</option>. It is highly recommended to
798d3a52 862 leave this option enabled for the majority of common units. If
c13fb257 863 set to <option>no</option>, this option does not disable
798d3a52
ZJS
864 all implicit dependencies, just non-essential
865 ones.</para></listitem>
866 </varlistentry>
867
5afe510c
LP
868 <varlistentry>
869 <term><varname>CollectMode=</varname></term>
870
871 <listitem><para>Tweaks the "garbage collection" algorithm for this unit. Takes one of <option>inactive</option>
872 or <option>inactive-or-failed</option>. If set to <option>inactive</option> the unit will be unloaded if it is
873 in the <constant>inactive</constant> state and is not referenced by clients, jobs or other units — however it
874 is not unloaded if it is in the <constant>failed</constant> state. In <option>failed</option> mode, failed
875 units are not unloaded until the user invoked <command>systemctl reset-failed</command> on them to reset the
876 <constant>failed</constant> state, or an equivalent command. This behaviour is altered if this option is set to
877 <option>inactive-or-failed</option>: in this case the unit is unloaded even if the unit is in a
878 <constant>failed</constant> state, and thus an explicitly resetting of the <constant>failed</constant> state is
879 not necessary. Note that if this mode is used unit results (such as exit codes, exit signals, consumed
880 resources, …) are flushed out immediately after the unit completed, except for what is stored in the logging
881 subsystem. Defaults to <option>inactive</option>.</para>
882 </listitem>
883 </varlistentry>
884
454dd6ce
ZJS
885 <varlistentry>
886 <term><varname>FailureAction=</varname></term>
887 <term><varname>SuccessAction=</varname></term>
888
54fcb619
ZJS
889 <listitem><para>Configure the action to take when the unit stops and enters a failed state or inactive state.
890 Takes one of <option>none</option>, <option>reboot</option>, <option>reboot-force</option>,
891 <option>reboot-immediate</option>, <option>poweroff</option>, <option>poweroff-force</option>,
892 <option>poweroff-immediate</option>, <option>exit</option>, and <option>exit-force</option>. In system mode,
a400bd8c
ZJS
893 all options are allowed. In user mode, only <option>none</option>, <option>exit</option>, and
894 <option>exit-force</option> are allowed. Both options default to <option>none</option>.</para>
54fcb619
ZJS
895
896 <para>If <option>none</option> is set, no action will be triggered. <option>reboot</option> causes a reboot
897 following the normal shutdown procedure (i.e. equivalent to <command>systemctl reboot</command>).
898 <option>reboot-force</option> causes a forced reboot which will terminate all processes forcibly but should
899 cause no dirty file systems on reboot (i.e. equivalent to <command>systemctl reboot -f</command>) and
900 <option>reboot-immediate</option> causes immediate execution of the
454dd6ce 901 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call, which
6a4e939d
LP
902 might result in data loss (i.e. equivalent to <command>systemctl reboot -ff</command>). Similarly,
903 <option>poweroff</option>, <option>poweroff-force</option>, <option>poweroff-immediate</option> have the effect
904 of powering down the system with similar semantics. <option>exit</option> causes the manager to exit following
905 the normal shutdown procedure, and <option>exit-force</option> causes it terminate without shutting down
906 services. When <option>exit</option> or <option>exit-force</option> is used by default the exit status of the
5238e957 907 main process of the unit (if this applies) is returned from the service manager. However, this may be overridden
6a4e939d
LP
908 with <varname>FailureActionExitStatus=</varname>/<varname>SuccessActionExitStatus=</varname>, see
909 below.</para></listitem>
910 </varlistentry>
911
912 <varlistentry>
913 <term><varname>FailureActionExitStatus=</varname></term>
914 <term><varname>SuccessActionExitStatus=</varname></term>
915
916 <listitem><para>Controls the exit status to propagate back to an invoking container manager (in case of a
917 system service) or service manager (in case of a user manager) when the
918 <varname>FailureAction=</varname>/<varname>SuccessAction=</varname> are set to <option>exit</option> or
919 <option>exit-force</option> and the action is triggered. By default the exit status of the main process of the
920 triggering unit (if this applies) is propagated. Takes a value in the range 0…255 or the empty string to
921 request default behaviour.</para></listitem>
454dd6ce
ZJS
922 </varlistentry>
923
798d3a52
ZJS
924 <varlistentry>
925 <term><varname>JobTimeoutSec=</varname></term>
a2df3ea4 926 <term><varname>JobRunningTimeoutSec=</varname></term>
798d3a52 927
3f9a0a52 928 <listitem><para>When a job for this unit is queued, a timeout <varname>JobTimeoutSec=</varname> may be
a2df3ea4
MK
929 configured. Similarly, <varname>JobRunningTimeoutSec=</varname> starts counting when the queued job is actually
930 started. If either time limit is reached, the job will be cancelled, the unit however will not change state or
931 even enter the <literal>failed</literal> mode. This value defaults to <literal>infinity</literal> (job timeouts
932 disabled), except for device units (<varname>JobRunningTimeoutSec=</varname> defaults to
933 <varname>DefaultTimeoutStartSec=</varname>). NB: this timeout is independent from any unit-specific timeout
934 (for example, the timeout set with <varname>TimeoutStartSec=</varname> in service units) as the job timeout has
935 no effect on the unit itself, only on the job that might be pending for it. Or in other words: unit-specific
936 timeouts are useful to abort unit state changes, and revert them. The job timeout set with this option however
937 is useful to abort only the job waiting for the unit state to change.</para>
de597248
ZJS
938 </listitem>
939 </varlistentry>
940
941 <varlistentry>
942 <term><varname>JobTimeoutAction=</varname></term>
943 <term><varname>JobTimeoutRebootArgument=</varname></term>
798d3a52 944
de597248 945 <listitem><para><varname>JobTimeoutAction=</varname> optionally configures an additional action to take when
3f9a0a52 946 the timeout is hit, see description of <varname>JobTimeoutSec=</varname> and
de597248
ZJS
947 <varname>JobRunningTimeoutSec=</varname> above. It takes the same values as
948 <varname>StartLimitAction=</varname>. Defaults to <option>none</option>.
0aabe747 949 <varname>JobTimeoutRebootArgument=</varname> configures an optional reboot string to pass to the
de597248
ZJS
950 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call.
951 </para></listitem>
798d3a52
ZJS
952 </varlistentry>
953
6bf0f408 954 <varlistentry>
fc5ffacd
ZJS
955 <term><varname>StartLimitIntervalSec=<replaceable>interval</replaceable></varname></term>
956 <term><varname>StartLimitBurst=<replaceable>burst</replaceable></varname></term>
6bf0f408 957
fc5ffacd 958 <listitem><para>Configure unit start rate limiting. Units which are started more than
b94f4313
LP
959 <replaceable>burst</replaceable> times within an <replaceable>interval</replaceable> time interval are not
960 permitted to start any more. Use <varname>StartLimitIntervalSec=</varname> to configure the checking interval
961 (defaults to <varname>DefaultStartLimitIntervalSec=</varname> in manager configuration file, set it to 0 to
962 disable any kind of rate limiting). Use <varname>StartLimitBurst=</varname> to configure how many starts per
963 interval are allowed (defaults to <varname>DefaultStartLimitBurst=</varname> in manager configuration
964 file). These configuration options are particularly useful in conjunction with the service setting
965 <varname>Restart=</varname> (see
6bf0f408
LP
966 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>); however,
967 they apply to all kinds of starts (including manual), not just those triggered by the
968 <varname>Restart=</varname> logic. Note that units which are configured for <varname>Restart=</varname> and
969 which reach the start limit are not attempted to be restarted anymore; however, they may still be restarted
b94f4313
LP
970 manually at a later point, after the <replaceable>interval</replaceable> has passed. From this point on, the
971 restart logic is activated again. Note that <command>systemctl reset-failed</command> will cause the restart
972 rate counter for a service to be flushed, which is useful if the administrator wants to manually start a unit
973 and the start limit interferes with that. Note that this rate-limiting is enforced after any unit condition
974 checks are executed, and hence unit activations with failing conditions do not count towards this rate
975 limit. This setting does not apply to slice, target, device, and scope units, since they are unit types whose
976 activation may either never fail, or may succeed only a single time.</para>
977
978 <para>When a unit is unloaded due to the garbage collection logic (see above) its rate limit counters are
1b2ad5d9 979 flushed out too. This means that configuring start rate limiting for a unit that is not referenced continuously
b94f4313 980 has no effect.</para></listitem>
6bf0f408
LP
981 </varlistentry>
982
983 <varlistentry>
984 <term><varname>StartLimitAction=</varname></term>
985
454dd6ce
ZJS
986 <listitem><para>Configure an additional action to take if the rate limit configured with
987 <varname>StartLimitIntervalSec=</varname> and <varname>StartLimitBurst=</varname> is hit. Takes the same
988 values as the setting <varname>FailureAction=</varname>/<varname>SuccessAction=</varname> settings and executes
989 the same actions. If <option>none</option> is set, hitting the rate limit will trigger no action besides that
990 the start will not be permitted. Defaults to <option>none</option>.</para></listitem>
6bf0f408
LP
991 </varlistentry>
992
53c35a76 993
6bf0f408
LP
994 <varlistentry>
995 <term><varname>RebootArgument=</varname></term>
996 <listitem><para>Configure the optional argument for the
997 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call if
53c35a76 998 <varname>StartLimitAction=</varname> or <varname>FailureAction=</varname> is a reboot action. This
6bf0f408
LP
999 works just like the optional argument to <command>systemctl reboot</command> command.</para></listitem>
1000 </varlistentry>
1001
798d3a52
ZJS
1002 <varlistentry>
1003 <term><varname>ConditionArchitecture=</varname></term>
1004 <term><varname>ConditionVirtualization=</varname></term>
1005 <term><varname>ConditionHost=</varname></term>
1006 <term><varname>ConditionKernelCommandLine=</varname></term>
5022f08a 1007 <term><varname>ConditionKernelVersion=</varname></term>
798d3a52
ZJS
1008 <term><varname>ConditionSecurity=</varname></term>
1009 <term><varname>ConditionCapability=</varname></term>
1010 <term><varname>ConditionACPower=</varname></term>
1011 <term><varname>ConditionNeedsUpdate=</varname></term>
1012 <term><varname>ConditionFirstBoot=</varname></term>
1013 <term><varname>ConditionPathExists=</varname></term>
1014 <term><varname>ConditionPathExistsGlob=</varname></term>
1015 <term><varname>ConditionPathIsDirectory=</varname></term>
1016 <term><varname>ConditionPathIsSymbolicLink=</varname></term>
1017 <term><varname>ConditionPathIsMountPoint=</varname></term>
1018 <term><varname>ConditionPathIsReadWrite=</varname></term>
1019 <term><varname>ConditionDirectoryNotEmpty=</varname></term>
1020 <term><varname>ConditionFileNotEmpty=</varname></term>
1021 <term><varname>ConditionFileIsExecutable=</varname></term>
c465a29f
FS
1022 <term><varname>ConditionUser=</varname></term>
1023 <term><varname>ConditionGroup=</varname></term>
e16647c3 1024 <term><varname>ConditionControlGroupController=</varname></term>
2b60d7ea
LP
1025 <term><varname>ConditionMemory=</varname></term>
1026 <term><varname>ConditionCPUs=</varname></term>
798d3a52 1027
bbd199c4 1028 <!-- We do not document ConditionNull= here, as it is not particularly useful and probably just
798d3a52
ZJS
1029 confusing. -->
1030
41448597
LP
1031 <listitem><para>Before starting a unit, verify that the specified condition is true. If it is not true, the
1032 starting of the unit will be (mostly silently) skipped, however all ordering dependencies of it are still
53bd20ea
LP
1033 respected. A failing condition will not result in the unit being moved into the <literal>failed</literal>
1034 state. The condition is checked at the time the queued start job is to be executed. Use condition expressions
1035 in order to silently skip units that do not apply to the local running system, for example because the kernel
1036 or runtime environment doesn't require their functionality. Use the various
1037 <varname>AssertArchitecture=</varname>, <varname>AssertVirtualization=</varname>, … options for a similar
1038 mechanism that causes the job to fail (instead of being skipped) and results in logging about the failed check
ccc162e0
SS
1039 (instead of being silently processed). For details about assertion conditions see below. Units with failed
1040 conditions are considered to be in a clean state and will be garbage collected if they are not referenced.
1041 This means, that when queried, the condition failure may or may not show up in the state of the unit.</para>
798d3a52 1042
bbd199c4
ZJS
1043 <para>If multiple conditions are specified, the unit will be executed if all of them apply (i.e. a
1044 logical AND is applied). Condition checks can be prefixed with a pipe symbol (<literal>|</literal>)
1045 in which case a condition becomes a triggering condition. If at least one triggering condition is
1046 defined for a unit, then the unit will be executed if at least one of the triggering conditions apply
1047 and all of the non-triggering conditions. If you prefix an argument with the pipe symbol and an
1048 exclamation mark, the pipe symbol must be passed first, the exclamation second. Except for
1049 <varname>ConditionPathIsSymbolicLink=</varname>, all path checks follow symlinks. If any of these
1050 options is assigned the empty string, the list of conditions is reset completely, all previous
edfea9fe
ZJS
1051 condition settings (of any kind) will have no effect. The <command>condition</command> verb of
1052 <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1053 can be used to test condition and assert expressions.</para>
bbd199c4 1054
798d3a52
ZJS
1055 <para><varname>ConditionArchitecture=</varname> may be used to
1056 check whether the system is running on a specific
1057 architecture. Takes one of
1cdca397
YW
1058 <literal>x86</literal>,
1059 <literal>x86-64</literal>,
1060 <literal>ppc</literal>,
1061 <literal>ppc-le</literal>,
1062 <literal>ppc64</literal>,
1063 <literal>ppc64-le</literal>,
1064 <literal>ia64</literal>,
1065 <literal>parisc</literal>,
1066 <literal>parisc64</literal>,
1067 <literal>s390</literal>,
1068 <literal>s390x</literal>,
1069 <literal>sparc</literal>,
1070 <literal>sparc64</literal>,
1071 <literal>mips</literal>,
1072 <literal>mips-le</literal>,
1073 <literal>mips64</literal>,
1074 <literal>mips64-le</literal>,
1075 <literal>alpha</literal>,
1076 <literal>arm</literal>,
1077 <literal>arm-be</literal>,
1078 <literal>arm64</literal>,
1079 <literal>arm64-be</literal>,
1080 <literal>sh</literal>,
1081 <literal>sh64</literal>,
1082 <literal>m68k</literal>,
1083 <literal>tilegx</literal>,
1084 <literal>cris</literal>,
1085 <literal>arc</literal>,
1086 <literal>arc-be</literal> to test
798d3a52
ZJS
1087 against a specific architecture. The architecture is
1088 determined from the information returned by
3ba3a79d 1089 <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
798d3a52
ZJS
1090 and is thus subject to
1091 <citerefentry><refentrytitle>personality</refentrytitle><manvolnum>2</manvolnum></citerefentry>.
1092 Note that a <varname>Personality=</varname> setting in the
1093 same unit file has no effect on this condition. A special
1cdca397 1094 architecture name <literal>native</literal> is mapped to the
798d3a52
ZJS
1095 architecture the system manager itself is compiled for. The
1096 test may be negated by prepending an exclamation mark.</para>
1097
1098 <para><varname>ConditionVirtualization=</varname> may be used
1099 to check whether the system is executed in a virtualized
1100 environment and optionally test whether it is a specific
1101 implementation. Takes either boolean value to check if being
1102 executed in any virtualized environment, or one of
1cdca397
YW
1103 <literal>vm</literal> and
1104 <literal>container</literal> to test against a generic type of
798d3a52 1105 virtualization solution, or one of
1cdca397
YW
1106 <literal>qemu</literal>,
1107 <literal>kvm</literal>,
1108 <literal>zvm</literal>,
1109 <literal>vmware</literal>,
1110 <literal>microsoft</literal>,
1111 <literal>oracle</literal>,
1112 <literal>xen</literal>,
1113 <literal>bochs</literal>,
1114 <literal>uml</literal>,
1115 <literal>bhyve</literal>,
1116 <literal>qnx</literal>,
1117 <literal>openvz</literal>,
1118 <literal>lxc</literal>,
1119 <literal>lxc-libvirt</literal>,
1120 <literal>systemd-nspawn</literal>,
1121 <literal>docker</literal>,
90fb1f09 1122 <literal>podman</literal>,
1cdca397
YW
1123 <literal>rkt</literal>,
1124 <literal>wsl</literal>,
1125 <literal>acrn</literal> to test
299a34c1 1126 against a specific implementation, or
1cdca397 1127 <literal>private-users</literal> to check whether we are running in a user namespace. See
798d3a52
ZJS
1128 <citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1129 for a full list of known virtualization technologies and their
1130 identifiers. If multiple virtualization technologies are
1131 nested, only the innermost is considered. The test may be
1132 negated by prepending an exclamation mark.</para>
1133
1134 <para><varname>ConditionHost=</varname> may be used to match
1135 against the hostname or machine ID of the host. This either
1136 takes a hostname string (optionally with shell style globs)
1137 which is tested against the locally set hostname as returned
1138 by
1139 <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1140 or a machine ID formatted as string (see
1141 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
1142 The test may be negated by prepending an exclamation
1143 mark.</para>
1144
1145 <para><varname>ConditionKernelCommandLine=</varname> may be
1146 used to check whether a specific kernel command line option is
1147 set (or if prefixed with the exclamation mark unset). The
1148 argument must either be a single word, or an assignment (i.e.
1149 two words, separated <literal>=</literal>). In the former case
1150 the kernel command line is searched for the word appearing as
1151 is, or as left hand side of an assignment. In the latter case,
1152 the exact assignment is looked for with right and left hand
1153 side matching.</para>
1154
2877d428
LP
1155 <para><varname>ConditionKernelVersion=</varname> may be used to check whether the kernel version (as
1156 reported by <command>uname -r</command>) matches a certain expression (or if prefixed with the
910c6d09
ZJS
1157 exclamation mark does not match it). The argument must be a list of (potentially quoted) expressions.
1158 For each of the expressions, if it starts with one of <literal>&lt;</literal>,
1159 <literal>&lt;=</literal>, <literal>=</literal>, <literal>!=</literal>, <literal>&gt;=</literal>,
1160 <literal>&gt;</literal> a relative version comparison is done, otherwise the specified string is
1161 matched with shell-style globs.</para>
5022f08a 1162
871c6d54
ZJS
1163 <para>Note that using the kernel version string is an unreliable way to determine which features are supported
1164 by a kernel, because of the widespread practice of backporting drivers, features, and fixes from newer upstream
1165 kernels into older versions provided by distributions. Hence, this check is inherently unportable and should
1166 not be used for units which may be used on different distributions.</para>
1167
be405b90
LP
1168 <para><varname>ConditionSecurity=</varname> may be used to check
1169 whether the given security technology is enabled on the
b8e1d4d1 1170 system. Currently, the recognized values are
1cdca397
YW
1171 <literal>selinux</literal>, <literal>apparmor</literal>,
1172 <literal>tomoyo</literal>, <literal>ima</literal>,
1173 <literal>smack</literal>, <literal>audit</literal> and
1174 <literal>uefi-secureboot</literal>. The test may be negated by
798d3a52
ZJS
1175 prepending an exclamation mark.</para>
1176
1177 <para><varname>ConditionCapability=</varname> may be used to
1178 check whether the given capability exists in the capability
1179 bounding set of the service manager (i.e. this does not check
1180 whether capability is actually available in the permitted or
1181 effective sets, see
1182 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
1183 for details). Pass a capability name such as
1184 <literal>CAP_MKNOD</literal>, possibly prefixed with an
1185 exclamation mark to negate the check.</para>
1186
1187 <para><varname>ConditionACPower=</varname> may be used to
1188 check whether the system has AC power, or is exclusively
1189 battery powered at the time of activation of the unit. This
1cdca397 1190 takes a boolean argument. If set to <literal>true</literal>,
798d3a52
ZJS
1191 the condition will hold only if at least one AC connector of
1192 the system is connected to a power source, or if no AC
1193 connectors are known. Conversely, if set to
1cdca397 1194 <literal>false</literal>, the condition will hold only if
798d3a52
ZJS
1195 there is at least one AC connector known and all AC connectors
1196 are disconnected from a power source.</para>
1197
1198 <para><varname>ConditionNeedsUpdate=</varname> takes one of
1199 <filename>/var</filename> or <filename>/etc</filename> as
1200 argument, possibly prefixed with a <literal>!</literal> (for
1201 inverting the condition). This condition may be used to
1202 conditionalize units on whether the specified directory
1203 requires an update because <filename>/usr</filename>'s
1204 modification time is newer than the stamp file
1205 <filename>.updated</filename> in the specified directory. This
1206 is useful to implement offline updates of the vendor operating
1207 system resources in <filename>/usr</filename> that require
1208 updating of <filename>/etc</filename> or
1209 <filename>/var</filename> on the next following boot. Units
1210 making use of this condition should order themselves before
1211 <citerefentry><refentrytitle>systemd-update-done.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
7f3fdb7f 1212 to make sure they run before the stamp file's modification
798d3a52
ZJS
1213 time gets reset indicating a completed update.</para>
1214
23254af1
LP
1215 <para><varname>ConditionFirstBoot=</varname> takes a boolean argument. This condition may be used to
1216 conditionalize units on whether the system is booting up with an unpopulated <filename>/etc</filename>
1217 directory (specifically: an <filename>/etc</filename> with no <filename>/etc/machine-id</filename>). This may
1218 be used to populate <filename>/etc</filename> on the first boot after factory reset, or when a new system
1219 instance boots up for the first time.</para>
798d3a52
ZJS
1220
1221 <para>With <varname>ConditionPathExists=</varname> a file
1222 existence condition is checked before a unit is started. If
1223 the specified absolute path name does not exist, the condition
1224 will fail. If the absolute path name passed to
1225 <varname>ConditionPathExists=</varname> is prefixed with an
1226 exclamation mark (<literal>!</literal>), the test is negated,
1227 and the unit is only started if the path does not
1228 exist.</para>
1229
1230 <para><varname>ConditionPathExistsGlob=</varname> is similar
1231 to <varname>ConditionPathExists=</varname>, but checks for the
1232 existence of at least one file or directory matching the
1233 specified globbing pattern.</para>
1234
1235 <para><varname>ConditionPathIsDirectory=</varname> is similar
1236 to <varname>ConditionPathExists=</varname> but verifies
1237 whether a certain path exists and is a directory.</para>
1238
1239 <para><varname>ConditionPathIsSymbolicLink=</varname> is
1240 similar to <varname>ConditionPathExists=</varname> but
1241 verifies whether a certain path exists and is a symbolic
1242 link.</para>
1243
1244 <para><varname>ConditionPathIsMountPoint=</varname> is similar
1245 to <varname>ConditionPathExists=</varname> but verifies
1246 whether a certain path exists and is a mount point.</para>
1247
1248 <para><varname>ConditionPathIsReadWrite=</varname> is similar
1249 to <varname>ConditionPathExists=</varname> but verifies
1250 whether the underlying file system is readable and writable
1251 (i.e. not mounted read-only).</para>
1252
1253 <para><varname>ConditionDirectoryNotEmpty=</varname> is
1254 similar to <varname>ConditionPathExists=</varname> but
1255 verifies whether a certain path exists and is a non-empty
1256 directory.</para>
1257
1258 <para><varname>ConditionFileNotEmpty=</varname> is similar to
1259 <varname>ConditionPathExists=</varname> but verifies whether a
1260 certain path exists and refers to a regular file with a
1261 non-zero size.</para>
1262
1263 <para><varname>ConditionFileIsExecutable=</varname> is similar
1264 to <varname>ConditionPathExists=</varname> but verifies
1265 whether a certain path exists, is a regular file and marked
1266 executable.</para>
1267
c465a29f 1268 <para><varname>ConditionUser=</varname> takes a numeric
534bab66
FS
1269 <literal>UID</literal>, a UNIX user name, or the special value
1270 <literal>@system</literal>. This condition may be used to check
1271 whether the service manager is running as the given user. The
1272 special value <literal>@system</literal> can be used to check
1273 if the user id is within the system user range. This option is not
c465a29f
FS
1274 useful for system services, as the system manager exclusively
1275 runs as the root user, and thus the test result is constant.</para>
1276
1277 <para><varname>ConditionGroup=</varname> is similar
1278 to <varname>ConditionUser=</varname> but verifies that the
1279 service manager's real or effective group, or any of its
534bab66
FS
1280 auxiliary groups match the specified group or GID. This setting
1281 does not have a special value <literal>@system</literal>.</para>
c465a29f 1282
e16647c3 1283 <para><varname>ConditionControlGroupController=</varname> takes a
1cdca397 1284 cgroup controller name (eg. <literal>cpu</literal>), verifying that it is
e16647c3
CD
1285 available for use on the system. For example, a particular controller
1286 may not be available if it was disabled on the kernel command line with
aad1e6be
CD
1287 <varname>cgroup_disable=controller</varname>. Multiple controllers may
1288 be passed with a space separating them; in this case the condition will
1289 only pass if all listed controllers are available for use. Controllers
1290 unknown to systemd are ignored. Valid controllers are
1cdca397
YW
1291 <literal>cpu</literal>, <literal>cpuacct</literal>, <literal>io</literal>,
1292 <literal>blkio</literal>, <literal>memory</literal>,
1293 <literal>devices</literal>, and <literal>pids</literal>.</para>
e16647c3 1294
2b60d7ea
LP
1295 <para><varname>ConditionMemory=</varname> verifies if the specified amount of system memory is
1296 available to the current system. Takes a memory size in bytes as argument, optionally prefixed with a
1297 comparison operator <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>=</literal>,
1298 <literal>!=</literal>, <literal>&gt;=</literal>, <literal>&gt;</literal>. On bare-metal systems
1299 compares the amount of physical memory in the system with the specified size, adhering to the
1300 specified comparison operator. In containers compares the amount of memory assigned to the container
1301 instead.</para>
1302
1303 <para><varname>ConditionCPUs=</varname> verifies if the specified number of CPUs is available to the
1304 current system. Takes a number of CPUs as argument, optionally prefixed with a comparison operator
1305 <literal>&lt;</literal>, <literal>&lt;=</literal>, <literal>=</literal>, <literal>!=</literal>,
1306 <literal>&gt;=</literal>, <literal>&gt;</literal>. Compares the number of CPUs in the CPU affinity mask
1307 configured of the service manager itself with the specified number, adhering to the specified
5238e957 1308 comparison operator. On physical systems the number of CPUs in the affinity mask of the service
2b60d7ea
LP
1309 manager usually matches the number of physical CPUs, but in special and virtual environments might
1310 differ. In particular, in containers the affinity mask usually matches the number of CPUs assigned to
bbd199c4 1311 the container and not the physically available ones.</para></listitem>
798d3a52
ZJS
1312 </varlistentry>
1313
1314 <varlistentry>
1315 <term><varname>AssertArchitecture=</varname></term>
1316 <term><varname>AssertVirtualization=</varname></term>
1317 <term><varname>AssertHost=</varname></term>
1318 <term><varname>AssertKernelCommandLine=</varname></term>
5022f08a 1319 <term><varname>AssertKernelVersion=</varname></term>
798d3a52
ZJS
1320 <term><varname>AssertSecurity=</varname></term>
1321 <term><varname>AssertCapability=</varname></term>
1322 <term><varname>AssertACPower=</varname></term>
1323 <term><varname>AssertNeedsUpdate=</varname></term>
1324 <term><varname>AssertFirstBoot=</varname></term>
1325 <term><varname>AssertPathExists=</varname></term>
1326 <term><varname>AssertPathExistsGlob=</varname></term>
1327 <term><varname>AssertPathIsDirectory=</varname></term>
1328 <term><varname>AssertPathIsSymbolicLink=</varname></term>
1329 <term><varname>AssertPathIsMountPoint=</varname></term>
1330 <term><varname>AssertPathIsReadWrite=</varname></term>
1331 <term><varname>AssertDirectoryNotEmpty=</varname></term>
1332 <term><varname>AssertFileNotEmpty=</varname></term>
1333 <term><varname>AssertFileIsExecutable=</varname></term>
c465a29f
FS
1334 <term><varname>AssertUser=</varname></term>
1335 <term><varname>AssertGroup=</varname></term>
e16647c3 1336 <term><varname>AssertControlGroupController=</varname></term>
798d3a52 1337
41448597
LP
1338 <listitem><para>Similar to the <varname>ConditionArchitecture=</varname>,
1339 <varname>ConditionVirtualization=</varname>, …, condition settings described above, these settings add
1340 assertion checks to the start-up of the unit. However, unlike the conditions settings, any assertion setting
53bd20ea
LP
1341 that is not met results in failure of the start job (which means this is logged loudly). Note that hitting a
1342 configured assertion does not cause the unit to enter the <literal>failed</literal> state (or in fact result in
1343 any state change of the unit), it affects only the job queued for it. Use assertion expressions for units that
1344 cannot operate when specific requirements are not met, and when this is something the administrator or user
1345 should look into.</para>
1346
1347 <para>Note that neither assertion nor condition expressions result in unit state changes. Also note that both
1348 are checked at the time the job is to be executed, i.e. long after depending jobs and it itself were
1349 queued. Thus, neither condition nor assertion expressions are suitable for conditionalizing unit
edfea9fe
ZJS
1350 dependencies.</para>
1351
1352 <para>The <command>condition</command> verb of
1353 <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1354 can be used to test condition and assert expressions.</para></listitem>
798d3a52
ZJS
1355 </varlistentry>
1356
1357 <varlistentry>
1358 <term><varname>SourcePath=</varname></term>
1359 <listitem><para>A path to a configuration file this unit has
1360 been generated from. This is primarily useful for
1361 implementation of generator tools that convert configuration
1362 from an external configuration file format into native unit
1363 files. This functionality should not be used in normal
1364 units.</para></listitem>
1365 </varlistentry>
1366 </variablelist>
2bf92506
ZJS
1367 </refsect1>
1368
1369 <refsect1>
1370 <title>Mapping of unit properties to their inverses</title>
1371
1372 <para>Unit settings that create a relationship with a second unit usually show up
1373 in properties of both units, for example in <command>systemctl show</command>
1374 output. In some cases the name of the property is the same as the name of the
2116134b 1375 configuration setting, but not always. This table lists the properties
2bf92506
ZJS
1376 that are shown on two units which are connected through some dependency, and shows
1377 which property on "source" unit corresponds to which property on the "target" unit.
1378 </para>
1379
1380 <table>
1381 <title>
1382 "Forward" and "reverse" unit properties
1383 </title>
1384
2eca7635 1385 <tgroup cols='4'>
2bf92506
ZJS
1386 <colspec colname='forward' />
1387 <colspec colname='reverse' />
2eca7635
ZJS
1388 <colspec colname='fuse' />
1389 <colspec colname='ruse' />
2bf92506
ZJS
1390 <thead>
1391 <row>
1392 <entry>"Forward" property</entry>
1393 <entry>"Reverse" property</entry>
2eca7635 1394 <entry namest='fuse' nameend='ruse' valign='middle'>Where used</entry>
2bf92506
ZJS
1395 </row>
1396 </thead>
1397 <tbody>
1398 <row>
1399 <entry><varname>Before=</varname></entry>
1400 <entry><varname>After=</varname></entry>
2eca7635 1401 <entry morerows='1' namest='fuse' nameend='ruse' valign='middle'>[Unit] section</entry>
2bf92506
ZJS
1402 </row>
1403 <row>
1404 <entry><varname>After=</varname></entry>
1405 <entry><varname>Before=</varname></entry>
1406 </row>
1407 <row>
1408 <entry><varname>Requires=</varname></entry>
1409 <entry><varname>RequiredBy=</varname></entry>
2eca7635
ZJS
1410 <entry>[Unit] section</entry>
1411 <entry>[Install] section</entry>
2bf92506
ZJS
1412 </row>
1413 <row>
1414 <entry><varname>Wants=</varname></entry>
1415 <entry><varname>WantedBy=</varname></entry>
2eca7635
ZJS
1416 <entry>[Unit] section</entry>
1417 <entry>[Install] section</entry>
2bf92506
ZJS
1418 </row>
1419 <row>
1420 <entry><varname>PartOf=</varname></entry>
1421 <entry><varname>ConsistsOf=</varname></entry>
2eca7635
ZJS
1422 <entry>[Unit] section</entry>
1423 <entry>an automatic property</entry>
2bf92506
ZJS
1424 </row>
1425 <row>
1426 <entry><varname>BindsTo=</varname></entry>
1427 <entry><varname>BoundBy=</varname></entry>
2eca7635
ZJS
1428 <entry>[Unit] section</entry>
1429 <entry>an automatic property</entry>
2bf92506
ZJS
1430 </row>
1431 <row>
1432 <entry><varname>Requisite=</varname></entry>
1433 <entry><varname>RequisiteOf=</varname></entry>
2eca7635
ZJS
1434 <entry>[Unit] section</entry>
1435 <entry>an automatic property</entry>
2bf92506
ZJS
1436 </row>
1437 <row>
1438 <entry><varname>Triggers=</varname></entry>
1439 <entry><varname>TriggeredBy=</varname></entry>
2eca7635 1440 <entry namest='fuse' nameend='ruse' valign='middle'>Automatic properties, see notes below</entry>
2bf92506
ZJS
1441 </row>
1442 <row>
1443 <entry><varname>Conflicts=</varname></entry>
1444 <entry><varname>ConflictedBy=</varname></entry>
2eca7635
ZJS
1445 <entry>[Unit] section</entry>
1446 <entry>an automatic property</entry>
2bf92506
ZJS
1447 </row>
1448 <row>
1449 <entry><varname>PropagatesReloadTo=</varname></entry>
1450 <entry><varname>ReloadPropagatedFrom=</varname></entry>
2eca7635 1451 <entry morerows='1' namest='fuse' nameend='ruse' valign='middle'>[Unit] section</entry>
2bf92506
ZJS
1452 </row>
1453 <row>
1454 <entry><varname>ReloadPropagatedFrom=</varname></entry>
1455 <entry><varname>PropagatesReloadTo=</varname></entry>
1456 </row>
2116134b
ZJS
1457 <row>
1458 <entry><varname>Following=</varname></entry>
1459 <entry>n/a</entry>
1460 <entry>An automatic property</entry>
1461 </row>
2bf92506
ZJS
1462 </tbody>
1463 </tgroup>
1464 </table>
798d3a52 1465
2bf92506
ZJS
1466 <para>Note: <varname>WantedBy=</varname> and <varname>RequiredBy=</varname> are
1467 used in the [Install] section to create symlinks in <filename>.wants/</filename>
1468 and <filename>.requires/</filename> directories. They cannot be used directly as a
1469 unit configuration setting.</para>
1470
1471 <para>Note: <varname>ConsistsOf=</varname>, <varname>BoundBy=</varname>,
1472 <varname>RequisiteOf=</varname>, <varname>ConflictedBy=</varname> are created
1473 implicitly along with their reverse and cannot be specified directly.</para>
1474
1475 <para>Note: <varname>Triggers=</varname> is created implicitly between a socket,
1476 path unit, or an automount unit, and the unit they activate. By default a unit
1b2ad5d9 1477 with the same name is triggered, but this can be overridden using
2bf92506
ZJS
1478 <varname>Sockets=</varname>, <varname>Service=</varname>, and <varname>Unit=</varname>
1479 settings. See
1480 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1481 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1482 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1483 and
1484 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1485 for details. <varname>TriggersBy=</varname> is created implicitly on the
1486 triggered unit.</para>
2116134b
ZJS
1487
1488 <para>Note: <varname>Following=</varname> is used to group device aliases and points to the
1489 "primary" device unit that systemd is using to track device state, usually corresponding to a
1490 sysfs path. It does not show up in the "target" unit.</para>
798d3a52
ZJS
1491 </refsect1>
1492
1493 <refsect1>
1494 <title>[Install] Section Options</title>
1495
be73bb48
LP
1496 <para>Unit files may include an <literal>[Install]</literal> section, which carries installation information for
1497 the unit. This section is not interpreted by
1498 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> during runtime; it is
1499 used by the <command>enable</command> and <command>disable</command> commands of the
1500 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool during
caa45f5b 1501 installation of a unit.</para>
798d3a52
ZJS
1502
1503 <variablelist class='unit-directives'>
1504 <varlistentry>
1505 <term><varname>Alias=</varname></term>
1506
f4bf8d2f 1507 <listitem><para>A space-separated list of additional names this unit shall be installed under. The names listed
1245e413 1508 here must have the same suffix (i.e. type) as the unit filename. This option may be specified more than once,
f4bf8d2f
LP
1509 in which case all listed names are used. At installation time, <command>systemctl enable</command> will create
1510 symlinks from these names to the unit filename. Note that not all unit types support such alias names, and this
1511 setting is not supported for them. Specifically, mount, slice, swap, and automount units do not support
1512 aliasing.</para></listitem>
798d3a52
ZJS
1513 </varlistentry>
1514
1515 <varlistentry>
1516 <term><varname>WantedBy=</varname></term>
1517 <term><varname>RequiredBy=</varname></term>
1518
1519 <listitem><para>This option may be used more than once, or a
1520 space-separated list of unit names may be given. A symbolic
1521 link is created in the <filename>.wants/</filename> or
1522 <filename>.requires/</filename> directory of each of the
1523 listed units when this unit is installed by <command>systemctl
1524 enable</command>. This has the effect that a dependency of
1525 type <varname>Wants=</varname> or <varname>Requires=</varname>
1526 is added from the listed unit to the current unit. The primary
1527 result is that the current unit will be started when the
1528 listed unit is started. See the description of
1529 <varname>Wants=</varname> and <varname>Requires=</varname> in
1530 the [Unit] section for details.</para>
1531
1532 <para><command>WantedBy=foo.service</command> in a service
1533 <filename>bar.service</filename> is mostly equivalent to
1534 <command>Alias=foo.service.wants/bar.service</command> in the
1535 same file. In case of template units, <command>systemctl
1536 enable</command> must be called with an instance name, and
1537 this instance will be added to the
1538 <filename>.wants/</filename> or
1539 <filename>.requires/</filename> list of the listed unit. E.g.
1540 <command>WantedBy=getty.target</command> in a service
1541 <filename>getty@.service</filename> will result in
1542 <command>systemctl enable getty@tty2.service</command>
1543 creating a
1544 <filename>getty.target.wants/getty@tty2.service</filename>
1545 link to <filename>getty@.service</filename>.
1546 </para></listitem>
1547 </varlistentry>
1548
1549 <varlistentry>
1550 <term><varname>Also=</varname></term>
1551
1552 <listitem><para>Additional units to install/deinstall when
1553 this unit is installed/deinstalled. If the user requests
1554 installation/deinstallation of a unit with this option
1555 configured, <command>systemctl enable</command> and
1556 <command>systemctl disable</command> will automatically
1557 install/uninstall units listed in this option as well.</para>
1558
1559 <para>This option may be used more than once, or a
1560 space-separated list of unit names may be
1561 given.</para></listitem>
1562 </varlistentry>
1563
1564 <varlistentry>
1565 <term><varname>DefaultInstance=</varname></term>
1566
1567 <listitem><para>In template unit files, this specifies for
1568 which instance the unit shall be enabled if the template is
1569 enabled without any explicitly set instance. This option has
1570 no effect in non-template unit files. The specified string
1571 must be usable as instance identifier.</para></listitem>
1572 </varlistentry>
1573 </variablelist>
1574
1575 <para>The following specifiers are interpreted in the Install
b75f0c69
DC
1576 section: %n, %N, %p, %i, %j, %g, %G, %U, %u, %m, %H, %b, %v. For their
1577 meaning see the next section.
798d3a52
ZJS
1578 </para>
1579 </refsect1>
1580
1581 <refsect1>
1582 <title>Specifiers</title>
1583
1584 <para>Many settings resolve specifiers which may be used to write
1585 generic unit files referring to runtime or unit parameters that
751223fe
ZJS
1586 are replaced when the unit files are loaded. Specifiers must be known
1587 and resolvable for the setting to be valid. The following
798d3a52
ZJS
1588 specifiers are understood:</para>
1589
1590 <table>
1591 <title>Specifiers available in unit files</title>
1592 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
1593 <colspec colname="spec" />
1594 <colspec colname="mean" />
1595 <colspec colname="detail" />
1596 <thead>
1597 <row>
5a15caf4
ZJS
1598 <entry>Specifier</entry>
1599 <entry>Meaning</entry>
1600 <entry>Details</entry>
798d3a52
ZJS
1601 </row>
1602 </thead>
1603 <tbody>
1604 <row>
709f4c47
LP
1605 <entry><literal>%b</literal></entry>
1606 <entry>Boot ID</entry>
1607 <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
1608 </row>
1609 <row>
709f4c47
LP
1610 <entry><literal>%C</literal></entry>
1611 <entry>Cache directory root</entry>
1612 <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 1613 </row>
969309c2
YW
1614 <row>
1615 <entry><literal>%E</literal></entry>
1616 <entry>Configuration directory root</entry>
1617 <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>
1618 </row>
798d3a52 1619 <row>
709f4c47
LP
1620 <entry><literal>%f</literal></entry>
1621 <entry>Unescaped filename</entry>
1622 <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
1623 </row>
1624 <row>
709f4c47
LP
1625 <entry><literal>%h</literal></entry>
1626 <entry>User home directory</entry>
b4e24077
ZJS
1627 <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>.
1628
1629Note 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
1630 </row>
1631 <row>
1632 <entry><literal>%H</literal></entry>
1633 <entry>Host name</entry>
1634 <entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry>
798d3a52
ZJS
1635 </row>
1636 <row>
5a15caf4
ZJS
1637 <entry><literal>%i</literal></entry>
1638 <entry>Instance name</entry>
e1a7f622 1639 <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
1640 </row>
1641 <row>
5a15caf4
ZJS
1642 <entry><literal>%I</literal></entry>
1643 <entry>Unescaped instance name</entry>
e1a7f622 1644 <entry>Same as <literal>%i</literal>, but with escaping undone.</entry>
798d3a52 1645 </row>
250e9fad
ZJS
1646 <row>
1647 <entry><literal>%j</literal></entry>
1648 <entry>Final component of the prefix</entry>
1649 <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>
1650 </row>
1651 <row>
1652 <entry><literal>%J</literal></entry>
1653 <entry>Unescaped final component of the prefix</entry>
1654 <entry>Same as <literal>%j</literal>, but with escaping undone.</entry>
1655 </row>
798d3a52 1656 <row>
709f4c47
LP
1657 <entry><literal>%L</literal></entry>
1658 <entry>Log directory root</entry>
1659 <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
1660 </row>
1661 <row>
709f4c47
LP
1662 <entry><literal>%m</literal></entry>
1663 <entry>Machine ID</entry>
1664 <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
1665 </row>
1666 <row>
709f4c47
LP
1667 <entry><literal>%n</literal></entry>
1668 <entry>Full unit name</entry>
1669 <entry></entry>
14068e17
LP
1670 </row>
1671 <row>
709f4c47
LP
1672 <entry><literal>%N</literal></entry>
1673 <entry>Full unit name</entry>
1674 <entry>Same as <literal>%n</literal>, but with the type suffix removed.</entry>
798d3a52
ZJS
1675 </row>
1676 <row>
709f4c47
LP
1677 <entry><literal>%p</literal></entry>
1678 <entry>Prefix name</entry>
1679 <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
1680 </row>
1681 <row>
709f4c47
LP
1682 <entry><literal>%P</literal></entry>
1683 <entry>Unescaped prefix name</entry>
1684 <entry>Same as <literal>%p</literal>, but with escaping undone.</entry>
798d3a52
ZJS
1685 </row>
1686 <row>
5a15caf4
ZJS
1687 <entry><literal>%s</literal></entry>
1688 <entry>User shell</entry>
1689 <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
1690 </row>
1691 <row>
709f4c47
LP
1692 <entry><literal>%S</literal></entry>
1693 <entry>State directory root</entry>
1694 <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
1695 </row>
1696 <row>
709f4c47
LP
1697 <entry><literal>%t</literal></entry>
1698 <entry>Runtime directory root</entry>
1699 <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 1700 </row>
b294e594
LP
1701 <row>
1702 <entry><literal>%T</literal></entry>
1703 <entry>Directory for temporary files</entry>
1704 <entry>This is either <filename>/tmp</filename> or the path <literal>$TMPDIR</literal>, <literal>$TEMP</literal> or <literal>$TMP</literal> are set to.</entry>
1705 </row>
b75f0c69
DC
1706 <row>
1707 <entry><literal>%g</literal></entry>
1708 <entry>User group</entry>
1709 <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>
1710 </row>
1711 <row>
1712 <entry><literal>%G</literal></entry>
1713 <entry>User GID</entry>
1714 <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>
1715 </row>
798d3a52 1716 <row>
709f4c47
LP
1717 <entry><literal>%u</literal></entry>
1718 <entry>User name</entry>
b4e24077
ZJS
1719 <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>.
1720
1721Note 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
1722 </row>
1723 <row>
1724 <entry><literal>%U</literal></entry>
1725 <entry>User UID</entry>
b4e24077
ZJS
1726 <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>.
1727
1728Note 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
1729 </row>
1730 <row>
5a15caf4
ZJS
1731 <entry><literal>%v</literal></entry>
1732 <entry>Kernel release</entry>
1733 <entry>Identical to <command>uname -r</command> output</entry>
798d3a52 1734 </row>
b294e594
LP
1735 <row>
1736 <entry><literal>%V</literal></entry>
1737 <entry>Directory for larger and persistent temporary files</entry>
1738 <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>
1739 </row>
798d3a52 1740 <row>
5a15caf4
ZJS
1741 <entry><literal>%%</literal></entry>
1742 <entry>Single percent sign</entry>
1743 <entry>Use <literal>%%</literal> in place of <literal>%</literal> to specify a single percent sign.</entry>
798d3a52
ZJS
1744 </row>
1745 </tbody>
1746 </tgroup>
1747 </table>
798d3a52
ZJS
1748 </refsect1>
1749
1750 <refsect1>
1751 <title>Examples</title>
1752
1753 <example>
1754 <title>Allowing units to be enabled</title>
1755
1756 <para>The following snippet (highlighted) allows a unit (e.g.
1757 <filename>foo.service</filename>) to be enabled via
1758 <command>systemctl enable</command>:</para>
1759
1760 <programlisting>[Unit]
92b1e225
CS
1761Description=Foo
1762
1763[Service]
1764ExecStart=/usr/sbin/foo-daemon
1765
1766<emphasis>[Install]</emphasis>
1767<emphasis>WantedBy=multi-user.target</emphasis></programlisting>
1768
798d3a52
ZJS
1769 <para>After running <command>systemctl enable</command>, a
1770 symlink
12b42c76 1771 <filename>/etc/systemd/system/multi-user.target.wants/foo.service</filename>
798d3a52
ZJS
1772 linking to the actual unit will be created. It tells systemd to
1773 pull in the unit when starting
1774 <filename>multi-user.target</filename>. The inverse
1775 <command>systemctl disable</command> will remove that symlink
1776 again.</para>
1777 </example>
1778
1779 <example>
1780 <title>Overriding vendor settings</title>
1781
1782 <para>There are two methods of overriding vendor settings in
1783 unit files: copying the unit file from
12b42c76
TG
1784 <filename>/usr/lib/systemd/system</filename> to
1785 <filename>/etc/systemd/system</filename> and modifying the
798d3a52
ZJS
1786 chosen settings. Alternatively, one can create a directory named
1787 <filename><replaceable>unit</replaceable>.d/</filename> within
12b42c76 1788 <filename>/etc/systemd/system</filename> and place a drop-in
798d3a52
ZJS
1789 file <filename><replaceable>name</replaceable>.conf</filename>
1790 there that only changes the specific settings one is interested
1791 in. Note that multiple such drop-in files are read if
8331eaab 1792 present, processed in lexicographic order of their filename.</para>
798d3a52
ZJS
1793
1794 <para>The advantage of the first method is that one easily
1795 overrides the complete unit, the vendor unit is not parsed at
1796 all anymore. It has the disadvantage that improvements to the
1797 unit file by the vendor are not automatically incorporated on
1798 updates.</para>
1799
1800 <para>The advantage of the second method is that one only
1801 overrides the settings one specifically wants, where updates to
1802 the unit by the vendor automatically apply. This has the
1803 disadvantage that some future updates by the vendor might be
1804 incompatible with the local changes.</para>
1805
798d3a52
ZJS
1806 <para>This also applies for user instances of systemd, but with
1807 different locations for the unit files. See the section on unit
1808 load paths for further details.</para>
1809
1810 <para>Suppose there is a vendor-supplied unit
12b42c76 1811 <filename>/usr/lib/systemd/system/httpd.service</filename> with
798d3a52
ZJS
1812 the following contents:</para>
1813
1814 <programlisting>[Unit]
92b1e225
CS
1815Description=Some HTTP server
1816After=remote-fs.target sqldb.service
1817Requires=sqldb.service
1818AssertPathExists=/srv/webserver
1819
1820[Service]
1821Type=notify
1822ExecStart=/usr/sbin/some-fancy-httpd-server
1823Nice=5
1824
1825[Install]
1826WantedBy=multi-user.target</programlisting>
1827
798d3a52
ZJS
1828 <para>Now one wants to change some settings as an administrator:
1829 firstly, in the local setup, <filename>/srv/webserver</filename>
e2acdb6b 1830 might not exist, because the HTTP server is configured to use
798d3a52
ZJS
1831 <filename>/srv/www</filename> instead. Secondly, the local
1832 configuration makes the HTTP server also depend on a memory
1833 cache service, <filename>memcached.service</filename>, that
1834 should be pulled in (<varname>Requires=</varname>) and also be
1835 ordered appropriately (<varname>After=</varname>). Thirdly, in
1836 order to harden the service a bit more, the administrator would
1837 like to set the <varname>PrivateTmp=</varname> setting (see
912f003f 1838 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
798d3a52
ZJS
1839 for details). And lastly, the administrator would like to reset
1840 the niceness of the service to its default value of 0.</para>
1841
1842 <para>The first possibility is to copy the unit file to
12b42c76 1843 <filename>/etc/systemd/system/httpd.service</filename> and
798d3a52
ZJS
1844 change the chosen settings:</para>
1845
1846 <programlisting>[Unit]
92b1e225
CS
1847Description=Some HTTP server
1848After=remote-fs.target sqldb.service <emphasis>memcached.service</emphasis>
1849Requires=sqldb.service <emphasis>memcached.service</emphasis>
1850AssertPathExists=<emphasis>/srv/www</emphasis>
1851
1852[Service]
1853Type=notify
1854ExecStart=/usr/sbin/some-fancy-httpd-server
1855<emphasis>Nice=0</emphasis>
1856<emphasis>PrivateTmp=yes</emphasis>
1857
1858[Install]
1859WantedBy=multi-user.target</programlisting>
1860
798d3a52
ZJS
1861 <para>Alternatively, the administrator could create a drop-in
1862 file
12b42c76 1863 <filename>/etc/systemd/system/httpd.service.d/local.conf</filename>
798d3a52 1864 with the following contents:</para>
92b1e225 1865
798d3a52 1866 <programlisting>[Unit]
92b1e225
CS
1867After=memcached.service
1868Requires=memcached.service
1869# Reset all assertions and then re-add the condition we want
1870AssertPathExists=
1871AssertPathExists=/srv/www
1872
1873[Service]
1874Nice=0
1875PrivateTmp=yes</programlisting>
1876
afbc75e6
DB
1877 <para>Note that for drop-in files, if one wants to remove
1878 entries from a setting that is parsed as a list (and is not a
1879 dependency), such as <varname>AssertPathExists=</varname> (or
1880 e.g. <varname>ExecStart=</varname> in service units), one needs
1881 to first clear the list before re-adding all entries except the
1882 one that is to be removed. Dependencies (<varname>After=</varname>, etc.)
798d3a52
ZJS
1883 cannot be reset to an empty list, so dependencies can only be
1884 added in drop-ins. If you want to remove dependencies, you have
1885 to override the entire unit.</para>
0cf4c0d1 1886
798d3a52
ZJS
1887 </example>
1888 </refsect1>
1889
1890 <refsect1>
1891 <title>See Also</title>
1892 <para>
1893 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1894 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
d1698b82 1895 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
798d3a52
ZJS
1896 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1897 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1898 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1899 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1900 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1901 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1902 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1903 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1904 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1905 <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
798d3a52
ZJS
1906 <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1907 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1908 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1909 <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1910 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1911 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
3ba3a79d 1912 <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>1</manvolnum></citerefentry>
798d3a52
ZJS
1913 </para>
1914 </refsect1>
d1ab0ca0
LP
1915
1916</refentry>