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