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