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