2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % entities SYSTEM
"custom-entities.ent" >
7 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
9 <refentry id=
"systemd.unit"
10 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
13 <title>systemd.unit
</title>
14 <productname>systemd
</productname>
18 <refentrytitle>systemd.unit
</refentrytitle>
19 <manvolnum>5</manvolnum>
23 <refname>systemd.unit
</refname>
24 <refpurpose>Unit configuration
</refpurpose>
28 <para><filename><replaceable>service
</replaceable>.service
</filename>,
29 <filename><replaceable>socket
</replaceable>.socket
</filename>,
30 <filename><replaceable>device
</replaceable>.device
</filename>,
31 <filename><replaceable>mount
</replaceable>.mount
</filename>,
32 <filename><replaceable>automount
</replaceable>.automount
</filename>,
33 <filename><replaceable>swap
</replaceable>.swap
</filename>,
34 <filename><replaceable>target
</replaceable>.target
</filename>,
35 <filename><replaceable>path
</replaceable>.path
</filename>,
36 <filename><replaceable>timer
</replaceable>.timer
</filename>,
37 <filename><replaceable>slice
</replaceable>.slice
</filename>,
38 <filename><replaceable>scope
</replaceable>.scope
</filename></para>
41 <title>System Unit Search Path
</title>
43 <para><literallayout><filename>/etc/systemd/system.control/*
</filename>
44 <filename>/run/systemd/system.control/*
</filename>
45 <filename>/run/systemd/transient/*
</filename>
46 <filename>/run/systemd/generator.early/*
</filename>
47 <filename>/etc/systemd/system/*
</filename>
48 <filename>/etc/systemd/system.attached/*
</filename>
49 <filename>/run/systemd/system/*
</filename>
50 <filename>/run/systemd/system.attached/*
</filename>
51 <filename>/run/systemd/generator/*
</filename>
52 <filename index='false'
>…
</filename>
53 <filename>/usr/lib/systemd/system/*
</filename>
54 <filename>/run/systemd/generator.late/*
</filename></literallayout></para>
58 <title>User Unit Search Path
</title>
59 <para><literallayout><filename>~/.config/systemd/user.control/*
</filename>
60 <filename>$XDG_RUNTIME_DIR/systemd/user.control/*
</filename>
61 <filename>$XDG_RUNTIME_DIR/systemd/transient/*
</filename>
62 <filename>$XDG_RUNTIME_DIR/systemd/generator.early/*
</filename>
63 <filename>~/.config/systemd/user/*
</filename>
64 <filename>$XDG_CONFIG_DIRS/systemd/user/*
</filename>
65 <filename>/etc/systemd/user/*
</filename>
66 <filename>$XDG_RUNTIME_DIR/systemd/user/*
</filename>
67 <filename>/run/systemd/user/*
</filename>
68 <filename>$XDG_RUNTIME_DIR/systemd/generator/*
</filename>
69 <filename>$XDG_DATA_HOME/systemd/user/*
</filename>
70 <filename>$XDG_DATA_DIRS/systemd/user/*
</filename>
71 <filename index='false'
>…
</filename>
72 <filename>/usr/lib/systemd/user/*
</filename>
73 <filename>$XDG_RUNTIME_DIR/systemd/generator.late/*
</filename></literallayout></para>
79 <title>Description
</title>
81 <para>A unit file is a plain text ini-style file that encodes information about a service, a
82 socket, a device, a mount point, an automount point, a swap file or partition, a start-up
83 target, a watched file system path, a timer controlled and supervised by
84 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>, a
85 resource management slice or a group of externally created processes. See
86 <citerefentry><refentrytitle>systemd.syntax
</refentrytitle><manvolnum>7</manvolnum></citerefentry>
87 for a general description of the syntax.
</para>
89 <para>This man page lists the common configuration options of all
90 the unit types. These options need to be configured in the [Unit]
91 or [Install] sections of the unit files.
</para>
93 <para>In addition to the generic [Unit] and [Install] sections
94 described here, each unit may have a type-specific section, e.g.
95 [Service] for a service unit. See the respective man pages for
97 <citerefentry><refentrytitle>systemd.service
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
98 <citerefentry><refentrytitle>systemd.socket
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
99 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
100 <citerefentry><refentrytitle>systemd.mount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
101 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
102 <citerefentry><refentrytitle>systemd.swap
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
103 <citerefentry><refentrytitle>systemd.target
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
104 <citerefentry><refentrytitle>systemd.path
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
105 <citerefentry><refentrytitle>systemd.timer
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
106 <citerefentry><refentrytitle>systemd.slice
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
107 <citerefentry><refentrytitle>systemd.scope
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
110 <para>Unit files are loaded from a set of paths determined during compilation, described in the next
113 <para>Valid unit names consist of a
"unit name prefix", and a suffix specifying the unit type which
114 begins with a dot. The
"unit name prefix" must consist of one or more valid characters (ASCII letters,
115 digits,
<literal>:
</literal>,
<literal>-
</literal>,
<literal>_
</literal>,
<literal>.
</literal>, and
116 <literal>\
</literal>). The total length of the unit name including the suffix must not exceed
255
117 characters. The unit type suffix must be one of
<literal>.service
</literal>,
<literal>.socket
</literal>,
118 <literal>.device
</literal>,
<literal>.mount
</literal>,
<literal>.automount
</literal>,
119 <literal>.swap
</literal>,
<literal>.target
</literal>,
<literal>.path
</literal>,
120 <literal>.timer
</literal>,
<literal>.slice
</literal>, or
<literal>.scope
</literal>.
</para>
122 <para>Unit names can be parameterized by a single argument called the
"instance name". The unit is then
123 constructed based on a
"template file" which serves as the definition of multiple services or other
124 units. A template unit must have a single
<literal>@
</literal> at the end of the unit name prefix (right
125 before the type suffix). The name of the full unit is formed by inserting the instance name between
126 <literal>@
</literal> and the unit type suffix. In the unit file itself, the instance parameter may be
127 referred to using
<literal>%i
</literal> and other specifiers, see below.
</para>
129 <para>Unit files may contain additional options on top of those listed here. If systemd encounters an
130 unknown option, it will write a warning log message but continue loading the unit. If an option or
131 section name is prefixed with
<option>X-
</option>, it is ignored completely by systemd. Options within an
132 ignored section do not need the prefix. Applications may use this to include additional information in
133 the unit files. To access those options, applications need to parse the unit files on their own.
</para>
135 <para>Units can be aliased (have an alternative name), by creating a symlink from the new name to the
136 existing name in one of the unit search paths. For example,
<filename>systemd-networkd.service
</filename>
137 has the alias
<filename>dbus-org.freedesktop.network1.service
</filename>, created during installation as
138 a symlink, so when
<command>systemd
</command> is asked through D-Bus to load
139 <filename>dbus-org.freedesktop.network1.service
</filename>, it'll load
140 <filename>systemd-networkd.service
</filename>. As another example,
<filename>default.target
</filename> —
141 the default system target started at boot — is commonly aliased to either
142 <filename>multi-user.target
</filename> or
<filename>graphical.target
</filename> to select what is started
143 by default. Alias names may be used in commands like
<command>disable
</command>,
144 <command>start
</command>,
<command>stop
</command>,
<command>status
</command>, and similar, and in all
145 unit dependency directives, including
<varname>Wants=
</varname>,
<varname>Requires=
</varname>,
146 <varname>Before=
</varname>,
<varname>After=
</varname>. Aliases cannot be used with the
147 <command>preset
</command> command.
</para>
149 <para>Aliases obey the following restrictions: a unit of a certain type (
<literal>.service
</literal>,
150 <literal>.socket
</literal>, …) can only be aliased by a name with the same type suffix. A plain unit (not
151 a template or an instance), may only be aliased by a plain name. A template instance may only be aliased
152 by another template instance, and the instance part must be identical. A template may be aliased by
153 another template (in which case the alias applies to all instances of the template). As a special case, a
154 template instance (e.g.
<literal>alias@inst.service
</literal>) may be a symlink to different template
155 (e.g.
<literal>template@inst.service
</literal>). In that case, just this specific instance is aliased,
156 while other instances of the template (e.g.
<literal>alias@foo.service
</literal>,
157 <literal>alias@bar.service
</literal>) are not aliased. Those rules preserve the requirement that the
158 instance (if any) is always uniquely defined for a given unit and all its aliases. The target of alias
159 symlink must point to a valid unit file location, i.e. the symlink target name must match the symlink
160 source name as described, and the destination path must be in one of the unit search paths, see UNIT FILE
161 LOAD PATH section below for more details. Note that the target file may not exist, i.e. the symlink may
164 <para>Unit files may specify aliases through the
<varname>Alias=
</varname> directive in the [Install]
165 section. When the unit is enabled, symlinks will be created for those names, and removed when the unit is
166 disabled. For example,
<filename>reboot.target
</filename> specifies
167 <varname>Alias=ctrl-alt-del.target
</varname>, so when enabled, the symlink
168 <filename>/etc/systemd/system/ctrl-alt-del.service
</filename> pointing to the
169 <filename>reboot.target
</filename> file will be created, and when
170 <keycombo><keycap>Ctrl
</keycap><keycap>Alt
</keycap><keycap>Del
</keycap></keycombo> is invoked,
171 <command>systemd
</command> will look for the
<filename>ctrl-alt-del.service
</filename> and execute
172 <filename>reboot.service
</filename>.
<command>systemd
</command> does not look at the [Install] section at
173 all during normal operation, so any directives in that section only have an effect through the symlinks
174 created during enablement.
</para>
176 <para>Along with a unit file
<filename>foo.service
</filename>, the directory
177 <filename>foo.service.wants/
</filename> may exist. All unit files symlinked from such a directory are
178 implicitly added as dependencies of type
<varname>Wants=
</varname> to the unit. Similar functionality
179 exists for
<varname>Requires=
</varname> type dependencies as well, the directory suffix is
180 <filename>.requires/
</filename> in this case. This functionality is useful to hook units into the
181 start-up of other units, without having to modify their unit files. For details about the semantics of
182 <varname>Wants=
</varname> and
<varname>Requires=
</varname>, see below. The preferred way to create
183 symlinks in the
<filename>.wants/
</filename> or
<filename>.requires/
</filename> directories is by
184 specifying the dependency in [Install] section of the target unit, and creating the symlink in the file
185 system with the
<command>enable
</command> or
<command>preset
</command> commands of
186 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The
187 target can be a normal unit (either plain or a specific instance of a template unit). In case when the
188 source unit is a template, the target can also be a template, in which case the instance will be
189 "propagated" to the target unit to form a valid unit instance. The target of symlinks in
190 <filename>.wants/
</filename> or
<filename>.requires/
</filename> must thus point to a valid unit file
191 location, i.e. the symlink target name must satisfy the described requirements, and the destination path
192 must be in one of the unit search paths, see UNIT FILE LOAD PATH section below for more details. Note
193 that the target file may not exist, i.e. the symlink may be dangling.
</para>
195 <para>Along with a unit file
<filename>foo.service
</filename>, a
"drop-in" directory
196 <filename>foo.service.d/
</filename> may exist. All files with the suffix
197 <literal>.conf
</literal> from this directory will be merged in the alphanumeric order and parsed
198 after the main unit file itself has been parsed. This is useful to alter or add configuration
199 settings for a unit, without having to modify unit files. Each drop-in file must contain appropriate
200 section headers. For instantiated units, this logic will first look for the instance
201 <literal>.d/
</literal> subdirectory (e.g.
<literal>foo@bar.service.d/
</literal>) and read its
202 <literal>.conf
</literal> files, followed by the template
<literal>.d/
</literal> subdirectory (e.g.
203 <literal>foo@.service.d/
</literal>) and the
<literal>.conf
</literal> files there. Moreover for unit
204 names containing dashes (
<literal>-
</literal>), the set of directories generated by repeatedly
205 truncating the unit name after all dashes is searched too. Specifically, for a unit name
206 <filename>foo-bar-baz.service
</filename> not only the regular drop-in directory
207 <filename>foo-bar-baz.service.d/
</filename> is searched but also both
<filename>foo-bar-.service.d/
</filename> and
208 <filename>foo-.service.d/
</filename>. This is useful for defining common drop-ins for a set of related units, whose
209 names begin with a common prefix. This scheme is particularly useful for mount, automount and slice units, whose
210 systematic naming structure is built around dashes as component separators. Note that equally named drop-in files
211 further down the prefix hierarchy override those further up,
212 i.e.
<filename>foo-bar-.service.d/
10-override.conf
</filename> overrides
213 <filename>foo-.service.d/
10-override.conf
</filename>.
</para>
215 <para>In cases of unit aliases (described above), dropins for the aliased name and all aliases are
216 loaded. In the example of
<filename>default.target
</filename> aliasing
217 <filename>graphical.target
</filename>,
<filename>default.target.d/
</filename>,
218 <filename>default.target.wants/
</filename>,
<filename>default.target.requires/
</filename>,
219 <filename>graphical.target.d/
</filename>,
<filename>graphical.target.wants/
</filename>,
220 <filename>graphical.target.requires/
</filename> would all be read. For templates, dropins for the
221 template, any template aliases, the template instance, and all alias instances are read. When just a
222 specific template instance is aliased, then the dropins for the target template, the target template
223 instance, and the alias template instance are read.
</para>
225 <para>In addition to
<filename>/etc/systemd/system
</filename>, the drop-in
<literal>.d/
</literal>
226 directories for system services can be placed in
<filename>/usr/lib/systemd/system
</filename> or
227 <filename>/run/systemd/system
</filename> directories. Drop-in files in
<filename>/etc/
</filename>
228 take precedence over those in
<filename>/run/
</filename> which in turn take precedence over those
229 in
<filename>/usr/lib/
</filename>. Drop-in files under any of these directories take precedence
230 over unit files wherever located. Multiple drop-in files with different names are applied in
231 lexicographic order, regardless of which of the directories they reside in.
</para>
233 <para>Units also support a top-level drop-in with
<filename><replaceable>type
</replaceable>.d/
</filename>,
234 where
<replaceable>type
</replaceable> may be e.g.
<literal>service
</literal> or
<literal>socket
</literal>,
235 that allows altering or adding to the settings of all corresponding unit files on the system.
236 The formatting and precedence of applying drop-in configurations follow what is defined above.
237 Files in
<filename><replaceable>type
</replaceable>.d/
</filename> have lower precedence compared
238 to files in name-specific override directories. The usual rules apply: multiple drop-in files
239 with different names are applied in lexicographic order, regardless of which of the directories
240 they reside in, so a file in
<filename><replaceable>type
</replaceable>.d/
</filename> applies
241 to a unit only if there are no drop-ins or masks with that name in directories with higher
242 precedence. See Examples.
</para>
244 <para>Note that while systemd offers a flexible dependency system
245 between units it is recommended to use this functionality only
246 sparingly and instead rely on techniques such as bus-based or
247 socket-based activation which make dependencies implicit,
248 resulting in a both simpler and more flexible system.
</para>
250 <para>As mentioned above, a unit may be instantiated from a template file. This allows creation
251 of multiple units from a single configuration file. If systemd looks for a unit configuration
252 file, it will first search for the literal unit name in the file system. If that yields no
253 success and the unit name contains an
<literal>@
</literal> character, systemd will look for a
254 unit template that shares the same name but with the instance string (i.e. the part between the
255 <literal>@
</literal> character and the suffix) removed. Example: if a service
256 <filename>getty@tty3.service
</filename> is requested and no file by that name is found, systemd
257 will look for
<filename>getty@.service
</filename> and instantiate a service from that
258 configuration file if it is found.
</para>
260 <para>To refer to the instance string from within the
261 configuration file you may use the special
<literal>%i
</literal>
262 specifier in many of the configuration options. See below for
265 <para>If a unit file is empty (i.e. has the file size
0) or is
266 symlinked to
<filename>/dev/null
</filename>, its configuration
267 will not be loaded and it appears with a load state of
268 <literal>masked
</literal>, and cannot be activated. Use this as an
269 effective way to fully disable a unit, making it impossible to
270 start it even manually.
</para>
272 <para>The unit file format is covered by the
273 <ulink url=
"https://systemd.io/PORTABILITY_AND_STABILITY/">Interface
274 Portability and Stability Promise
</ulink>.
</para>
279 <title>String Escaping for Inclusion in Unit Names
</title>
281 <para>Sometimes it is useful to convert arbitrary strings into unit names. To facilitate this, a method of string
282 escaping is used, in order to map strings containing arbitrary byte values (except
<constant>NUL
</constant>) into
283 valid unit names and their restricted character set. A common special case are unit names that reflect paths to
284 objects in the file system hierarchy. Example: a device unit
<filename>dev-sda.device
</filename> refers to a device
285 with the device node
<filename index=
"false">/dev/sda
</filename> in the file system.
</para>
287 <para>The escaping algorithm operates as follows: given a string, any
<literal>/
</literal> character is
288 replaced by
<literal>-
</literal>, and all other characters which are not ASCII alphanumerics,
289 <literal>:
</literal>,
<literal>_
</literal> or
<literal>.
</literal> are replaced by C-style
290 <literal>\x2d
</literal> escapes. In addition,
<literal>.
</literal> is replaced with such a C-style escape
291 when it would appear as the first character in the escaped string.
</para>
293 <para>When the input qualifies as absolute file system path, this algorithm is extended slightly: the path to the
294 root directory
<literal>/
</literal> is encoded as single dash
<literal>-
</literal>. In addition, any leading,
295 trailing or duplicate
<literal>/
</literal> characters are removed from the string before transformation. Example:
296 <filename index=
"false">/foo//bar/baz/
</filename> becomes
<literal>foo-bar-baz
</literal>.
</para>
298 <para>This escaping is fully reversible, as long as it is known whether the escaped string was a path (the
299 unescaping results are different for paths and non-path strings). The
300 <citerefentry><refentrytitle>systemd-escape
</refentrytitle><manvolnum>1</manvolnum></citerefentry> command may be
301 used to apply and reverse escaping on arbitrary strings. Use
<command>systemd-escape --path
</command> to escape
302 path strings, and
<command>systemd-escape
</command> without
<option>--path
</option> otherwise.
</para>
306 <title>Automatic dependencies
</title>
309 <title>Implicit Dependencies
</title>
311 <para>A number of unit dependencies are implicitly established, depending on unit type and
312 unit configuration. These implicit dependencies can make unit configuration file cleaner. For
313 the implicit dependencies in each unit type, please refer to section
"Implicit Dependencies"
314 in respective man pages.
</para>
316 <para>For example, service units with
<varname>Type=dbus
</varname> automatically acquire
317 dependencies of type
<varname>Requires=
</varname> and
<varname>After=
</varname> on
318 <filename>dbus.socket
</filename>. See
319 <citerefentry><refentrytitle>systemd.service
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
324 <title>Default Dependencies
</title>
326 <para>Default dependencies are similar to implicit dependencies, but can be turned on and off
327 by setting
<varname>DefaultDependencies=
</varname> to
<varname>yes
</varname> (the default) and
328 <varname>no
</varname>, while implicit dependencies are always in effect. See section
"Default
329 Dependencies" in respective man pages for the effect of enabling
330 <varname>DefaultDependencies=
</varname> in each unit types.
</para>
332 <para>For example, target units will complement all configured dependencies of type
333 <varname>Wants=
</varname> or
<varname>Requires=
</varname> with dependencies of type
334 <varname>After=
</varname>. See
335 <citerefentry><refentrytitle>systemd.target
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
336 for details. Note that this behavior can be opted out by setting
337 <varname>DefaultDependencies=no
</varname> in the specified units, or it can be selectively
338 overridden via an explicit
<varname>Before=
</varname> dependency.
</para>
343 <title>Unit File Load Path
</title>
345 <para>Unit files are loaded from a set of paths determined during
346 compilation, described in the two tables below. Unit files found
347 in directories listed earlier override files with the same name in
348 directories lower in the list.
</para>
350 <para>When the variable
<varname>$SYSTEMD_UNIT_PATH
</varname> is set,
351 the contents of this variable overrides the unit load path. If
352 <varname>$SYSTEMD_UNIT_PATH
</varname> ends with an empty component
353 (
<literal>:
</literal>), the usual unit load path will be appended
354 to the contents of the variable.
</para>
358 Load path when running in system mode (
<option>--system
</option>).
362 <colspec colname='path'
/>
363 <colspec colname='expl'
/>
367 <entry>Description
</entry>
372 <entry><filename>/etc/systemd/system.control
</filename></entry>
373 <entry morerows=
"1">Persistent and transient configuration created using the dbus API
</entry>
376 <entry><filename>/run/systemd/system.control
</filename></entry>
379 <entry><filename>/run/systemd/transient
</filename></entry>
380 <entry>Dynamic configuration for transient units
</entry>
383 <entry><filename>/run/systemd/generator.early
</filename></entry>
384 <entry>Generated units with high priority (see
<replaceable>early-dir
</replaceable> in
<citerefentry
385 ><refentrytitle>systemd.generator
</refentrytitle><manvolnum>7</manvolnum></citerefentry>)
</entry>
388 <entry><filename>/etc/systemd/system
</filename></entry>
389 <entry>System units created by the administrator
</entry>
392 <entry><filename>/run/systemd/system
</filename></entry>
393 <entry>Runtime units
</entry>
396 <entry><filename>/run/systemd/generator
</filename></entry>
397 <entry>Generated units with medium priority (see
<replaceable>normal-dir
</replaceable> in
<citerefentry
398 ><refentrytitle>systemd.generator
</refentrytitle><manvolnum>7</manvolnum></citerefentry>)
</entry>
401 <entry><filename>/usr/local/lib/systemd/system
</filename></entry>
402 <entry>System units installed by the administrator
</entry>
405 <entry><filename>/usr/lib/systemd/system
</filename></entry>
406 <entry>System units installed by the distribution package manager
</entry>
409 <entry><filename>/run/systemd/generator.late
</filename></entry>
410 <entry>Generated units with low priority (see
<replaceable>late-dir
</replaceable> in
<citerefentry
411 ><refentrytitle>systemd.generator
</refentrytitle><manvolnum>7</manvolnum></citerefentry>)
</entry>
419 Load path when running in user mode (
<option>--user
</option>).
423 <colspec colname='path'
/>
424 <colspec colname='expl'
/>
428 <entry>Description
</entry>
433 <entry><filename>$XDG_CONFIG_HOME/systemd/user.control
</filename> or
<filename
434 >~/.config/systemd/user.control
</filename></entry>
435 <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>
438 <entry><filename>$XDG_RUNTIME_DIR/systemd/user.control
</filename></entry>
441 <entry><filename>$XDG_RUNTIME_DIR/systemd/transient
</filename></entry>
442 <entry>Dynamic configuration for transient units
</entry>
445 <entry><filename>$XDG_RUNTIME_DIR/systemd/generator.early
</filename></entry>
446 <entry>Generated units with high priority (see
<replaceable>early-dir
</replaceable> in
<citerefentry
447 ><refentrytitle>systemd.generator
</refentrytitle><manvolnum>7</manvolnum></citerefentry>)
</entry>
450 <entry><filename>$XDG_CONFIG_HOME/systemd/user
</filename> or
<filename>$HOME/.config/systemd/user
</filename></entry>
451 <entry>User configuration (
<varname>$XDG_CONFIG_HOME
</varname> is used if set,
<filename>~/.config
</filename> otherwise)
</entry>
454 <entry><filename>$XDG_CONFIG_DIRS/systemd/user
</filename> or
<filename>/etc/xdg/systemd/user
</filename></entry>
455 <entry>Additional configuration directories as specified by the XDG base directory specification (
<varname>$XDG_CONFIG_DIRS
</varname> is used if set,
<filename>/etc/xdg
</filename> otherwise)
</entry>
458 <entry><filename>/etc/systemd/user
</filename></entry>
459 <entry>User units created by the administrator
</entry>
462 <entry><filename>$XDG_RUNTIME_DIR/systemd/user
</filename></entry>
463 <entry>Runtime units (only used when $XDG_RUNTIME_DIR is set)
</entry>
466 <entry><filename>/run/systemd/user
</filename></entry>
467 <entry>Runtime units
</entry>
470 <entry><filename>$XDG_RUNTIME_DIR/systemd/generator
</filename></entry>
471 <entry>Generated units with medium priority (see
<replaceable>normal-dir
</replaceable> in
<citerefentry
472 ><refentrytitle>systemd.generator
</refentrytitle><manvolnum>7</manvolnum></citerefentry>)
</entry>
475 <entry><filename>$XDG_DATA_HOME/systemd/user
</filename> or
<filename>$HOME/.local/share/systemd/user
</filename></entry>
476 <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>
479 <entry><filename>$XDG_DATA_DIRS/systemd/user
</filename> or
<filename>/usr/local/share/systemd/user
</filename> and
<filename>/usr/share/systemd/user
</filename></entry>
480 <entry>Additional data directories as specified by the XDG base directory specification (
<varname>$XDG_DATA_DIRS
</varname> is used if set,
<filename>/usr/local/share
</filename> and
<filename>/usr/share
</filename> otherwise)
</entry>
483 <entry><filename>$dir/systemd/user
</filename> for each
<varname index=
"false">$dir
</varname> in
<varname>$XDG_DATA_DIRS
</varname></entry>
484 <entry>Additional locations for installed user units, one for each entry in
<varname>$XDG_DATA_DIRS
</varname></entry>
487 <entry><filename>/usr/local/lib/systemd/user
</filename></entry>
488 <entry>User units installed by the administrator
</entry>
491 <entry><filename>/usr/lib/systemd/user
</filename></entry>
492 <entry>User units installed by the distribution package manager
</entry>
495 <entry><filename>$XDG_RUNTIME_DIR/systemd/generator.late
</filename></entry>
496 <entry>Generated units with low priority (see
<replaceable>late-dir
</replaceable> in
<citerefentry
497 ><refentrytitle>systemd.generator
</refentrytitle><manvolnum>7</manvolnum></citerefentry>)
</entry>
503 <para>The set of load paths for the user manager instance may be augmented or
504 changed using various environment variables. And environment variables may in
505 turn be set using environment generators, see
506 <citerefentry><refentrytitle>systemd.environment-generator
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
507 In particular,
<varname>$XDG_DATA_HOME
</varname> and
508 <varname>$XDG_DATA_DIRS
</varname> may be easily set using
509 <citerefentry><refentrytitle>systemd-environment-d-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
510 Thus, directories listed here are just the defaults. To see the actual list that
511 would be used based on compilation options and current environment use
512 <programlisting>systemd-analyze --user unit-paths
</programlisting>
515 <para>Moreover, additional units might be loaded into systemd from directories not on the unit load path
516 by creating a symlink pointing to a unit file in the directories. You can use
<command>systemctl
517 link
</command> for this; see
518 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The file
519 system where the linked unit files are located must be accessible when systemd is started (e.g. anything
520 underneath
<filename>/home/
</filename> or
<filename>/var/
</filename> is not allowed, unless those
521 directories are located on the root file system).
</para>
523 <para>It is important to distinguish
"linked unit files" from
"unit file aliases": any symlink where the
524 symlink
<emphasis>target
</emphasis> is within the unit load path becomes an alias: the source name and
525 the target file name must satisfy specific constraints listed above in the discussion of aliases, but the
526 symlink target doesn't have to exist, and in fact the symlink target path is not used, except to check
527 whether the target is within the unit load path. In contrast, a symlink which goes outside of the unit
528 load path signifies a linked unit file. The symlink is followed when loading the file, but the
529 destination name is otherwise unused (and may even not be a valid unit file name). For example, symlinks
530 <filename index='false'
>/etc/systemd/system/alias1.service
</filename> →
<filename index='false'
>service1.service
</filename>,
531 <filename index='false'
>/etc/systemd/system/alias2.service
</filename> →
<filename index='false'
>/usr/lib/systemd/service1.service
</filename>,
532 <filename index='false'
>/etc/systemd/system/alias3.service
</filename> →
<filename index='false'
>/etc/systemd/system/service1.service
</filename>
533 are all valid aliases and
<filename index='false'
>service1.service
</filename> will have
534 four names, even if the unit file is located at
535 <filename index='false'
>/run/systemd/system/service1.service
</filename>. In contrast,
536 a symlink
<filename index='false'
>/etc/systemd/system/link1.service
</filename> →
<filename index='false'
>../link1_service_file
</filename>
537 means that
<filename index='false'
>link1.service
</filename> is a
"linked unit" and the contents of
538 <filename index='false'
>/etc/systemd/link1_service_file
</filename> provide its configuration.
</para>
542 <title>Unit Garbage Collection
</title>
544 <para>The system and service manager loads a unit's configuration automatically when a unit is referenced for the
545 first time. It will automatically unload the unit configuration and state again when the unit is not needed anymore
546 (
"garbage collection"). A unit may be referenced through a number of different mechanisms:
</para>
549 <listitem><para>Another loaded unit references it with a dependency such as
<varname>After=
</varname>,
550 <varname>Wants=
</varname>, …
</para></listitem>
552 <listitem><para>The unit is currently starting, running, reloading or stopping.
</para></listitem>
554 <listitem><para>The unit is currently in the
<constant>failed
</constant> state. (But see below.)
</para></listitem>
556 <listitem><para>A job for the unit is pending.
</para></listitem>
558 <listitem><para>The unit is pinned by an active IPC client program.
</para></listitem>
560 <listitem><para>The unit is a special
"perpetual" unit that is always active and loaded. Examples for perpetual
561 units are the root mount unit
<filename>-.mount
</filename> or the scope unit
<filename>init.scope
</filename> that
562 the service manager itself lives in.
</para></listitem>
564 <listitem><para>The unit has running processes associated with it.
</para></listitem>
567 <para>The garbage collection logic may be altered with the
<varname>CollectMode=
</varname> option, which allows
568 configuration whether automatic unloading of units that are in
<constant>failed
</constant> state is permissible,
571 <para>Note that when a unit's configuration and state is unloaded, all execution results, such as exit codes, exit
572 signals, resource consumption and other statistics are lost, except for what is stored in the log subsystem.
</para>
574 <para>Use
<command>systemctl daemon-reload
</command> or an equivalent command to reload unit configuration while
575 the unit is already loaded. In this case all configuration settings are flushed out and replaced with the new
576 configuration (which however might not be in effect immediately), however all runtime state is
577 saved/restored.
</para>
581 <title>[Unit] Section Options
</title>
583 <para>The unit file may include a [Unit] section, which carries
584 generic information about the unit that is not dependent on the
587 <variablelist class='unit-directives'
>
589 <term><varname>Description=
</varname></term>
590 <listitem><para>A short human readable title of the unit. This may be used by
591 <command>systemd
</command> (and other UIs) as a user-visible label for the unit, so this string
592 should identify the unit rather than describe it, despite the name. This string also shouldn't just
593 repeat the unit name.
<literal>Apache2 Web Server
</literal> is a good example. Bad examples are
594 <literal>high-performance light-weight HTTP server
</literal> (too generic) or
595 <literal>Apache2
</literal> (meaningless for people who do not know Apache, duplicates the unit
596 name).
<command>systemd
</command> may use this string as a noun in status messages (
<literal>Starting
597 <replaceable>description
</replaceable>...
</literal>,
<literal>Started
598 <replaceable>description
</replaceable>.
</literal>,
<literal>Reached target
599 <replaceable>description
</replaceable>.
</literal>,
<literal>Failed to start
600 <replaceable>description
</replaceable>.
</literal>), so it should be capitalized, and should not be a
601 full sentence, or a phrase with a continuous verb. Bad examples include
<literal>exiting the
602 container
</literal> or
<literal>updating the database once per day.
</literal>.
</para>
604 <xi:include href=
"version-info.xml" xpointer=
"v201"/>
609 <term><varname>Documentation=
</varname></term>
610 <listitem><para>A space-separated list of URIs referencing
611 documentation for this unit or its configuration. Accepted are
612 only URIs of the types
<literal>http://
</literal>,
613 <literal>https://
</literal>,
<literal>file:
</literal>,
614 <literal>info:
</literal>,
<literal>man:
</literal>. For more
615 information about the syntax of these URIs, see
<citerefentry
616 project='man-pages'
><refentrytitle>uri
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
617 The URIs should be listed in order of relevance, starting with
618 the most relevant. It is a good idea to first reference
619 documentation that explains what the unit's purpose is,
620 followed by how it is configured, followed by any other
621 related documentation. This option may be specified more than
622 once, in which case the specified list of URIs is merged. If
623 the empty string is assigned to this option, the list is reset
624 and all prior assignments will have no
627 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
631 <term><varname>Wants=
</varname></term>
633 <listitem><para>Configures (weak) requirement dependencies on other units. This option may be
634 specified more than once or multiple space-separated units may be specified in one option in which
635 case dependencies for all listed names will be created. Dependencies of this type may also be
636 configured outside of the unit configuration file by adding a symlink to a
637 <filename>.wants/
</filename> directory accompanying the unit file. For details, see above.
</para>
639 <para>Units listed in this option will be started if the configuring unit is. However, if the listed
640 units fail to start or cannot be added to the transaction, this has no impact on the validity of the
641 transaction as a whole, and this unit will still be started. This is the recommended way to hook
642 the start-up of one unit to the start-up of another unit.
</para>
644 <para>Note that requirement dependencies do not influence the order in which services are started or
645 stopped. This has to be configured independently with the
<varname>After=
</varname> or
646 <varname>Before=
</varname> options. If unit
<filename>foo.service
</filename> pulls in unit
647 <filename>bar.service
</filename> as configured with
<varname>Wants=
</varname> and no ordering is
648 configured with
<varname>After=
</varname> or
<varname>Before=
</varname>, then both units will be
649 started simultaneously and without any delay between them if
<filename>foo.service
</filename> is
652 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
656 <term><varname>Requires=
</varname></term>
658 <listitem><para>Similar to
<varname>Wants=
</varname>, but declares a stronger requirement
659 dependency. Dependencies of this type may also be configured by adding a symlink to a
660 <filename>.requires/
</filename> directory accompanying the unit file.
</para>
662 <para>If this unit gets activated, the units listed will be activated as well. If one of
663 the other units fails to activate, and an ordering dependency
<varname>After=
</varname> on the
664 failing unit is set, this unit will not be started. Besides, with or without specifying
665 <varname>After=
</varname>, this unit will be stopped (or restarted) if one of the other units is
666 explicitly stopped (or restarted).
</para>
668 <para>Often, it is a better choice to use
<varname>Wants=
</varname> instead of
669 <varname>Requires=
</varname> in order to achieve a system that is more robust when dealing with
670 failing services.
</para>
672 <para>Note that this dependency type does not imply that the other unit always has to be in active state when
673 this unit is running. Specifically: failing condition checks (such as
<varname>ConditionPathExists=
</varname>,
674 <varname>ConditionPathIsSymbolicLink=
</varname>, … — see below) do not cause the start job of a unit with a
675 <varname>Requires=
</varname> dependency on it to fail. Also, some unit types may deactivate on their own (for
676 example, a service process may decide to exit cleanly, or a device may be unplugged by the user), which is not
677 propagated to units having a
<varname>Requires=
</varname> dependency. Use the
<varname>BindsTo=
</varname>
678 dependency type together with
<varname>After=
</varname> to ensure that a unit may never be in active state
679 without a specific other unit also in active state (see below).
</para>
681 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
685 <term><varname>Requisite=
</varname></term>
687 <listitem><para>Similar to
<varname>Requires=
</varname>. However, if the units listed here
688 are not started already, they will not be started and the starting of this unit will fail
689 immediately.
<varname>Requisite=
</varname> does not imply an ordering dependency, even if
690 both units are started in the same transaction. Hence this setting should usually be
691 combined with
<varname>After=
</varname>, to ensure this unit is not started before the other
694 <para>When
<varname>Requisite=b.service
</varname> is used on
695 <filename>a.service
</filename>, this dependency will show as
696 <varname>RequisiteOf=a.service
</varname> in property listing of
697 <filename>b.service
</filename>.
<varname>RequisiteOf=
</varname>
698 dependency cannot be specified directly.
</para>
700 <xi:include href=
"version-info.xml" xpointer=
"v201"/>
705 <term><varname>BindsTo=
</varname></term>
707 <listitem><para>Configures requirement dependencies, very similar in style to
708 <varname>Requires=
</varname>. However, this dependency type is stronger: in addition to the effect of
709 <varname>Requires=
</varname> it declares that if the unit bound to is stopped, this unit will be stopped
710 too. This means a unit bound to another unit that suddenly enters inactive state will be stopped too.
711 Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit
712 might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of
713 a mount unit might be unmounted without involvement of the system and service manager.
</para>
715 <para>When used in conjunction with
<varname>After=
</varname> on the same unit the behaviour of
716 <varname>BindsTo=
</varname> is even stronger. In this case, the unit bound to strictly has to be in active
717 state for this unit to also be in active state. This not only means a unit bound to another unit that suddenly
718 enters inactive state, but also one that is bound to another unit that gets skipped due to an unmet condition
719 check (such as
<varname>ConditionPathExists=
</varname>,
<varname>ConditionPathIsSymbolicLink=
</varname>, … —
720 see below) will be stopped, should it be running. Hence, in many cases it is best to combine
721 <varname>BindsTo=
</varname> with
<varname>After=
</varname>.
</para>
723 <para>When
<varname>BindsTo=b.service
</varname> is used on
724 <filename>a.service
</filename>, this dependency will show as
725 <varname>BoundBy=a.service
</varname> in property listing of
726 <filename>b.service
</filename>.
<varname>BoundBy=
</varname>
727 dependency cannot be specified directly.
</para>
729 <xi:include href=
"version-info.xml" xpointer=
"v201"/>
734 <term><varname>PartOf=
</varname></term>
736 <listitem><para>Configures dependencies similar to
737 <varname>Requires=
</varname>, but limited to stopping and
738 restarting of units. When systemd stops or restarts the units
739 listed here, the action is propagated to this unit. Note that
740 this is a one-way dependency — changes to this unit do not
741 affect the listed units.
</para>
743 <para>When
<varname>PartOf=b.service
</varname> is used on
744 <filename>a.service
</filename>, this dependency will show as
745 <varname>ConsistsOf=a.service
</varname> in property listing of
746 <filename>b.service
</filename>.
<varname>ConsistsOf=
</varname>
747 dependency cannot be specified directly.
</para>
749 <xi:include href=
"version-info.xml" xpointer=
"v201"/>
754 <term><varname>Upholds=
</varname></term>
756 <listitem><para>Configures dependencies similar to
<varname>Wants=
</varname>, but as long as this unit
757 is up, all units listed in
<varname>Upholds=
</varname> are started whenever found to be inactive or
758 failed, and no job is queued for them. While a
<varname>Wants=
</varname> dependency on another unit
759 has a one-time effect when this units started, a
<varname>Upholds=
</varname> dependency on it has a
760 continuous effect, constantly restarting the unit if necessary. This is an alternative to the
761 <varname>Restart=
</varname> setting of service units, to ensure they are kept running whatever
762 happens. The restart happens without delay, and usual per-unit rate-limit applies.
</para>
764 <para>When
<varname>Upholds=b.service
</varname> is used on
<filename>a.service
</filename>, this
765 dependency will show as
<varname>UpheldBy=a.service
</varname> in the property listing of
766 <filename>b.service
</filename>.
</para>
768 <xi:include href=
"version-info.xml" xpointer=
"v249"/>
773 <term><varname>Conflicts=
</varname></term>
775 <listitem><para>A space-separated list of unit names. Configures negative requirement
776 dependencies. If a unit has a
<varname>Conflicts=
</varname> setting on another unit, starting the
777 former will stop the latter and vice versa.
</para>
779 <para>Note that this setting does not imply an ordering dependency, similarly to the
780 <varname>Wants=
</varname> and
<varname>Requires=
</varname> dependencies described above. This means
781 that to ensure that the conflicting unit is stopped before the other unit is started, an
782 <varname>After=
</varname> or
<varname>Before=
</varname> dependency must be declared. It doesn't
783 matter which of the two ordering dependencies is used, because stop jobs are always ordered before
784 start jobs, see the discussion in
<varname>Before=
</varname>/
<varname>After=
</varname> below.
</para>
786 <para>If unit A that conflicts with unit B is scheduled to
787 be started at the same time as B, the transaction will either
788 fail (in case both are required parts of the transaction) or be
789 modified to be fixed (in case one or both jobs are not a
790 required part of the transaction). In the latter case, the job
791 that is not required will be removed, or in case both are
792 not required, the unit that conflicts will be started and the
793 unit that is conflicted is stopped.
</para>
795 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
799 <term><varname>Before=
</varname></term>
800 <term><varname>After=
</varname></term>
802 <listitem><para>These two settings expect a space-separated list of unit names. They may be specified
803 more than once, in which case dependencies for all listed names are created.
</para>
805 <para>Those two settings configure ordering dependencies between units. If unit
806 <filename>foo.service
</filename> contains the setting
<option>Before=bar.service
</option> and both
807 units are being started,
<filename>bar.service
</filename>'s start-up is delayed until
808 <filename>foo.service
</filename> has finished starting up.
<varname>After=
</varname> is the inverse
809 of
<varname>Before=
</varname>, i.e. while
<varname>Before=
</varname> ensures that the configured unit
810 is started before the listed unit begins starting up,
<varname>After=
</varname> ensures the opposite,
811 that the listed unit is fully started up before the configured unit is started.
</para>
813 <para>When two units with an ordering dependency between them are shut down, the inverse of the
814 start-up order is applied. I.e. if a unit is configured with
<varname>After=
</varname> on another
815 unit, the former is stopped before the latter if both are shut down. Given two units with any
816 ordering dependency between them, if one unit is shut down and the other is started up, the shutdown
817 is ordered before the start-up. It doesn't matter if the ordering dependency is
818 <varname>After=
</varname> or
<varname>Before=
</varname>, in this case. It also doesn't matter which
819 of the two is shut down, as long as one is shut down and the other is started up; the shutdown is
820 ordered before the start-up in all cases. If two units have no ordering dependencies between them,
821 they are shut down or started up simultaneously, and no ordering takes place. It depends on the unit
822 type when precisely a unit has finished starting up. Most importantly, for service units start-up is
823 considered completed for the purpose of
<varname>Before=
</varname>/
<varname>After=
</varname> when all
824 its configured start-up commands have been invoked and they either failed or reported start-up
825 success. Note that this does includes
<varname>ExecStartPost=
</varname> (or
826 <varname>ExecStopPost=
</varname> for the shutdown case).
</para>
828 <para>Note that those settings are independent of and orthogonal to the requirement dependencies as
829 configured by
<varname>Requires=
</varname>,
<varname>Wants=
</varname>,
<varname>Requisite=
</varname>,
830 or
<varname>BindsTo=
</varname>. It is a common pattern to include a unit name in both the
831 <varname>After=
</varname> and
<varname>Wants=
</varname> options, in which case the unit listed will
832 be started before the unit that is configured with these options.
</para>
834 <para>Note that
<varname>Before=
</varname> dependencies on device units have no effect and are not
835 supported. Devices generally become available as a result of an external hotplug event, and systemd
836 creates the corresponding device unit without delay.
</para>
838 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
842 <term><varname>OnFailure=
</varname></term>
844 <listitem><para>A space-separated list of one or more units that are activated when this unit enters
845 the
<literal>failed
</literal> state.
</para>
847 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
851 <term><varname>OnSuccess=
</varname></term>
853 <listitem><para>A space-separated list of one or more units that are activated when this unit enters
854 the
<literal>inactive
</literal> state.
</para>
856 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
860 <term><varname>PropagatesReloadTo=
</varname></term>
861 <term><varname>ReloadPropagatedFrom=
</varname></term>
863 <listitem><para>A space-separated list of one or more units to which reload requests from this unit
864 shall be propagated to, or units from which reload requests shall be propagated to this unit,
865 respectively. Issuing a reload request on a unit will automatically also enqueue reload requests on
866 all units that are linked to it using these two settings.
</para>
868 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
872 <term><varname>PropagatesStopTo=
</varname></term>
873 <term><varname>StopPropagatedFrom=
</varname></term>
875 <listitem><para>A space-separated list of one or more units to which stop requests from this unit
876 shall be propagated to, or units from which stop requests shall be propagated to this unit,
877 respectively. Issuing a stop request on a unit will automatically also enqueue stop requests on all
878 units that are linked to it using these two settings.
</para>
880 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
884 <term><varname>JoinsNamespaceOf=
</varname></term>
886 <listitem><para>For units that start processes (such as service units), lists one or more other units
887 whose network and/or temporary file namespace to join. If this is specified on a unit (say, a.service
888 has
<varname>JoinsNamespaceOf=b.service
</varname>), then this the inverse dependency
889 (
<varname>JoinsNamespaceOf=a.service
</varname> for b.service) is implied. This only applies to unit
890 types which support the
<varname>PrivateNetwork=
</varname>,
<varname>NetworkNamespacePath=
</varname>,
891 <varname>PrivateIPC=
</varname>,
<varname>IPCNamespacePath=
</varname>, and
892 <varname>PrivateTmp=
</varname> directives (see
893 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
894 details). If a unit that has this setting set is started, its processes will see the same
895 <filename>/tmp/
</filename>,
<filename>/var/tmp/
</filename>, IPC namespace and network namespace as
896 one listed unit that is started. If multiple listed units are already started and these do not share
897 their namespace, then it is not defined which namespace is joined. Note that this setting only has an
898 effect if
<varname>PrivateNetwork=
</varname>/
<varname>NetworkNamespacePath=
</varname>,
899 <varname>PrivateIPC=
</varname>/
<varname>IPCNamespacePath=
</varname> and/or
900 <varname>PrivateTmp=
</varname> is enabled for both the unit that joins the namespace and the unit
901 whose namespace is joined.
</para>
903 <xi:include href=
"version-info.xml" xpointer=
"v209"/></listitem>
907 <term><varname>RequiresMountsFor=
</varname></term>
909 <listitem><para>Takes a space-separated list of absolute
910 paths. Automatically adds dependencies of type
911 <varname>Requires=
</varname> and
<varname>After=
</varname> for
912 all mount units required to access the specified path.
</para>
914 <para>Mount points marked with
<option>noauto
</option> are not
915 mounted automatically through
<filename>local-fs.target
</filename>,
916 but are still honored for the purposes of this option, i.e. they
917 will be pulled in by this unit.
</para>
919 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
923 <term><varname>OnSuccessJobMode=
</varname></term>
924 <term><varname>OnFailureJobMode=
</varname></term>
926 <listitem><para>Takes a value of
927 <literal>fail
</literal>,
928 <literal>replace
</literal>,
929 <literal>replace-irreversibly
</literal>,
930 <literal>isolate
</literal>,
931 <literal>flush
</literal>,
932 <literal>ignore-dependencies
</literal> or
933 <literal>ignore-requirements
</literal>. Defaults to
934 <literal>replace
</literal>. Specifies how the units listed in
935 <varname>OnSuccess=
</varname>/
<varname>OnFailure=
</varname> will be enqueued. See
936 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
937 <option>--job-mode=
</option> option for details on the
938 possible values. If this is set to
<literal>isolate
</literal>,
939 only a single unit may be listed in
940 <varname>OnSuccess=
</varname>/
<varname>OnFailure=
</varname>.
</para>
942 <xi:include href=
"version-info.xml" xpointer=
"v209"/></listitem>
946 <term><varname>IgnoreOnIsolate=
</varname></term>
948 <listitem><para>Takes a boolean argument. If
<option>true
</option>, this unit will not be stopped
949 when isolating another unit. Defaults to
<option>false
</option> for service, target, socket, timer,
950 and path units, and
<option>true
</option> for slice, scope, device, swap, mount, and automount
953 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
957 <term><varname>StopWhenUnneeded=
</varname></term>
959 <listitem><para>Takes a boolean argument. If
960 <option>true
</option>, this unit will be stopped when it is no
961 longer used. Note that, in order to minimize the work to be
962 executed, systemd will not stop units by default unless they
963 are conflicting with other units, or the user explicitly
964 requested their shut down. If this option is set, a unit will
965 be automatically cleaned up if no other active unit requires
966 it. Defaults to
<option>false
</option>.
</para>
968 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
972 <term><varname>RefuseManualStart=
</varname></term>
973 <term><varname>RefuseManualStop=
</varname></term>
975 <listitem><para>Takes a boolean argument. If
976 <option>true
</option>, this unit can only be activated or
977 deactivated indirectly. In this case, explicit start-up or
978 termination requested by the user is denied, however if it is
979 started or stopped as a dependency of another unit, start-up
980 or termination will succeed. This is mostly a safety feature
981 to ensure that the user does not accidentally activate units
982 that are not intended to be activated explicitly, and not
983 accidentally deactivate units that are not intended to be
984 deactivated. These options default to
985 <option>false
</option>.
</para>
987 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
991 <term><varname>AllowIsolate=
</varname></term>
993 <listitem><para>Takes a boolean argument. If
994 <option>true
</option>, this unit may be used with the
995 <command>systemctl isolate
</command> command. Otherwise, this
996 will be refused. It probably is a good idea to leave this
997 disabled except for target units that shall be used similar to
998 runlevels in SysV init systems, just as a precaution to avoid
999 unusable system states. This option defaults to
1000 <option>false
</option>.
</para>
1002 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
1006 <term><varname>DefaultDependencies=
</varname></term>
1008 <listitem><para>Takes a boolean argument. If
1009 <option>yes
</option>, (the default), a few default
1010 dependencies will implicitly be created for the unit. The
1011 actual dependencies created depend on the unit type. For
1012 example, for service units, these dependencies ensure that the
1013 service is started only after basic system initialization is
1014 completed and is properly terminated on system shutdown. See
1015 the respective man pages for details. Generally, only services
1016 involved with early boot or late shutdown should set this
1017 option to
<option>no
</option>. It is highly recommended to
1018 leave this option enabled for the majority of common units. If
1019 set to
<option>no
</option>, this option does not disable
1020 all implicit dependencies, just non-essential
1023 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
1027 <term><varname>SurviveFinalKillSignal=
</varname></term>
1029 <listitem><para>Takes a boolean argument. Defaults to
<option>no
</option>. If
<option>yes
</option>,
1030 processes belonging to this unit will not be sent the final
<literal>SIGTERM
</literal> and
1031 <literal>SIGKILL
</literal> signals during the final phase of the system shutdown process.
1032 This functionality replaces the older mechanism that allowed a program to set
1033 <literal>argv[
0][
0] = '@'
</literal> as described at
1034 <ulink url=
"https://systemd.io/ROOT_STORAGE_DAEMONS">systemd and Storage Daemons for the Root File
1035 System
</ulink>, which however continues to be supported.
</para>
1037 <xi:include href=
"version-info.xml" xpointer=
"v255"/></listitem>
1041 <term><varname>CollectMode=
</varname></term>
1043 <listitem><para>Tweaks the
"garbage collection" algorithm for this unit. Takes one of
<option>inactive
</option>
1044 or
<option>inactive-or-failed
</option>. If set to
<option>inactive
</option> the unit will be unloaded if it is
1045 in the
<constant>inactive
</constant> state and is not referenced by clients, jobs or other units — however it
1046 is not unloaded if it is in the
<constant>failed
</constant> state. In
<option>failed
</option> mode, failed
1047 units are not unloaded until the user invoked
<command>systemctl reset-failed
</command> on them to reset the
1048 <constant>failed
</constant> state, or an equivalent command. This behaviour is altered if this option is set to
1049 <option>inactive-or-failed
</option>: in this case the unit is unloaded even if the unit is in a
1050 <constant>failed
</constant> state, and thus an explicitly resetting of the
<constant>failed
</constant> state is
1051 not necessary. Note that if this mode is used unit results (such as exit codes, exit signals, consumed
1052 resources, …) are flushed out immediately after the unit completed, except for what is stored in the logging
1053 subsystem. Defaults to
<option>inactive
</option>.
</para>
1055 <xi:include href=
"version-info.xml" xpointer=
"v236"/>
1060 <term><varname>FailureAction=
</varname></term>
1061 <term><varname>SuccessAction=
</varname></term>
1063 <listitem><para>Configure the action to take when the unit stops and enters a failed state or
1064 inactive state. Takes one of
<option>none
</option>,
<option>reboot
</option>,
1065 <option>reboot-force
</option>,
<option>reboot-immediate
</option>,
<option>poweroff
</option>,
1066 <option>poweroff-force
</option>,
<option>poweroff-immediate
</option>,
<option>exit
</option>,
1067 <option>exit-force
</option>,
<option>soft-reboot
</option>,
<option>soft-reboot-force
</option>,
1068 <option>kexec
</option>,
<option>kexec-force
</option>,
<option>halt
</option>,
1069 <option>halt-force
</option> and
<option>halt-immediate
</option>. In system mode, all options are
1070 allowed. In user mode, only
<option>none
</option>,
<option>exit
</option>,
1071 <option>exit-force
</option>,
<option>soft-reboot
</option> and
<option>soft-reboot-force
</option> are
1072 allowed. Both options default to
<option>none
</option>.
</para>
1074 <para>If
<option>none
</option> is set, no action will be triggered.
<option>reboot
</option> causes a
1075 reboot following the normal shutdown procedure (i.e. equivalent to
<command>systemctl
1076 reboot
</command>).
<option>reboot-force
</option> causes a forced reboot which will terminate all
1077 processes forcibly but should cause no dirty file systems on reboot (i.e. equivalent to
1078 <command>systemctl reboot -f
</command>) and
<option>reboot-immediate
</option> causes immediate
1080 <citerefentry><refentrytitle>reboot
</refentrytitle><manvolnum>2</manvolnum></citerefentry> system
1081 call, which might result in data loss (i.e. equivalent to
<command>systemctl reboot -ff
</command>).
1082 Similarly,
<option>poweroff
</option>,
<option>poweroff-force
</option>,
1083 <option>poweroff-immediate
</option>,
<option>kexec
</option>,
<option>kexec-force
</option>,
1084 <option>halt
</option>,
<option>halt-force
</option> and
<option>halt-immediate
</option> have the
1085 effect of powering down the system, executing kexec, and halting the system respectively with similar
1086 semantics.
<option>exit
</option> causes the manager to exit following the normal shutdown procedure,
1087 and
<option>exit-force
</option> causes it terminate without shutting down services. When
1088 <option>exit
</option> or
<option>exit-force
</option> is used by default the exit status of the main
1089 process of the unit (if this applies) is returned from the service manager. However, this may be
1091 <varname>FailureActionExitStatus=
</varname>/
<varname>SuccessActionExitStatus=
</varname>, see below.
1092 <option>soft-reboot
</option> will trigger a userspace reboot operation.
1093 <option>soft-reboot-force
</option> does that too, but does not go through the shutdown transaction
1096 <xi:include href=
"version-info.xml" xpointer=
"v236"/></listitem>
1100 <term><varname>FailureActionExitStatus=
</varname></term>
1101 <term><varname>SuccessActionExitStatus=
</varname></term>
1103 <listitem><para>Controls the exit status to propagate back to an invoking container manager (in case of a
1104 system service) or service manager (in case of a user manager) when the
1105 <varname>FailureAction=
</varname>/
<varname>SuccessAction=
</varname> are set to
<option>exit
</option> or
1106 <option>exit-force
</option> and the action is triggered. By default the exit status of the main process of the
1107 triggering unit (if this applies) is propagated. Takes a value in the range
0…
255 or the empty string to
1108 request default behaviour.
</para>
1110 <xi:include href=
"version-info.xml" xpointer=
"v240"/></listitem>
1114 <term><varname>JobTimeoutSec=
</varname></term>
1115 <term><varname>JobRunningTimeoutSec=
</varname></term>
1117 <listitem><para><varname>JobTimeoutSec=
</varname> specifies a timeout for the whole job that starts
1118 running when the job is queued.
<varname>JobRunningTimeoutSec=
</varname> specifies a timeout that
1119 starts running when the queued job is actually started. If either limit is reached, the job will be
1120 cancelled, the unit however will not change state or even enter the
<literal>failed
</literal> mode.
1123 <para>Both settings take a time span with the default unit of seconds, but other units may be
1125 <citerefentry><refentrytitle>systemd.time
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
1126 The default is
<literal>infinity
</literal> (job timeouts disabled), except for device units where
1127 <varname>JobRunningTimeoutSec=
</varname> defaults to
<varname>DefaultDeviceTimeoutSec=
</varname>.
1130 <para>Note: these timeouts are independent from any unit-specific timeouts (for example, the timeout
1131 set with
<varname>TimeoutStartSec=
</varname> in service units). The job timeout has no effect on the
1132 unit itself. Or in other words: unit-specific timeouts are useful to abort unit state changes, and
1133 revert them. The job timeout set with this option however is useful to abort only the job waiting for
1134 the unit state to change.
</para>
1136 <xi:include href=
"version-info.xml" xpointer=
"v201"/>
1141 <term><varname>JobTimeoutAction=
</varname></term>
1142 <term><varname>JobTimeoutRebootArgument=
</varname></term>
1144 <listitem><para><varname>JobTimeoutAction=
</varname> optionally configures an additional action to
1145 take when the timeout is hit, see description of
<varname>JobTimeoutSec=
</varname> and
1146 <varname>JobRunningTimeoutSec=
</varname> above. It takes the same values as
1147 <varname>StartLimitAction=
</varname>. Defaults to
<option>none
</option>.
</para>
1149 <para><varname>JobTimeoutRebootArgument=
</varname> configures an optional reboot string to pass to
1150 the
<citerefentry><refentrytitle>reboot
</refentrytitle><manvolnum>2</manvolnum></citerefentry> system
1153 <xi:include href=
"version-info.xml" xpointer=
"v240"/></listitem>
1157 <term><varname>StartLimitIntervalSec=
<replaceable>interval
</replaceable></varname></term>
1158 <term><varname>StartLimitBurst=
<replaceable>burst
</replaceable></varname></term>
1160 <listitem><para>Configure unit start rate limiting. Units which are started more than
1161 <replaceable>burst
</replaceable> times within an
<replaceable>interval
</replaceable> time span are
1162 not permitted to start any more. Use
<varname>StartLimitIntervalSec=
</varname> to configure the
1163 checking interval and
<varname>StartLimitBurst=
</varname> to configure how many starts per interval
1166 <para><replaceable>interval
</replaceable> is a time span with the default unit of seconds, but other
1167 units may be specified, see
1168 <citerefentry><refentrytitle>systemd.time
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
1169 Defaults to
<varname>DefaultStartLimitIntervalSec=
</varname> in manager configuration file, and may
1170 be set to
0 to disable any kind of rate limiting.
<replaceable>burst
</replaceable> is a number and
1171 defaults to
<varname>DefaultStartLimitBurst=
</varname> in manager configuration file.
</para>
1173 <para>These configuration options are particularly useful in conjunction with the service setting
1174 <varname>Restart=
</varname> (see
1175 <citerefentry><refentrytitle>systemd.service
</refentrytitle><manvolnum>5</manvolnum></citerefentry>);
1176 however, they apply to all kinds of starts (including manual), not just those triggered by the
1177 <varname>Restart=
</varname> logic.
</para>
1179 <para>Note that units which are configured for
<varname>Restart=
</varname>, and which reach the start
1180 limit are not attempted to be restarted anymore; however, they may still be restarted manually or
1181 from a timer or socket at a later point, after the
<replaceable>interval
</replaceable> has passed.
1182 From that point on, the restart logic is activated again.
<command>systemctl reset-failed
</command>
1183 will cause the restart rate counter for a service to be flushed, which is useful if the administrator
1184 wants to manually start a unit and the start limit interferes with that. Rate-limiting is enforced
1185 after any unit condition checks are executed, and hence unit activations with failing conditions do
1186 not count towards the rate limit.
</para>
1188 <para>When a unit is unloaded due to the garbage collection logic (see above) its rate limit counters
1189 are flushed out too. This means that configuring start rate limiting for a unit that is not
1190 referenced continuously has no effect.
</para>
1192 <para>This setting does not apply to slice, target, device, and scope units, since they are unit
1193 types whose activation may either never fail, or may succeed only a single time.
</para>
1195 <xi:include href=
"version-info.xml" xpointer=
"v229"/></listitem>
1199 <term><varname>StartLimitAction=
</varname></term>
1201 <listitem><para>Configure an additional action to take if the rate limit configured with
1202 <varname>StartLimitIntervalSec=
</varname> and
<varname>StartLimitBurst=
</varname> is hit. Takes the same
1203 values as the
<varname>FailureAction=
</varname>/
<varname>SuccessAction=
</varname> settings. If
1204 <option>none
</option> is set, hitting the rate limit will trigger no action except that
1205 the start will not be permitted. Defaults to
<option>none
</option>.
</para>
1207 <xi:include href=
"version-info.xml" xpointer=
"v229"/></listitem>
1211 <term><varname>RebootArgument=
</varname></term>
1212 <listitem><para>Configure the optional argument for the
1213 <citerefentry><refentrytitle>reboot
</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call if
1214 <varname>StartLimitAction=
</varname> or
<varname>FailureAction=
</varname> is a reboot action. This
1215 works just like the optional argument to
<command>systemctl reboot
</command> command.
</para>
1217 <xi:include href=
"version-info.xml" xpointer=
"v229"/></listitem>
1221 <term><varname>SourcePath=
</varname></term>
1222 <listitem><para>A path to a configuration file this unit has
1223 been generated from. This is primarily useful for
1224 implementation of generator tools that convert configuration
1225 from an external configuration file format into native unit
1226 files. This functionality should not be used in normal
1229 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
1234 <title>Conditions and Asserts
</title>
1236 <para>Unit files may also include a number of
<varname index=
"false">Condition…=
</varname> and
<varname
1237 index=
"false">Assert…=
</varname> settings. Before the unit is started, systemd will verify that the
1238 specified conditions and asserts are true. If not, the starting of the unit will be (mostly silently)
1239 skipped (in case of conditions), or aborted with an error message (in case of asserts). Failing
1240 conditions or asserts will not result in the unit being moved into the
<literal>failed
</literal>
1241 state. The conditions and asserts are checked at the time the queued start job is to be executed. The
1242 ordering dependencies are still respected, so other units are still pulled in and ordered as if this
1243 unit was successfully activated, and the conditions and asserts are executed the precise moment the
1244 unit would normally start and thus can validate system state after the units ordered before completed
1245 initialization. Use condition expressions for skipping units that do not apply to the local system, for
1246 example because the kernel or runtime environment doesn't require their functionality.
1249 <para>If multiple conditions are specified, the unit will be executed if all of them apply (i.e. a
1250 logical AND is applied). Condition checks can use a pipe symbol (
<literal>|
</literal>) after the equals
1251 sign (
<literal>Condition…=|…
</literal>), which causes the condition to become a
1252 <emphasis>triggering
</emphasis> condition. If at least one triggering condition is defined for a unit,
1253 then the unit will be started if at least one of the triggering conditions of the unit applies and all
1254 of the regular (i.e. non-triggering) conditions apply. If you prefix an argument with the pipe symbol
1255 and an exclamation mark, the pipe symbol must be passed first, the exclamation second. If any of these
1256 options is assigned the empty string, the list of conditions is reset completely, all previous
1257 condition settings (of any kind) will have no effect.
</para>
1259 <para>The
<varname>AssertArchitecture=
</varname>,
<varname>AssertVirtualization=
</varname>, … options
1260 are similar to conditions but cause the start job to fail (instead of being skipped). The failed check
1261 is logged. Units with unmet conditions are considered to be in a clean state and will be garbage
1262 collected if they are not referenced. This means that when queried, the condition failure may or may
1263 not show up in the state of the unit.
</para>
1265 <para>Note that neither assertion nor condition expressions result in unit state changes. Also note
1266 that both are checked at the time the job is to be executed, i.e. long after depending jobs and it
1267 itself were queued. Thus, neither condition nor assertion expressions are suitable for conditionalizing
1268 unit dependencies.
</para>
1270 <para>The
<command>condition
</command> verb of
1271 <citerefentry><refentrytitle>systemd-analyze
</refentrytitle><manvolnum>1</manvolnum></citerefentry> can
1272 be used to test condition and assert expressions.
</para>
1274 <para>Except for
<varname>ConditionPathIsSymbolicLink=
</varname>, all path checks follow symlinks.
</para>
1276 <variablelist class='unit-directives'
>
1278 <term><varname>ConditionArchitecture=
</varname></term>
1280 <listitem><para>Check whether the system is running on a specific architecture. Takes one of
1281 <literal>x86
</literal>,
1282 <literal>x86-
64</literal>,
1283 <literal>ppc
</literal>,
1284 <literal>ppc-le
</literal>,
1285 <literal>ppc64
</literal>,
1286 <literal>ppc64-le
</literal>,
1287 <literal>ia64
</literal>,
1288 <literal>parisc
</literal>,
1289 <literal>parisc64
</literal>,
1290 <literal>s390
</literal>,
1291 <literal>s390x
</literal>,
1292 <literal>sparc
</literal>,
1293 <literal>sparc64
</literal>,
1294 <literal>mips
</literal>,
1295 <literal>mips-le
</literal>,
1296 <literal>mips64
</literal>,
1297 <literal>mips64-le
</literal>,
1298 <literal>alpha
</literal>,
1299 <literal>arm
</literal>,
1300 <literal>arm-be
</literal>,
1301 <literal>arm64
</literal>,
1302 <literal>arm64-be
</literal>,
1303 <literal>sh
</literal>,
1304 <literal>sh64
</literal>,
1305 <literal>m68k
</literal>,
1306 <literal>tilegx
</literal>,
1307 <literal>cris
</literal>,
1308 <literal>arc
</literal>,
1309 <literal>arc-be
</literal>, or
1310 <literal>native
</literal>.
</para>
1312 <para>The architecture is determined from the information returned by
1313 <citerefentry project='man-pages'
><refentrytitle>uname
</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1314 and is thus subject to
1315 <citerefentry><refentrytitle>personality
</refentrytitle><manvolnum>2</manvolnum></citerefentry>.
1316 Note that a
<varname>Personality=
</varname> setting in the same unit file has no effect on this
1317 condition. A special architecture name
<literal>native
</literal> is mapped to the architecture the
1318 system manager itself is compiled for. The test may be negated by prepending an exclamation
1321 <xi:include href=
"version-info.xml" xpointer=
"v201"/>
1326 <term><varname>ConditionFirmware=
</varname></term>
1328 <listitem><para>Check whether the system's firmware is of a certain type. The following values are
1332 <listitem><para><literal>uefi
</literal> matches systems with EFI.
</para></listitem>
1334 <listitem><para><literal>device-tree
</literal> matches systems with a device tree.
1337 <listitem><para><literal>device-tree-compatible(
<replaceable>value
</replaceable>)
</literal>
1338 matches systems with a device tree that are compatible with
<literal>value
</literal>.
1341 <listitem><para><literal>smbios-field(
<replaceable>field
</replaceable>
1342 <replaceable>operator
</replaceable> <replaceable>value
</replaceable>)
</literal> matches systems
1343 with a SMBIOS field containing a certain value.
<replaceable>field
</replaceable> is the name of
1344 the SMBIOS field exposed as
<literal>sysfs
</literal> attribute file below
1345 <filename>/sys/class/dmi/id/
</filename>.
<replaceable>operator
</replaceable> is one of
1346 <literal><</literal>,
<literal><=
</literal>,
<literal>>=
</literal>,
1347 <literal>></literal>,
<literal>==
</literal>,
<literal><></literal> for version
1348 comparisons,
<literal>=
</literal> and
<literal>!=
</literal> for literal string comparisons, or
1349 <literal>$=
</literal>,
<literal>!$=
</literal> for shell-style glob comparisons.
1350 <replaceable>value
</replaceable> is the expected value of the SMBIOS field value (possibly
1351 containing shell style globs in case
<literal>$=
</literal>/
<literal>!$=
</literal> is used).
1355 <xi:include href=
"version-info.xml" xpointer=
"v249"/></listitem>
1359 <term><varname>ConditionVirtualization=
</varname></term>
1361 <listitem><para>Check whether the system is executed in a virtualized environment and optionally
1362 test whether it is a specific implementation. Takes either boolean value to check if being executed
1363 in any virtualized environment, or one of
1364 <literal>vm
</literal> and
1365 <literal>container
</literal> to test against a generic type of virtualization solution, or one of
1366 <literal>qemu
</literal>,
1367 <literal>kvm
</literal>,
1368 <literal>amazon
</literal>,
1369 <literal>zvm
</literal>,
1370 <literal>vmware
</literal>,
1371 <literal>microsoft
</literal>,
1372 <literal>oracle
</literal>,
1373 <literal>powervm
</literal>,
1374 <literal>xen
</literal>,
1375 <literal>bochs
</literal>,
1376 <literal>uml
</literal>,
1377 <literal>bhyve
</literal>,
1378 <literal>qnx
</literal>,
1379 <literal>apple
</literal>,
1380 <literal>sre
</literal>,
1381 <literal>openvz
</literal>,
1382 <literal>lxc
</literal>,
1383 <literal>lxc-libvirt
</literal>,
1384 <literal>systemd-nspawn
</literal>,
1385 <literal>docker
</literal>,
1386 <literal>podman
</literal>,
1387 <literal>rkt
</literal>,
1388 <literal>wsl
</literal>,
1389 <literal>proot
</literal>,
1390 <literal>pouch
</literal>,
1391 <literal>acrn
</literal> to test
1392 against a specific implementation, or
1393 <literal>private-users
</literal> to check whether we are running in a user namespace. See
1394 <citerefentry><refentrytitle>systemd-detect-virt
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1395 for a full list of known virtualization technologies and their identifiers. If multiple
1396 virtualization technologies are nested, only the innermost is considered. The test may be negated
1397 by prepending an exclamation mark.
</para>
1399 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1404 <term><varname>ConditionHost=
</varname></term>
1406 <listitem><para><varname>ConditionHost=
</varname> may be used to match against the hostname or
1407 machine ID of the host. This either takes a hostname string (optionally with shell style globs)
1408 which is tested against the locally set hostname as returned by
1409 <citerefentry><refentrytitle>gethostname
</refentrytitle><manvolnum>2</manvolnum></citerefentry>, or
1410 a machine ID formatted as string (see
1411 <citerefentry><refentrytitle>machine-id
</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
1412 The test may be negated by prepending an exclamation mark.
</para>
1414 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1419 <term><varname>ConditionKernelCommandLine=
</varname></term>
1421 <listitem><para><varname>ConditionKernelCommandLine=
</varname> may be used to check whether a
1422 specific kernel command line option is set (or if prefixed with the exclamation mark — unset). The
1423 argument must either be a single word, or an assignment (i.e. two words, separated by
1424 <literal>=
</literal>). In the former case the kernel command line is searched for the word
1425 appearing as is, or as left hand side of an assignment. In the latter case, the exact assignment is
1426 looked for with right and left hand side matching. This operates on the kernel command line
1427 communicated to userspace via
<filename>/proc/cmdline
</filename>, except when the service manager
1428 is invoked as payload of a container manager, in which case the command line of
<filename>PID
1429 1</filename> is used instead (i.e.
<filename>/proc/
1/cmdline
</filename>).
</para>
1431 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1436 <term><varname>ConditionKernelVersion=
</varname></term>
1438 <listitem><para><varname>ConditionKernelVersion=
</varname> may be used to check whether the kernel
1439 version (as reported by
<command>uname -r
</command>) matches a certain expression, or if prefixed
1440 with the exclamation mark, does not match. The argument must be a list of (potentially quoted)
1441 expressions. Each expression starts with one of
<literal>=
</literal> or
<literal>!=
</literal> for
1442 string comparisons,
<literal><</literal>,
<literal><=
</literal>,
<literal>==
</literal>,
1443 <literal><></literal>,
<literal>>=
</literal>,
<literal>></literal> for version
1444 comparisons, or
<literal>$=
</literal>,
<literal>!$=
</literal> for a shell-style glob match. If no
1445 operator is specified,
<literal>$=
</literal> is implied.
</para>
1447 <para>Note that using the kernel version string is an unreliable way to determine which features
1448 are supported by a kernel, because of the widespread practice of backporting drivers, features, and
1449 fixes from newer upstream kernels into older versions provided by distributions. Hence, this check
1450 is inherently unportable and should not be used for units which may be used on different
1451 distributions.
</para>
1453 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1458 <term><varname>ConditionCredential=
</varname></term>
1460 <listitem><para><varname>ConditionCredential=
</varname> may be used to check whether a credential
1461 by the specified name was passed into the service manager. See
<ulink
1462 url=
"https://systemd.io/CREDENTIALS">System and Service Credentials
</ulink> for details about
1463 credentials. If used in services for the system service manager this may be used to conditionalize
1464 services based on system credentials passed in. If used in services for the per-user service
1465 manager this may be used to conditionalize services based on credentials passed into the
1466 <filename>unit@.service
</filename> service instance belonging to the user. The argument must be a
1467 valid credential name.
</para>
1469 <xi:include href=
"version-info.xml" xpointer=
"v252"/></listitem>
1473 <term><varname>ConditionEnvironment=
</varname></term>
1475 <listitem><para><varname>ConditionEnvironment=
</varname> may be used to check whether a specific
1476 environment variable is set (or if prefixed with the exclamation mark — unset) in the service
1477 manager's environment block.
1479 The argument may be a single word, to check if the variable with this name is defined in the
1480 environment block, or an assignment
1481 (
<literal><replaceable>name
</replaceable>=
<replaceable>value
</replaceable></literal>), to check if
1482 the variable with this exact value is defined. Note that the environment block of the service
1483 manager itself is checked, i.e. not any variables defined with
<varname>Environment=
</varname> or
1484 <varname>EnvironmentFile=
</varname>, as described above. This is particularly useful when the
1485 service manager runs inside a containerized environment or as per-user service manager, in order to
1486 check for variables passed in by the enclosing container manager or PAM.
</para>
1488 <xi:include href=
"version-info.xml" xpointer=
"v246"/>
1493 <term><varname>ConditionSecurity=
</varname></term>
1495 <listitem><para><varname>ConditionSecurity=
</varname> may be used to check whether the given
1496 security technology is enabled on the system. Currently, the following values are recognized:
</para>
1499 <title>Recognized security technologies
</title>
1502 <colspec colname='value'
/>
1503 <colspec colname='description'
/>
1507 <entry>Value
</entry>
1508 <entry>Description
</entry>
1513 <entry>selinux
</entry>
1514 <entry>SELinux MAC
</entry>
1517 <entry>apparmor
</entry>
1518 <entry>AppArmor MAC
</entry>
1521 <entry>tomoyo
</entry>
1522 <entry>Tomoyo MAC
</entry>
1525 <entry>smack
</entry>
1526 <entry>SMACK MAC
</entry>
1530 <entry>Integrity Measurement Architecture (IMA)
</entry>
1533 <entry>audit
</entry>
1534 <entry>Linux Audit Framework
</entry>
1537 <entry>uefi-secureboot
</entry>
1538 <entry>UEFI SecureBoot
</entry>
1542 <entry>Trusted Platform Module
2.0 (TPM2)
</entry>
1546 <entry>Confidential virtual machine (SEV/TDX)
</entry>
1549 <entry>measured-uki
</entry>
1550 <entry>Unified Kernel Image with PCR
11 Measurements, as per
<citerefentry><refentrytitle>systemd-stub
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
<xi:include href=
"version-info.xml" xpointer=
"v255"/></entry>
1556 <para>The test may be negated by prepending an exclamation mark.
</para>
1558 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1563 <term><varname>ConditionCapability=
</varname></term>
1565 <listitem><para>Check whether the given capability exists in the capability bounding set of the
1566 service manager (i.e. this does not check whether capability is actually available in the permitted
1567 or effective sets, see
1568 <citerefentry project='man-pages'
><refentrytitle>capabilities
</refentrytitle><manvolnum>7</manvolnum></citerefentry>
1569 for details). Pass a capability name such as
<literal>CAP_MKNOD
</literal>, possibly prefixed with
1570 an exclamation mark to negate the check.
</para>
1572 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1577 <term><varname>ConditionACPower=
</varname></term>
1579 <listitem><para>Check whether the system has AC power, or is exclusively battery powered at the
1580 time of activation of the unit. This takes a boolean argument. If set to
<literal>true
</literal>,
1581 the condition will hold only if at least one AC connector of the system is connected to a power
1582 source, or if no AC connectors are known. Conversely, if set to
<literal>false
</literal>, the
1583 condition will hold only if there is at least one AC connector known and all AC connectors are
1584 disconnected from a power source.
</para>
1586 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1591 <term><varname>ConditionNeedsUpdate=
</varname></term>
1593 <listitem><para>Takes one of
<filename>/var/
</filename> or
<filename>/etc/
</filename> as argument,
1594 possibly prefixed with a
<literal>!
</literal> (to invert the condition). This condition may be
1595 used to conditionalize units on whether the specified directory requires an update because
1596 <filename>/usr/
</filename>'s modification time is newer than the stamp file
1597 <filename>.updated
</filename> in the specified directory. This is useful to implement offline
1598 updates of the vendor operating system resources in
<filename>/usr/
</filename> that require updating
1599 of
<filename>/etc/
</filename> or
<filename>/var/
</filename> on the next following boot. Units making
1600 use of this condition should order themselves before
1601 <citerefentry><refentrytitle>systemd-update-done.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1602 to make sure they run before the stamp file's modification time gets reset indicating a completed
1605 <para>If the
<varname>systemd.condition-needs-update=
</varname> option is specified on the kernel
1606 command line (taking a boolean), it will override the result of this condition check, taking
1607 precedence over any file modification time checks. If the kernel command line option is used,
1608 <filename>systemd-update-done.service
</filename> will not have immediate effect on any following
1609 <varname>ConditionNeedsUpdate=
</varname> checks, until the system is rebooted where the kernel
1610 command line option is not specified anymore.
</para>
1612 <para>Note that to make this scheme effective, the timestamp of
<filename>/usr/
</filename> should
1613 be explicitly updated after its contents are modified. The kernel will automatically update
1614 modification timestamp on a directory only when immediate children of a directory are modified; an
1615 modification of nested files will not automatically result in mtime of
<filename>/usr/
</filename>
1616 being updated.
</para>
1618 <para>Also note that if the update method includes a call to execute appropriate post-update steps
1619 itself, it should not touch the timestamp of
<filename>/usr/
</filename>. In a typical distribution
1620 packaging scheme, packages will do any required update steps as part of the installation or
1621 upgrade, to make package contents immediately usable.
<varname>ConditionNeedsUpdate=
</varname>
1622 should be used with other update mechanisms where such an immediate update does not
1625 <xi:include href=
"version-info.xml" xpointer=
"v244"/></listitem>
1629 <term><varname>ConditionFirstBoot=
</varname></term>
1631 <listitem><para>Takes a boolean argument. This condition may be used to conditionalize units on
1632 whether the system is booting up for the first time. This roughly means that
<filename>/etc/
</filename>
1633 was unpopulated when the system started booting (for details, see
"First Boot Semantics" in
1634 <citerefentry><refentrytitle>machine-id
</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
1635 First boot is considered finished (this condition will evaluate as false) after the manager
1636 has finished the startup phase.
</para>
1638 <para>This condition may be used to populate
<filename>/etc/
</filename> on the first boot after
1639 factory reset, or when a new system instance boots up for the first time.
</para>
1641 <para>For robustness, units with
<varname>ConditionFirstBoot=yes
</varname> should order themselves
1642 before
<filename>first-boot-complete.target
</filename> and pull in this passive target with
1643 <varname>Wants=
</varname>. This ensures that in a case of an aborted first boot, these units will
1644 be re-run during the next system startup.
</para>
1646 <para>If the
<varname>systemd.condition-first-boot=
</varname> option is specified on the kernel
1647 command line (taking a boolean), it will override the result of this condition check, taking
1648 precedence over
<filename>/etc/machine-id
</filename> existence checks.
</para>
1650 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1655 <term><varname>ConditionPathExists=
</varname></term>
1657 <listitem><para>Check for the existence of a file. If the specified absolute path name does not exist,
1658 the condition will fail. If the absolute path name passed to
1659 <varname>ConditionPathExists=
</varname> is prefixed with an exclamation mark
1660 (
<literal>!
</literal>), the test is negated, and the unit is only started if the path does not
1663 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1668 <term><varname>ConditionPathExistsGlob=
</varname></term>
1670 <listitem><para><varname>ConditionPathExistsGlob=
</varname> is similar to
1671 <varname>ConditionPathExists=
</varname>, but checks for the existence of at least one file or
1672 directory matching the specified globbing pattern.
</para>
1674 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1679 <term><varname>ConditionPathIsDirectory=
</varname></term>
1681 <listitem><para><varname>ConditionPathIsDirectory=
</varname> is similar to
1682 <varname>ConditionPathExists=
</varname> but verifies that a certain path exists and is a
1685 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1690 <term><varname>ConditionPathIsSymbolicLink=
</varname></term>
1692 <listitem><para><varname>ConditionPathIsSymbolicLink=
</varname> is similar to
1693 <varname>ConditionPathExists=
</varname> but verifies that a certain path exists and is a symbolic
1696 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1701 <term><varname>ConditionPathIsMountPoint=
</varname></term>
1703 <listitem><para><varname>ConditionPathIsMountPoint=
</varname> is similar to
1704 <varname>ConditionPathExists=
</varname> but verifies that a certain path exists and is a mount
1707 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1712 <term><varname>ConditionPathIsReadWrite=
</varname></term>
1714 <listitem><para><varname>ConditionPathIsReadWrite=
</varname> is similar to
1715 <varname>ConditionPathExists=
</varname> but verifies that the underlying file system is readable
1716 and writable (i.e. not mounted read-only).
</para>
1718 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1723 <term><varname>ConditionPathIsEncrypted=
</varname></term>
1725 <listitem><para><varname>ConditionPathIsEncrypted=
</varname> is similar to
1726 <varname>ConditionPathExists=
</varname> but verifies that the underlying file system's backing
1727 block device is encrypted using dm-crypt/LUKS. Note that this check does not cover ext4
1728 per-directory encryption, and only detects block level encryption. Moreover, if the specified path
1729 resides on a file system on top of a loopback block device, only encryption above the loopback device is
1730 detected. It is not detected whether the file system backing the loopback block device is encrypted.
</para>
1732 <xi:include href=
"version-info.xml" xpointer=
"v246"/>
1737 <term><varname>ConditionDirectoryNotEmpty=
</varname></term>
1739 <listitem><para><varname>ConditionDirectoryNotEmpty=
</varname> is similar to
1740 <varname>ConditionPathExists=
</varname> but verifies that a certain path exists and is a non-empty
1743 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1748 <term><varname>ConditionFileNotEmpty=
</varname></term>
1750 <listitem><para><varname>ConditionFileNotEmpty=
</varname> is similar to
1751 <varname>ConditionPathExists=
</varname> but verifies that a certain path exists and refers to a
1752 regular file with a non-zero size.
</para>
1754 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1759 <term><varname>ConditionFileIsExecutable=
</varname></term>
1761 <listitem><para><varname>ConditionFileIsExecutable=
</varname> is similar to
1762 <varname>ConditionPathExists=
</varname> but verifies that a certain path exists, is a regular file,
1763 and marked executable.
</para>
1765 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1770 <term><varname>ConditionUser=
</varname></term>
1772 <listitem><para><varname>ConditionUser=
</varname> takes a numeric
<literal>UID
</literal>, a UNIX
1773 user name, or the special value
<literal>@system
</literal>. This condition may be used to check
1774 whether the service manager is running as the given user. The special value
1775 <literal>@system
</literal> can be used to check if the user id is within the system user
1776 range. This option is not useful for system services, as the system manager exclusively runs as the
1777 root user, and thus the test result is constant.
</para>
1779 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1784 <term><varname>ConditionGroup=
</varname></term>
1786 <listitem><para><varname>ConditionGroup=
</varname> is similar to
<varname>ConditionUser=
</varname>
1787 but verifies that the service manager's real or effective group, or any of its auxiliary groups,
1788 match the specified group or GID. This setting does not support the special value
1789 <literal>@system
</literal>.
</para>
1791 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1796 <term><varname>ConditionControlGroupController=
</varname></term>
1798 <listitem><para>Check whether given cgroup controllers (e.g.
<literal>cpu
</literal>) are available
1799 for use on the system or whether the legacy v1 cgroup or the modern v2 cgroup hierarchy is used.
1802 <para>Multiple controllers may be passed with a space separating them; in this case the condition
1803 will only pass if all listed controllers are available for use. Controllers unknown to systemd are
1804 ignored. Valid controllers are
<literal>cpu
</literal>,
<literal>io
</literal>,
1805 <literal>memory
</literal>, and
<literal>pids
</literal>. Even if available in the kernel, a
1806 particular controller may not be available if it was disabled on the kernel command line with
1807 <varname>cgroup_disable=controller
</varname>.
</para>
1809 <para>Alternatively, two special strings
<literal>v1
</literal> and
<literal>v2
</literal> may be
1810 specified (without any controller names).
<literal>v2
</literal> will pass if the unified v2 cgroup
1811 hierarchy is used, and
<literal>v1
</literal> will pass if the legacy v1 hierarchy or the hybrid
1812 hierarchy are used. Note that legacy or hybrid hierarchies have been deprecated. See
1813 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry> for
1814 more information.
</para>
1816 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1821 <term><varname>ConditionMemory=
</varname></term>
1823 <listitem><para>Verify that the specified amount of system memory is available to the current
1824 system. Takes a memory size in bytes as argument, optionally prefixed with a comparison operator
1825 <literal><</literal>,
<literal><=
</literal>,
<literal>=
</literal> (or
<literal>==
</literal>),
1826 <literal>!=
</literal> (or
<literal><></literal>),
<literal>>=
</literal>,
1827 <literal>></literal>. On bare-metal systems compares the amount of physical memory in the system
1828 with the specified size, adhering to the specified comparison operator. In containers compares the
1829 amount of memory assigned to the container instead.
</para>
1831 <xi:include href=
"version-info.xml" xpointer=
"v244"/>
1836 <term><varname>ConditionCPUs=
</varname></term>
1838 <listitem><para>Verify that the specified number of CPUs is available to the current system. Takes
1839 a number of CPUs as argument, optionally prefixed with a comparison operator
1840 <literal><</literal>,
<literal><=
</literal>,
<literal>=
</literal> (or
<literal>==
</literal>),
1841 <literal>!=
</literal> (or
<literal><></literal>),
<literal>>=
</literal>,
1842 <literal>></literal>. Compares the number of CPUs in the CPU affinity mask configured of the
1843 service manager itself with the specified number, adhering to the specified comparison operator. On
1844 physical systems the number of CPUs in the affinity mask of the service manager usually matches the
1845 number of physical CPUs, but in special and virtual environments might differ. In particular, in
1846 containers the affinity mask usually matches the number of CPUs assigned to the container and not
1847 the physically available ones.
</para>
1849 <xi:include href=
"version-info.xml" xpointer=
"v244"/></listitem>
1853 <term><varname>ConditionCPUFeature=
</varname></term>
1855 <listitem><para>Verify that a given CPU feature is available via the
<literal>CPUID
</literal>
1856 instruction. This condition only does something on i386 and x86-
64 processors. On other
1857 processors it is assumed that the CPU does not support the given feature. It checks the leaves
1858 <literal>1</literal>,
<literal>7</literal>,
<literal>0x80000001</literal>, and
1859 <literal>0x80000007</literal>. Valid values are:
1860 <literal>fpu
</literal>,
1861 <literal>vme
</literal>,
1862 <literal>de
</literal>,
1863 <literal>pse
</literal>,
1864 <literal>tsc
</literal>,
1865 <literal>msr
</literal>,
1866 <literal>pae
</literal>,
1867 <literal>mce
</literal>,
1868 <literal>cx8
</literal>,
1869 <literal>apic
</literal>,
1870 <literal>sep
</literal>,
1871 <literal>mtrr
</literal>,
1872 <literal>pge
</literal>,
1873 <literal>mca
</literal>,
1874 <literal>cmov
</literal>,
1875 <literal>pat
</literal>,
1876 <literal>pse36
</literal>,
1877 <literal>clflush
</literal>,
1878 <literal>mmx
</literal>,
1879 <literal>fxsr
</literal>,
1880 <literal>sse
</literal>,
1881 <literal>sse2
</literal>,
1882 <literal>ht
</literal>,
1883 <literal>pni
</literal>,
1884 <literal>pclmul
</literal>,
1885 <literal>monitor
</literal>,
1886 <literal>ssse3
</literal>,
1887 <literal>fma3
</literal>,
1888 <literal>cx16
</literal>,
1889 <literal>sse4_1
</literal>,
1890 <literal>sse4_2
</literal>,
1891 <literal>movbe
</literal>,
1892 <literal>popcnt
</literal>,
1893 <literal>aes
</literal>,
1894 <literal>xsave
</literal>,
1895 <literal>osxsave
</literal>,
1896 <literal>avx
</literal>,
1897 <literal>f16c
</literal>,
1898 <literal>rdrand
</literal>,
1899 <literal>bmi1
</literal>,
1900 <literal>avx2
</literal>,
1901 <literal>bmi2
</literal>,
1902 <literal>rdseed
</literal>,
1903 <literal>adx
</literal>,
1904 <literal>sha_ni
</literal>,
1905 <literal>syscall
</literal>,
1906 <literal>rdtscp
</literal>,
1907 <literal>lm
</literal>,
1908 <literal>lahf_lm
</literal>,
1909 <literal>abm
</literal>,
1910 <literal>constant_tsc
</literal>.
</para>
1912 <xi:include href=
"version-info.xml" xpointer=
"v248"/>
1917 <term><varname>ConditionOSRelease=
</varname></term>
1919 <listitem><para>Verify that a specific
<literal>key=value
</literal> pair is set in the host's
1920 <citerefentry><refentrytitle>os-release
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>
1922 <para>Other than exact string matching (with
<literal>=
</literal> and
<literal>!=
</literal>),
1923 relative comparisons are supported for versioned parameters (e.g.
<literal>VERSION_ID
</literal>;
1924 with
<literal><</literal>,
<literal><=
</literal>,
<literal>==
</literal>,
1925 <literal><></literal>,
<literal>>=
</literal>,
<literal>></literal>), and shell-style
1926 wildcard comparisons (
<literal>*
</literal>,
<literal>?
</literal>,
<literal>[]
</literal>) are
1927 supported with the
<literal>$=
</literal> (match) and
<literal>!$=
</literal> (non-match).
</para>
1929 <xi:include href=
"version-info.xml" xpointer=
"v249"/>
1934 <term><varname>ConditionMemoryPressure=
</varname></term>
1935 <term><varname>ConditionCPUPressure=
</varname></term>
1936 <term><varname>ConditionIOPressure=
</varname></term>
1938 <listitem><para>Verify that the overall system (memory, CPU or IO) pressure is below or equal to a threshold.
1939 This setting takes a threshold value as argument. It can be specified as a simple percentage value,
1940 suffixed with
<literal>%
</literal>, in which case the pressure will be measured as an average over the last
1941 five minutes before the attempt to start the unit is performed.
1942 Alternatively, the average timespan can also be specified using
<literal>/
</literal> as a separator, for
1943 example:
<literal>10%/
1min
</literal>. The supported timespans match what the kernel provides, and are
1944 limited to
<literal>10sec
</literal>,
<literal>1min
</literal> and
<literal>5min
</literal>. The
1945 <literal>full
</literal> PSI will be checked first, and if not found
<literal>some
</literal> will be
1946 checked. For more details, see the documentation on
<ulink
1947 url=
"https://docs.kernel.org/accounting/psi.html">PSI (Pressure Stall Information)
1950 <para>Optionally, the threshold value can be prefixed with the slice unit under which the pressure will be checked,
1951 followed by a
<literal>:
</literal>. If the slice unit is not specified, the overall system pressure will be measured,
1952 instead of a particular cgroup's.
</para>
1954 <xi:include href=
"version-info.xml" xpointer=
"v250"/>
1959 <term><varname>AssertArchitecture=
</varname></term>
1960 <term><varname>AssertVirtualization=
</varname></term>
1961 <term><varname>AssertHost=
</varname></term>
1962 <term><varname>AssertKernelCommandLine=
</varname></term>
1963 <term><varname>AssertKernelVersion=
</varname></term>
1964 <term><varname>AssertCredential=
</varname></term>
1965 <term><varname>AssertEnvironment=
</varname></term>
1966 <term><varname>AssertSecurity=
</varname></term>
1967 <term><varname>AssertCapability=
</varname></term>
1968 <term><varname>AssertACPower=
</varname></term>
1969 <term><varname>AssertNeedsUpdate=
</varname></term>
1970 <term><varname>AssertFirstBoot=
</varname></term>
1971 <term><varname>AssertPathExists=
</varname></term>
1972 <term><varname>AssertPathExistsGlob=
</varname></term>
1973 <term><varname>AssertPathIsDirectory=
</varname></term>
1974 <term><varname>AssertPathIsSymbolicLink=
</varname></term>
1975 <term><varname>AssertPathIsMountPoint=
</varname></term>
1976 <term><varname>AssertPathIsReadWrite=
</varname></term>
1977 <term><varname>AssertPathIsEncrypted=
</varname></term>
1978 <term><varname>AssertDirectoryNotEmpty=
</varname></term>
1979 <term><varname>AssertFileNotEmpty=
</varname></term>
1980 <term><varname>AssertFileIsExecutable=
</varname></term>
1981 <term><varname>AssertUser=
</varname></term>
1982 <term><varname>AssertGroup=
</varname></term>
1983 <term><varname>AssertControlGroupController=
</varname></term>
1984 <term><varname>AssertMemory=
</varname></term>
1985 <term><varname>AssertCPUs=
</varname></term>
1986 <term><varname>AssertCPUFeature=
</varname></term>
1987 <term><varname>AssertOSRelease=
</varname></term>
1988 <term><varname>AssertMemoryPressure=
</varname></term>
1989 <term><varname>AssertCPUPressure=
</varname></term>
1990 <term><varname>AssertIOPressure=
</varname></term>
1992 <listitem><para>Similar to the
<varname>ConditionArchitecture=
</varname>,
1993 <varname>ConditionVirtualization=
</varname>, …, condition settings described above, these settings
1994 add assertion checks to the start-up of the unit. However, unlike the conditions settings, any
1995 assertion setting that is not met results in failure of the start job (which means this is logged
1996 loudly). Note that hitting a configured assertion does not cause the unit to enter the
1997 <literal>failed
</literal> state (or in fact result in any state change of the unit), it affects
1998 only the job queued for it. Use assertion expressions for units that cannot operate when specific
1999 requirements are not met, and when this is something the administrator or user should look
2002 <xi:include href=
"version-info.xml" xpointer=
"v218"/>
2010 <title>Mapping of unit properties to their inverses
</title>
2012 <para>Unit settings that create a relationship with a second unit usually show up
2013 in properties of both units, for example in
<command>systemctl show
</command>
2014 output. In some cases the name of the property is the same as the name of the
2015 configuration setting, but not always. This table lists the properties
2016 that are shown on two units which are connected through some dependency, and shows
2017 which property on
"source" unit corresponds to which property on the
"target" unit.
2022 "Forward" and
"reverse" unit properties
2026 <colspec colname='forward'
/>
2027 <colspec colname='reverse'
/>
2028 <colspec colname='fuse'
/>
2029 <colspec colname='ruse'
/>
2032 <entry>"Forward" property
</entry>
2033 <entry>"Reverse" property
</entry>
2034 <entry namest='fuse' nameend='ruse' valign='middle'
>Where used
</entry>
2039 <entry><varname>Before=
</varname></entry>
2040 <entry><varname>After=
</varname></entry>
2041 <entry morerows='
1' namest='fuse' nameend='ruse' valign='middle'
>[Unit] section
</entry>
2044 <entry><varname>After=
</varname></entry>
2045 <entry><varname>Before=
</varname></entry>
2048 <entry><varname>Requires=
</varname></entry>
2049 <entry><varname>RequiredBy=
</varname></entry>
2050 <entry>[Unit] section
</entry>
2051 <entry>[Install] section
</entry>
2054 <entry><varname>Wants=
</varname></entry>
2055 <entry><varname>WantedBy=
</varname></entry>
2056 <entry>[Unit] section
</entry>
2057 <entry>[Install] section
</entry>
2060 <entry><varname>Upholds=
</varname></entry>
2061 <entry><varname>UpheldBy=
</varname></entry>
2062 <entry>[Unit] section
</entry>
2063 <entry>[Install] section
</entry>
2066 <entry><varname>PartOf=
</varname></entry>
2067 <entry><varname>ConsistsOf=
</varname></entry>
2068 <entry>[Unit] section
</entry>
2069 <entry>an automatic property
</entry>
2072 <entry><varname>BindsTo=
</varname></entry>
2073 <entry><varname>BoundBy=
</varname></entry>
2074 <entry>[Unit] section
</entry>
2075 <entry>an automatic property
</entry>
2078 <entry><varname>Requisite=
</varname></entry>
2079 <entry><varname>RequisiteOf=
</varname></entry>
2080 <entry>[Unit] section
</entry>
2081 <entry>an automatic property
</entry>
2084 <entry><varname>Conflicts=
</varname></entry>
2085 <entry><varname>ConflictedBy=
</varname></entry>
2086 <entry>[Unit] section
</entry>
2087 <entry>an automatic property
</entry>
2090 <entry><varname>Triggers=
</varname></entry>
2091 <entry><varname>TriggeredBy=
</varname></entry>
2092 <entry namest='fuse' nameend='ruse' valign='middle'
>Automatic properties, see notes below
</entry>
2095 <entry><varname>PropagatesReloadTo=
</varname></entry>
2096 <entry><varname>ReloadPropagatedFrom=
</varname></entry>
2097 <entry morerows='
1' namest='fuse' nameend='ruse' valign='middle'
>[Unit] section
</entry>
2100 <entry><varname>ReloadPropagatedFrom=
</varname></entry>
2101 <entry><varname>PropagatesReloadTo=
</varname></entry>
2104 <entry><varname>PropagatesStopTo=
</varname></entry>
2105 <entry><varname>StopPropagatedFrom=
</varname></entry>
2106 <entry morerows='
1' namest='fuse' nameend='ruse' valign='middle'
>[Unit] section
</entry>
2109 <entry><varname>StopPropagatedFrom=
</varname></entry>
2110 <entry><varname>PropagatesStopTo=
</varname></entry>
2113 <entry><varname>Following=
</varname></entry>
2115 <entry>An automatic property
</entry>
2121 <para>Note:
<varname>WantedBy=
</varname>,
<varname>RequiredBy=
</varname>, and
<varname>UpheldBy=
</varname>
2122 are used in the [Install] section to create symlinks in
<filename>.wants/
</filename>,
2123 <filename>.requires/
</filename>, and
<filename>.upholds/
</filename> directories. They cannot be used
2124 directly as a unit configuration setting.
</para>
2126 <para>Note:
<varname>ConsistsOf=
</varname>,
<varname>BoundBy=
</varname>,
2127 <varname>RequisiteOf=
</varname>,
<varname>ConflictedBy=
</varname> are created
2128 implicitly along with their reverses and cannot be specified directly.
</para>
2130 <para>Note:
<varname>Triggers=
</varname> is created implicitly between a socket,
2131 path unit, or an automount unit, and the unit they activate. By default a unit
2132 with the same name is triggered, but this can be overridden using
2133 <varname>Sockets=
</varname>,
<varname>Service=
</varname>, and
<varname>Unit=
</varname>
2135 <citerefentry><refentrytitle>systemd.service
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2136 <citerefentry><refentrytitle>systemd.socket
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2137 <citerefentry><refentrytitle>systemd.path
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2139 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
2140 for details.
<varname>TriggeredBy=
</varname> is created implicitly on the
2141 triggered unit.
</para>
2143 <para>Note:
<varname>Following=
</varname> is used to group device aliases and points to the
2144 "primary" device unit that systemd is using to track device state, usually corresponding to a
2145 sysfs path. It does not show up in the
"target" unit.
</para>
2149 <title>[Install] Section Options
</title>
2151 <para>Unit files may include an [Install] section, which carries installation information for
2152 the unit. This section is not interpreted by
2153 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry> during runtime; it is
2154 used by the
<command>enable
</command> and
<command>disable
</command> commands of the
2155 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool during
2156 installation of a unit.
</para>
2158 <variablelist class='unit-directives'
>
2160 <term><varname>Alias=
</varname></term>
2162 <listitem><para>A space-separated list of additional names this unit shall be installed under. The names listed
2163 here must have the same suffix (i.e. type) as the unit filename. This option may be specified more than once,
2164 in which case all listed names are used. At installation time,
<command>systemctl enable
</command> will create
2165 symlinks from these names to the unit filename. Note that not all unit types support such alias names, and this
2166 setting is not supported for them. Specifically, mount, slice, swap, and automount units do not support
2169 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
2173 <term><varname>WantedBy=
</varname></term>
2174 <term><varname>RequiredBy=
</varname></term>
2175 <term><varname>UpheldBy=
</varname></term>
2177 <listitem><para>This option may be used more than once, or a space-separated list of unit names may
2178 be given. A symbolic link is created in the
<filename>.wants/
</filename>,
<filename>.requires/
</filename>,
2179 or
<filename>.upholds/
</filename> directory of each of the listed units when this unit is installed
2180 by
<command>systemctl enable
</command>. This has the effect of a dependency of type
2181 <varname>Wants=
</varname>,
<varname>Requires=
</varname>, or
<varname>Upholds=
</varname> being added
2182 from the listed unit to the current unit. See the description of the mentioned dependency types
2183 in the [Unit] section for details.
</para>
2185 <para>In case of template units listing non template units, the listing unit must have
2186 <varname>DefaultInstance=
</varname> set, or
<command>systemctl enable
</command> must be called with
2187 an instance name. The instance (default or specified) will be added to the
2188 <filename>.wants/
</filename>,
<filename>.requires/
</filename>, or
<filename>.upholds/
</filename>
2189 list of the listed unit. For example,
<command>WantedBy=getty.target
</command> in a service
2190 <filename>getty@.service
</filename> will result in
<command>systemctl enable getty@tty2.service
</command>
2191 creating a
<filename>getty.target.wants/getty@tty2.service
</filename> link to
2192 <filename>getty@.service
</filename>. This also applies to listing specific instances of templated
2193 units: this specific instance will gain the dependency. A template unit may also list a template
2194 unit, in which case a generic dependency will be added where each instance of the listing unit will
2195 have a dependency on an instance of the listed template with the same instance value. For example,
2196 <command>WantedBy=container@.target
</command> in a service
<filename>monitor@.service
</filename> will
2197 result in
<command>systemctl enable monitor@.service
</command> creating a
2198 <filename>container@.target.wants/monitor@.service
</filename> link to
2199 <filename>monitor@.service
</filename>, which applies to all instances of
2200 <filename>container@.target
</filename>.
</para>
2202 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
2206 <term><varname>Also=
</varname></term>
2208 <listitem><para>Additional units to install/deinstall when
2209 this unit is installed/deinstalled. If the user requests
2210 installation/deinstallation of a unit with this option
2211 configured,
<command>systemctl enable
</command> and
2212 <command>systemctl disable
</command> will automatically
2213 install/uninstall units listed in this option as well.
</para>
2215 <para>This option may be used more than once, or a
2216 space-separated list of unit names may be
2219 <xi:include href=
"version-info.xml" xpointer=
"v201"/></listitem>
2223 <term><varname>DefaultInstance=
</varname></term>
2225 <listitem><para>In template unit files, this specifies for
2226 which instance the unit shall be enabled if the template is
2227 enabled without any explicitly set instance. This option has
2228 no effect in non-template unit files. The specified string
2229 must be usable as instance identifier.
</para>
2231 <xi:include href=
"version-info.xml" xpointer=
"v215"/></listitem>
2235 <para>The following specifiers are interpreted in the Install section:
2236 %a, %b, %B, %g, %G, %H, %i, %j, %l, %m, %n, %N, %o, %p, %u, %U, %v, %w, %W, %%.
2237 For their meaning see the next section.
</para>
2241 <title>Specifiers
</title>
2243 <para>Many settings resolve specifiers which may be used to write
2244 generic unit files referring to runtime or unit parameters that
2245 are replaced when the unit files are loaded. Specifiers must be known
2246 and resolvable for the setting to be valid. The following
2247 specifiers are understood:
</para>
2249 <table class='specifiers'
>
2250 <title>Specifiers available in unit files
</title>
2251 <tgroup cols='
3' align='left' colsep='
1' rowsep='
1'
>
2252 <colspec colname=
"spec" />
2253 <colspec colname=
"mean" />
2254 <colspec colname=
"detail" />
2257 <entry>Specifier
</entry>
2258 <entry>Meaning
</entry>
2259 <entry>Details
</entry>
2264 <!-- We do not use the common definition from standard-specifiers.xml here since it includes a
2265 reference onto our own man page, which would make the rendered version self-referential. -->
2266 <entry><literal>%a
</literal></entry>
2267 <entry>Architecture
</entry>
2268 <entry>A short string identifying the architecture of the local system. A string such as
<constant>x86
</constant>,
<constant>x86-
64</constant> or
<constant>arm64
</constant>. See the architectures defined for
<varname>ConditionArchitecture=
</varname> above for a full list.
</entry>
2270 <xi:include href=
"standard-specifiers.xml" xpointer=
"A"/>
2271 <xi:include href=
"standard-specifiers.xml" xpointer=
"b"/>
2272 <xi:include href=
"standard-specifiers.xml" xpointer=
"B"/>
2274 <entry><literal>%C
</literal></entry>
2275 <entry>Cache directory root
</entry>
2276 <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>
2279 <entry><literal>%d
</literal></entry>
2280 <entry>Credentials directory
</entry>
2281 <entry>This is the value of the
<literal>$CREDENTIALS_DIRECTORY
</literal> environment variable if available. See section
"Credentials" in
<citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.
</entry>
2284 <entry><literal>%E
</literal></entry>
2285 <entry>Configuration directory root
</entry>
2286 <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>
2289 <entry><literal>%f
</literal></entry>
2290 <entry>Unescaped filename
</entry>
2291 <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>
2294 <entry><literal>%g
</literal></entry>
2295 <entry>User group
</entry>
2296 <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>
2299 <entry><literal>%G
</literal></entry>
2300 <entry>User GID
</entry>
2301 <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>
2304 <entry><literal>%h
</literal></entry>
2305 <entry>User home directory
</entry>
2306 <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>.
2308 Note that this setting is
<emphasis>not
</emphasis> influenced by the
<varname>User=
</varname> setting configurable in the [Service] section of the service unit.
</entry>
2311 <!-- We do not use the common definition from standard-specifiers.xml here since we want a
2312 slightly more verbose explanation here, referring to the reload cycle. -->
2313 <entry><literal>%H
</literal></entry>
2314 <entry>Host name
</entry>
2315 <entry>The hostname of the running system at the point in time the unit configuration is loaded.
</entry>
2318 <entry><literal>%i
</literal></entry>
2319 <entry>Instance name
</entry>
2320 <entry>For instantiated units this is the string between the first
<literal>@
</literal> character and the type suffix. Empty for non-instantiated units.
</entry>
2323 <entry><literal>%I
</literal></entry>
2324 <entry>Unescaped instance name
</entry>
2325 <entry>Same as
<literal>%i
</literal>, but with escaping undone.
</entry>
2328 <entry><literal>%j
</literal></entry>
2329 <entry>Final component of the prefix
</entry>
2330 <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>
2333 <entry><literal>%J
</literal></entry>
2334 <entry>Unescaped final component of the prefix
</entry>
2335 <entry>Same as
<literal>%j
</literal>, but with escaping undone.
</entry>
2338 <entry><literal>%l
</literal></entry>
2339 <!-- We do not use the common definition from standard-specifiers.xml here since we want a
2340 slightly more verbose explanation here, referring to the reload cycle. -->
2341 <entry>Short host name
</entry>
2342 <entry>The hostname of the running system at the point in time the unit configuration is loaded, truncated at the first dot to remove any domain component.
</entry>
2345 <entry><literal>%L
</literal></entry>
2346 <entry>Log directory root
</entry>
2347 <entry>This is either
<filename>/var/log
</filename> (for the system manager) or the path
<varname>$XDG_STATE_HOME
</varname> resolves to with
<filename index=
"false">/log
</filename> appended (for user managers).
</entry>
2349 <xi:include href=
"standard-specifiers.xml" xpointer=
"m"/>
2350 <xi:include href=
"standard-specifiers.xml" xpointer=
"M"/>
2352 <entry><literal>%n
</literal></entry>
2353 <entry>Full unit name
</entry>
2357 <entry><literal>%N
</literal></entry>
2358 <entry>Full unit name
</entry>
2359 <entry>Same as
<literal>%n
</literal>, but with the type suffix removed.
</entry>
2361 <xi:include href=
"standard-specifiers.xml" xpointer=
"o"/>
2363 <entry><literal>%p
</literal></entry>
2364 <entry>Prefix name
</entry>
2365 <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>
2368 <entry><literal>%P
</literal></entry>
2369 <entry>Unescaped prefix name
</entry>
2370 <entry>Same as
<literal>%p
</literal>, but with escaping undone.
</entry>
2373 <!-- We do not use the common definition from standard-specifiers.xml here since we want a
2374 slightly more verbose explanation here, referring to the reload cycle. -->
2375 <entry><literal>%q
</literal></entry>
2376 <entry>Pretty host name
</entry>
2377 <entry>The pretty hostname of the running system at the point in time the unit configuration is loaded, as read from the
<varname>PRETTY_HOSTNAME=
</varname> field of
<filename>/etc/machine-info
</filename>. If not set, resolves to the short hostname. See
<citerefentry><refentrytitle>machine-info
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.
</entry>
2380 <entry><literal>%s
</literal></entry>
2381 <entry>User shell
</entry>
2382 <entry>This is the shell of the user running the service manager instance.
</entry>
2385 <entry><literal>%S
</literal></entry>
2386 <entry>State directory root
</entry>
2387 <entry>This is either
<filename>/var/lib
</filename> (for the system manager) or the path
<varname>$XDG_STATE_HOME
</varname> resolves to (for user managers).
</entry>
2390 <entry><literal>%t
</literal></entry>
2391 <entry>Runtime directory root
</entry>
2392 <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>
2394 <xi:include href=
"standard-specifiers.xml" xpointer=
"T"/>
2396 <entry><literal>%u
</literal></entry>
2397 <entry>User name
</entry>
2398 <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>.
2400 Note that this setting is
<emphasis>not
</emphasis> influenced by the
<varname>User=
</varname> setting configurable in the [Service] section of the service unit.
</entry>
2403 <entry><literal>%U
</literal></entry>
2404 <entry>User UID
</entry>
2405 <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>.
2407 Note that this setting is
<emphasis>not
</emphasis> influenced by the
<varname>User=
</varname> setting configurable in the [Service] section of the service unit.
</entry>
2409 <xi:include href=
"standard-specifiers.xml" xpointer=
"v"/>
2410 <xi:include href=
"standard-specifiers.xml" xpointer=
"V"/>
2411 <xi:include href=
"standard-specifiers.xml" xpointer=
"w"/>
2412 <xi:include href=
"standard-specifiers.xml" xpointer=
"W"/>
2414 <entry><literal>%y
</literal></entry>
2415 <entry>The path to the fragment
</entry>
2416 <entry>This is the path where the main part of the unit file is located. For linked unit files, the real path outside of the unit search directories is used. For units that don't have a fragment file, this specifier will raise an error.
</entry>
2419 <entry><literal>%Y
</literal></entry>
2420 <entry>The directory of the fragment
</entry>
2421 <entry>This is the directory part of
<literal>%y
</literal>.
</entry>
2423 <xi:include href=
"standard-specifiers.xml" xpointer=
"percent"/>
2430 <title>Examples
</title>
2433 <title>Allowing units to be enabled
</title>
2435 <para>The following snippet (highlighted) allows a unit (e.g.
2436 <filename>foo.service
</filename>) to be enabled via
2437 <command>systemctl enable
</command>:
</para>
2439 <programlisting>[Unit]
2443 ExecStart=/usr/sbin/foo-daemon
2445 <emphasis>[Install]
</emphasis>
2446 <emphasis>WantedBy=multi-user.target
</emphasis></programlisting>
2448 <para>After running
<command>systemctl enable
</command>, a
2450 <filename index=
"false">/etc/systemd/system/multi-user.target.wants/foo.service
</filename>
2451 linking to the actual unit will be created. It tells systemd to
2452 pull in the unit when starting
2453 <filename>multi-user.target
</filename>. The inverse
2454 <command>systemctl disable
</command> will remove that symlink
2459 <title>Overriding vendor settings
</title>
2461 <para>There are two methods of overriding vendor settings in
2462 unit files: copying the unit file from
2463 <filename>/usr/lib/systemd/system
</filename> to
2464 <filename>/etc/systemd/system
</filename> and modifying the
2465 chosen settings. Alternatively, one can create a directory named
2466 <filename><replaceable>unit
</replaceable>.d/
</filename> within
2467 <filename>/etc/systemd/system
</filename> and place a drop-in
2468 file
<filename><replaceable>name
</replaceable>.conf
</filename>
2469 there that only changes the specific settings one is interested
2470 in. Note that multiple such drop-in files are read if
2471 present, processed in lexicographic order of their filename.
</para>
2473 <para>The advantage of the first method is that one easily
2474 overrides the complete unit, the vendor unit is not parsed at
2475 all anymore. It has the disadvantage that improvements to the
2476 unit file by the vendor are not automatically incorporated on
2479 <para>The advantage of the second method is that one only
2480 overrides the settings one specifically wants, where updates to
2481 the unit by the vendor automatically apply. This has the
2482 disadvantage that some future updates by the vendor might be
2483 incompatible with the local changes.
</para>
2485 <para>This also applies for user instances of systemd, but with
2486 different locations for the unit files. See the section on unit
2487 load paths for further details.
</para>
2489 <para>Suppose there is a vendor-supplied unit
2490 <filename>/usr/lib/systemd/system/httpd.service
</filename> with
2491 the following contents:
</para>
2493 <programlisting>[Unit]
2494 Description=Some HTTP server
2495 After=remote-fs.target sqldb.service
2496 Requires=sqldb.service
2497 AssertPathExists=/srv/webserver
2501 ExecStart=/usr/sbin/some-fancy-httpd-server
2505 WantedBy=multi-user.target
</programlisting>
2507 <para>Now one wants to change some settings as an administrator:
2508 firstly, in the local setup,
<filename>/srv/webserver
</filename>
2509 might not exist, because the HTTP server is configured to use
2510 <filename>/srv/www
</filename> instead. Secondly, the local
2511 configuration makes the HTTP server also depend on a memory
2512 cache service,
<filename>memcached.service
</filename>, that
2513 should be pulled in (
<varname>Requires=
</varname>) and also be
2514 ordered appropriately (
<varname>After=
</varname>). Thirdly, in
2515 order to harden the service a bit more, the administrator would
2516 like to set the
<varname>PrivateTmp=
</varname> setting (see
2517 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
2518 for details). And lastly, the administrator would like to reset
2519 the niceness of the service to its default value of
0.
</para>
2521 <para>The first possibility is to copy the unit file to
2522 <filename>/etc/systemd/system/httpd.service
</filename> and
2523 change the chosen settings:
</para>
2525 <programlisting>[Unit]
2526 Description=Some HTTP server
2527 After=remote-fs.target sqldb.service
<emphasis>memcached.service
</emphasis>
2528 Requires=sqldb.service
<emphasis>memcached.service
</emphasis>
2529 AssertPathExists=
<emphasis>/srv/www
</emphasis>
2533 ExecStart=/usr/sbin/some-fancy-httpd-server
2534 <emphasis>Nice=
0</emphasis>
2535 <emphasis>PrivateTmp=yes
</emphasis>
2538 WantedBy=multi-user.target
</programlisting>
2540 <para>Alternatively, the administrator could create a drop-in
2542 <filename>/etc/systemd/system/httpd.service.d/local.conf
</filename>
2543 with the following contents:
</para>
2545 <programlisting>[Unit]
2546 After=memcached.service
2547 Requires=memcached.service
2548 # Reset all assertions and then re-add the condition we want
2550 AssertPathExists=/srv/www
2554 PrivateTmp=yes
</programlisting>
2556 <para>Note that for drop-in files, if one wants to remove
2557 entries from a setting that is parsed as a list (and is not a
2558 dependency), such as
<varname>AssertPathExists=
</varname> (or
2559 e.g.
<varname>ExecStart=
</varname> in service units), one needs
2560 to first clear the list before re-adding all entries except the
2561 one that is to be removed. Dependencies (
<varname>After=
</varname>, etc.)
2562 cannot be reset to an empty list, so dependencies can only be
2563 added in drop-ins. If you want to remove dependencies, you have
2564 to override the entire unit.
</para>
2569 <title>Top level drop-ins with template units
</title>
2571 <para>Top level per-type drop-ins can be used to change some aspect of
2572 all units of a particular type. For example, by creating the
2573 <filename index='false'
>/etc/systemd/system/service.d/
</filename>
2574 directory with a drop-in file, the contents of the drop-in file can be
2575 applied to all service units. We can take this further by having the
2576 top-level drop-in instantiate a secondary helper unit. Consider for
2577 example the following set of units and drop-in files where we install
2578 an
<varname>OnFailure=
</varname> dependency for all service units.
</para>
2581 <filename index='false'
>/etc/systemd/system/failure-handler@.service
</filename>:
</para>
2583 <programlisting>[Unit]
2584 Description=My failure handler for %i
2588 # Perform some special action for when %i exits unexpectedly.
2589 ExecStart=/usr/sbin/myfailurehandler %i
2592 <para>We can then add an instance of
2593 <filename index='false'
>failure-handler@.service
</filename> as an
2594 <varname>OnFailure=
</varname> dependency for all service units.
</para>
2597 <filename index='false'
>/etc/systemd/system/service.d/
10-all.conf
</filename>:
</para>
2599 <programlisting>[Unit]
2600 OnFailure=failure-handler@%N.service
2603 <para>Now, after running
<command>systemctl daemon-reload
</command> all
2604 services will have acquired an
<varname>OnFailure=
</varname> dependency on
2605 <filename index='false'
>failure-handler@%N.service
</filename>. The
2606 template instance units will also have gained the dependency which results
2607 in the creation of a recursive dependency chain. systemd will try to detect
2608 these recursive dependency chains where a template unit directly and
2609 recursively depends on itself and will remove such dependencies
2610 automatically if it finds them. If systemd doesn't detect the recursive
2611 dependency chain, we can break the chain ourselves by disabling the drop-in
2612 for the template instance units via a symlink to
2613 <filename index='false'
>/dev/null
</filename>:
</para>
2616 <command>mkdir /etc/systemd/system/failure-handler@.service.d/
</command>
2617 <command>ln -s /dev/null /etc/systemd/system/failure-handler@.service.d/
10-all.conf
</command>
2618 <command>systemctl daemon-reload
</command>
2621 <para>This ensures that if a
<filename index='false'
>failure-handler@.service
</filename> instance fails it will not trigger an instance named
2622 <filename index='false'
>failure-handler@failure-handler.service
</filename>.
</para>
2629 <title>See Also
</title>
2631 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
2632 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
2633 <citerefentry><refentrytitle>systemd-system.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2634 <citerefentry><refentrytitle>systemd.special
</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
2635 <citerefentry><refentrytitle>systemd.service
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2636 <citerefentry><refentrytitle>systemd.socket
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2637 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2638 <citerefentry><refentrytitle>systemd.mount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2639 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2640 <citerefentry><refentrytitle>systemd.swap
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2641 <citerefentry><refentrytitle>systemd.target
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2642 <citerefentry><refentrytitle>systemd.path
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2643 <citerefentry><refentrytitle>systemd.timer
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2644 <citerefentry><refentrytitle>systemd.scope
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2645 <citerefentry><refentrytitle>systemd.slice
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
2646 <citerefentry><refentrytitle>systemd.time
</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
2647 <citerefentry><refentrytitle>systemd-analyze
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
2648 <citerefentry project='man-pages'
><refentrytitle>capabilities
</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
2649 <citerefentry><refentrytitle>systemd.directives
</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
2650 <citerefentry project='man-pages'
><refentrytitle>uname
</refentrytitle><manvolnum>1</manvolnum></citerefentry>