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