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