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