Debian Codegraph @

upstream/fedora-44/man5/systemd.unit.5

raw
1 '\" t
2 .TH "SYSTEMD\&.UNIT" "5" "" "systemd 259.5" "systemd.unit"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 systemd.unit \- Unit configuration
24 .SH "SYNOPSIS"
25 .PP
26 \fIservice\fR\&.service, \fIsocket\fR\&.socket, \fIdevice\fR\&.device, \fImount\fR\&.mount, \fIautomount\fR\&.automount, \fIswap\fR\&.swap, \fItarget\fR\&.target, \fIpath\fR\&.path, \fItimer\fR\&.timer, \fIslice\fR\&.slice, \fIscope\fR\&.scope
27 .SS "System Unit Search Path"
28 .PP
29 .RS 4
30 /etc/systemd/system\&.control/*
31 .RE
32 .RS 4
33 /run/systemd/system\&.control/*
34 .RE
35 .RS 4
36 /run/systemd/transient/*
37 .RE
38 .RS 4
39 /run/systemd/generator\&.early/*
40 .RE
41 .RS 4
42 /etc/systemd/system/*
43 .RE
44 .RS 4
45 /etc/systemd/system\&.attached/*
46 .RE
47 .RS 4
48 /run/systemd/system/*
49 .RE
50 .RS 4
51 /run/systemd/system\&.attached/*
52 .RE
53 .RS 4
54 /run/systemd/generator/*
55 .RE
56 .RS 4
57 \&...
58 .RE
59 .RS 4
60 /usr/local/lib/systemd/system/*
61 .RE
62 .RS 4
63 /usr/lib/systemd/system/*
64 .RE
65 .RS 4
66 /run/systemd/generator\&.late/*
67 .RE
68 .SS "User Unit Search Path"
69 .PP
70 .RS 4
71 ~/\&.config/systemd/user\&.control/*
72 .RE
73 .RS 4
74 $XDG_RUNTIME_DIR/systemd/user\&.control/*
75 .RE
76 .RS 4
77 $XDG_RUNTIME_DIR/systemd/transient/*
78 .RE
79 .RS 4
80 $XDG_RUNTIME_DIR/systemd/generator\&.early/*
81 .RE
82 .RS 4
83 ~/\&.config/systemd/user/*
84 .RE
85 .RS 4
86 $XDG_CONFIG_DIRS/systemd/user/*
87 .RE
88 .RS 4
89 /etc/systemd/user/*
90 .RE
91 .RS 4
92 $XDG_RUNTIME_DIR/systemd/user/*
93 .RE
94 .RS 4
95 /run/systemd/user/*
96 .RE
97 .RS 4
98 $XDG_RUNTIME_DIR/systemd/generator/*
99 .RE
100 .RS 4
101 $XDG_DATA_HOME/systemd/user/*
102 .RE
103 .RS 4
104 $XDG_DATA_DIRS/systemd/user/*
105 .RE
106 .RS 4
107 \&...
108 .RE
109 .RS 4
110 /usr/local/lib/systemd/user/*
111 .RE
112 .RS 4
113 /usr/lib/systemd/user/*
114 .RE
115 .RS 4
116 $XDG_RUNTIME_DIR/systemd/generator\&.late/*
117 .RE
118 .SH "DESCRIPTION"
119 .PP
120 A unit file is a plain text ini\-style file that encodes information about a service, a socket, a device, a mount point, an automount point, a swap file or partition, a start\-up target, a watched file system path, a timer controlled and supervised by
121 \fBsystemd\fR(1), a resource management slice or a group of externally created processes\&. See
122 \fBsystemd.syntax\fR(7)
123 for a general description of the syntax\&.
124 .PP
125 This man page lists the common configuration options of all the unit types\&. These options need to be configured in the [Unit] or [Install] sections of the unit files\&.
126 .PP
127 In addition to the generic [Unit] and [Install] sections described here, each unit may have a type\-specific section, e\&.g\&. [Service] for a service unit\&. See the respective man pages for more information:
128 \fBsystemd.service\fR(5),
129 \fBsystemd.socket\fR(5),
130 \fBsystemd.device\fR(5),
131 \fBsystemd.mount\fR(5),
132 \fBsystemd.automount\fR(5),
133 \fBsystemd.swap\fR(5),
134 \fBsystemd.target\fR(5),
135 \fBsystemd.path\fR(5),
136 \fBsystemd.timer\fR(5),
137 \fBsystemd.slice\fR(5),
138 \fBsystemd.scope\fR(5)\&.
139 .PP
140 Unit files are loaded from a set of paths determined during compilation, described in the next section\&.
141 .PP
142 Valid unit names consist of a "unit name prefix", and a suffix specifying the unit type which begins with a dot\&. The "unit name prefix" must consist of one or more valid characters (ASCII letters, digits,
143 ":",
144 "\-",
145 "_",
146 "\&.", and
147 "\e")\&. The total length of the unit name including the suffix must not exceed 255 characters\&. The unit type suffix must be one of
148 "\&.service",
149 "\&.socket",
150 "\&.device",
151 "\&.mount",
152 "\&.automount",
153 "\&.swap",
154 "\&.target",
155 "\&.path",
156 "\&.timer",
157 "\&.slice", or
158 "\&.scope"\&.
159 .PP
160 Unit names can be parameterized by a single argument called the "instance name"\&. The unit is then constructed based on a "template file" which serves as the definition of multiple services or other units\&. A template unit must have a single
161 "@"
162 at the end of the unit name prefix (right before the type suffix)\&. The name of the full unit is formed by inserting the instance name between
163 "@"
164 and the unit type suffix\&. In the unit file itself, the instance parameter may be referred to using
165 "%i"
166 and other specifiers, see below\&.
167 .PP
168 Unit files may contain additional options on top of those listed here\&. If systemd encounters an unknown option, it will write a warning log message but continue loading the unit\&. If an option or section name is prefixed with
169 \fBX\-\fR, it is ignored completely by systemd\&. Options within an ignored section do not need the prefix\&. Applications may use this to include additional information in the unit files\&. To access those options, applications need to parse the unit files on their own\&.
170 .PP
171 Units can be aliased (have an alternative name), by creating a symlink from the new name to the existing name in one of the unit search paths\&. For example,
172 systemd\-networkd\&.service
173 has the alias
174 dbus\-org\&.freedesktop\&.network1\&.service, created during installation as a symlink, so when
175 \fBsystemd\fR
176 is asked through D\-Bus to load
177 dbus\-org\&.freedesktop\&.network1\&.service, it\*(Aqll load
178 systemd\-networkd\&.service\&. As another example,
179 default\&.target
180 \(em the default system target started at boot \(em is commonly aliased to either
181 multi\-user\&.target
182 or
183 graphical\&.target
184 to select what is started by default\&. Alias names may be used in commands like
185 \fBdisable\fR,
186 \fBstart\fR,
187 \fBstop\fR,
188 \fBstatus\fR, and similar, and in all unit dependency directives, including
189 \fIWants=\fR,
190 \fIRequires=\fR,
191 \fIBefore=\fR,
192 \fIAfter=\fR\&. Aliases cannot be used with the
193 \fBpreset\fR
194 command\&.
195 .PP
196 Aliases obey the following restrictions: a unit of a certain type ("\&.service",
197 "\&.socket", \&...) can only be aliased by a name with the same type suffix\&. A plain unit (not a template or an instance), may only be aliased by a plain name\&. A template instance may only be aliased by another template instance, and the instance part must be identical\&. A template may be aliased by another template (in which case the alias applies to all instances of the template)\&. As a special case, a template instance (e\&.g\&.
198 "alias@inst\&.service") may be a symlink to different template (e\&.g\&.
199 "template@inst\&.service")\&. In that case, just this specific instance is aliased, while other instances of the template (e\&.g\&.
200 "alias@foo\&.service",
201 "alias@bar\&.service") are not aliased\&. Those rules preserve the requirement that the instance (if any) is always uniquely defined for a given unit and all its aliases\&. The target of alias symlink must point to a valid unit file location, i\&.e\&. the symlink target name must match the symlink source name as described, and the destination path must be in one of the unit search paths, see UNIT FILE LOAD PATH section below for more details\&. Note that the target file might not exist, i\&.e\&. the symlink may be dangling\&.
202 .PP
203 Unit files may specify aliases through the
204 \fIAlias=\fR
205 directive in the [Install] section\&. When the unit is enabled, symlinks will be created for those names, and removed when the unit is disabled\&. For example,
206 reboot\&.target
207 specifies
208 \fIAlias=ctrl\-alt\-del\&.target\fR, so when enabled, the symlink
209 /etc/systemd/system/ctrl\-alt\-del\&.target
210 pointing to the
211 reboot\&.target
212 file will be created, and when
213 Ctrl+Alt+Del
214 is invoked,
215 \fBsystemd\fR
216 will look for
217 ctrl\-alt\-del\&.target, follow the symlink to
218 reboot\&.target, and execute
219 reboot\&.service
220 as part of that target\&.
221 \fBsystemd\fR
222 does not look at the [Install] section at all during normal operation, so any directives in that section only have an effect through the symlinks created during enablement\&.
223 .PP
224 Along with a unit file
225 foo\&.service, the directory
226 foo\&.service\&.wants/
227 may exist\&. All unit files symlinked from such a directory are implicitly added as dependencies of type
228 \fIWants=\fR
229 to the unit\&. Similar functionality exists for
230 \fIRequires=\fR
231 type dependencies as well, the directory suffix is
232 \&.requires/
233 in this case\&. This functionality is useful to hook units into the start\-up of other units, without having to modify their unit files\&. For details about the semantics of
234 \fIWants=\fR
235 and
236 \fIRequires=\fR, see below\&. The preferred way to create symlinks in the
237 \&.wants/
238 or
239 \&.requires/
240 directories is by specifying the dependency in [Install] section of the target unit, and creating the symlink in the file system with the
241 \fBenable\fR
242 or
243 \fBpreset\fR
244 commands of
245 \fBsystemctl\fR(1)\&. The target can be a normal unit (either plain or a specific instance of a template unit)\&. In case when the source unit is a template, the target can also be a template, in which case the instance will be "propagated" to the target unit to form a valid unit instance\&. The target of symlinks in
246 \&.wants/
247 or
248 \&.requires/
249 must thus point to a valid unit file location, i\&.e\&. the symlink target name must satisfy the described requirements, and the destination path must be in one of the unit search paths, see UNIT FILE LOAD PATH section below for more details\&. Note that the target file might not exist, i\&.e\&. the symlink may be dangling\&.
250 .PP
251 Along with a unit file
252 foo\&.service, a "drop\-in" directory
253 foo\&.service\&.d/
254 may exist\&. All files with the suffix
255 "\&.conf"
256 from this directory will be merged in the alphanumeric order and parsed after the main unit file itself has been parsed\&. This is useful to alter or add configuration settings for a unit, without having to modify unit files\&. Each drop\-in file must contain appropriate section headers\&. For instantiated units, this logic will first look for the instance
257 "\&.d/"
258 subdirectory (e\&.g\&.
259 "foo@bar\&.service\&.d/") and read its
260 "\&.conf"
261 files, followed by the template
262 "\&.d/"
263 subdirectory (e\&.g\&.
264 "foo@\&.service\&.d/") and the
265 "\&.conf"
266 files there\&. Moreover, for unit names containing dashes ("\-"), the set of directories generated by repeatedly truncating the unit name after all dashes is searched too\&. Specifically, for a unit name
267 foo\-bar\-baz\&.service
268 not only the regular drop\-in directory
269 foo\-bar\-baz\&.service\&.d/
270 is searched but also both
271 foo\-bar\-\&.service\&.d/
272 and
273 foo\-\&.service\&.d/\&. This is useful for defining common drop\-ins for a set of related units, whose names begin with a common prefix\&. This scheme is particularly useful for mount, automount and slice units, whose systematic naming structure is built around dashes as component separators\&. Note that equally named drop\-in files further down the prefix hierarchy override those further up, i\&.e\&.
274 foo\-bar\-\&.service\&.d/10\-override\&.conf
275 overrides
276 foo\-\&.service\&.d/10\-override\&.conf\&.
277 .PP
278 In cases of unit aliases (described above), dropins for the aliased name and all aliases are loaded\&. In the example of
279 default\&.target
280 aliasing
281 graphical\&.target,
282 default\&.target\&.d/,
283 default\&.target\&.wants/,
284 default\&.target\&.requires/,
285 graphical\&.target\&.d/,
286 graphical\&.target\&.wants/,
287 graphical\&.target\&.requires/
288 would all be read\&. For templates, dropins for the template, any template aliases, the template instance, and all alias instances are read\&. When just a specific template instance is aliased, then the dropins for the target template, the target template instance, and the alias template instance are read\&.
289 .PP
290 In addition to
291 /etc/systemd/system, the drop\-in
292 "\&.d/"
293 directories for system services can be placed in
294 /usr/lib/systemd/system
295 or
296 /run/systemd/system
297 directories\&. Drop\-in files in
298 /etc/
299 take precedence over those in
300 /run/
301 which in turn take precedence over those in
302 /usr/lib/\&. Drop\-in files under any of these directories take precedence over unit files wherever located\&. Multiple drop\-in files with different names are applied in lexicographic order, regardless of which of the directories they reside in\&.
303 .PP
304 Units also support a top\-level drop\-in with
305 \fItype\fR\&.d/, where
306 \fItype\fR
307 may be e\&.g\&.
308 "service"
309 or
310 "socket", that allows altering or adding to the settings of all corresponding unit files on the system\&. The formatting and precedence of applying drop\-in configurations follow what is defined above\&. Files in
311 \fItype\fR\&.d/
312 have lower precedence compared to files in name\-specific override directories\&. The usual rules apply: multiple drop\-in files with different names are applied in lexicographic order, regardless of which of the directories they reside in, so a file in
313 \fItype\fR\&.d/
314 applies to a unit only if there are no drop\-ins or masks with that name in directories with higher precedence\&. See Examples\&.
315 .PP
316 Note that while systemd offers a flexible dependency system between units it is recommended to use this functionality only sparingly and instead rely on techniques such as bus\-based or socket\-based activation which make dependencies implicit, resulting in a both simpler and more flexible system\&.
317 .PP
318 As mentioned above, a unit may be instantiated from a template file\&. This allows creation of multiple units from a single configuration file\&. If systemd looks for a unit configuration file, it will first search for the literal unit name in the file system\&. If that yields no success and the unit name contains an
319 "@"
320 character, systemd will look for a unit template that shares the same name but with the instance string (i\&.e\&. the part between the
321 "@"
322 character and the suffix) removed\&. Example: if a service
323 getty@tty3\&.service
324 is requested and no file by that name is found, systemd will look for
325 getty@\&.service
326 and instantiate a service from that configuration file if it is found\&.
327 .PP
328 To refer to the instance string from within the configuration file you may use the special
329 "%i"
330 specifier in many of the configuration options\&. See below for details\&.
331 .PP
332 If a unit file is empty (i\&.e\&. has the file size 0) or is symlinked to
333 /dev/null, its configuration will not be loaded and it appears with a load state of
334 "masked", and cannot be activated\&. Use this as an effective way to fully disable a unit, making it impossible to start it even manually\&.
335 .PP
336 Files (including directories) with names that match certain patterns are generally ignored\&. This includes names that start with a
337 "\&."
338 or end with a
339 "\&.ignore"\&.
340 .PP
341 The unit file format is covered by the
342 \m[blue]\fBInterface Portability and Stability Promise\fR\m[]\&\s-2\u[1]\d\s+2\&.
343 .SH "STRING ESCAPING FOR INCLUSION IN UNIT NAMES"
344 .PP
345 Sometimes it is useful to convert arbitrary strings into unit names\&. To facilitate this, a method of string escaping is used, in order to map strings containing arbitrary byte values (except
346 \fBNUL\fR) into valid unit names and their restricted character set\&. A common special case are unit names that reflect paths to objects in the file system hierarchy\&. Example: a device unit
347 dev\-sda\&.device
348 refers to a device with the device node
349 /dev/sda
350 in the file system\&.
351 .PP
352 The escaping algorithm operates as follows: given a string, any
353 "/"
354 character is replaced by
355 "\-", and all other characters which are not ASCII alphanumerics,
356 ":",
357 "_"
358 or
359 "\&."
360 are replaced by C\-style
361 "\ex2d"
362 escapes\&. In addition,
363 "\&."
364 is replaced with such a C\-style escape when it would appear as the first character in the escaped string\&.
365 .PP
366 When the input qualifies as absolute file system path, this algorithm is extended slightly: the path to the root directory
367 "/"
368 is encoded as single dash
369 "\-"\&. In addition, any leading, trailing or duplicate
370 "/"
371 characters are removed from the string before transformation\&. Example:
372 /foo//bar/baz/
373 becomes
374 "foo\-bar\-baz"\&.
375 .PP
376 This escaping is fully reversible, as long as it is known whether the escaped string was a path (the unescaping results are different for paths and non\-path strings)\&. The
377 \fBsystemd-escape\fR(1)
378 command may be used to apply and reverse escaping on arbitrary strings\&. Use
379 \fBsystemd\-escape \-\-path\fR
380 to escape path strings, and
381 \fBsystemd\-escape\fR
382 without
383 \fB\-\-path\fR
384 otherwise\&.
385 .SH "AUTOMATIC DEPENDENCIES"
386 .SS "Implicit Dependencies"
387 .PP
388 A number of unit dependencies are implicitly established, depending on unit type and unit configuration\&. These implicit dependencies can make unit configuration file cleaner\&. For the implicit dependencies in each unit type, please refer to section "Implicit Dependencies" in respective man pages\&.
389 .PP
390 For example, service units with
391 \fIType=dbus\fR
392 automatically acquire dependencies of type
393 \fIRequires=\fR
394 and
395 \fIAfter=\fR
396 on
397 dbus\&.socket\&. See
398 \fBsystemd.service\fR(5)
399 for details\&.
400 .SS "Default Dependencies"
401 .PP
402 Default dependencies are similar to implicit dependencies, but can be turned on and off by setting
403 \fIDefaultDependencies=\fR
404 to
405 \fIyes\fR
406 (the default) and
407 \fIno\fR, while implicit dependencies are always in effect\&. See section "Default Dependencies" in respective man pages for the effect of enabling
408 \fIDefaultDependencies=\fR
409 in each unit types\&.
410 .PP
411 For example, target units will complement all configured dependencies of type
412 \fIWants=\fR
413 or
414 \fIRequires=\fR
415 with dependencies of type
416 \fIAfter=\fR\&. See
417 \fBsystemd.target\fR(5)
418 for details\&. Note that this behavior can be opted out by setting
419 \fIDefaultDependencies=no\fR
420 in the specified units, or it can be selectively overridden via an explicit
421 \fIBefore=\fR
422 dependency\&.
423 .SH "UNIT FILE LOAD PATH"
424 .PP
425 Unit files are loaded from a set of paths determined during compilation, described in the two tables below\&. Unit files found in directories listed earlier override files with the same name in directories lower in the list
426 \&\s-2\u[2]\d\s+2\&.
427 .PP
428 When the variable
429 \fI$SYSTEMD_UNIT_PATH\fR
430 is set, the contents of this variable overrides the unit load path\&. If
431 \fI$SYSTEMD_UNIT_PATH\fR
432 ends with an empty component (":"), the usual unit load path will be appended to the contents of the variable\&.
433 .sp
434 .it 1 an-trap
435 .nr an-no-space-flag 1
436 .nr an-break-flag 1
437 .br
438 .B Table\ \&1.\ \& Load path when running in system mode (\-\-system)\&.
439 .TS
440 allbox tab(:);
441 lB lB.
442 T{
443 Path
444 T}:T{
445 Description
446 T}
447 .T&
448 l l
449 l ^
450 l l
451 l l
452 l l
453 l l
454 l l
455 l l
456 l l
457 l l.
458 T{
459 /etc/systemd/system\&.control
460 T}:T{
461 Persistent and transient configuration created using the dbus API
462 T}
463 T{
464 /run/systemd/system\&.control
465 T}:
466 T{
467 /run/systemd/transient
468 T}:T{
469 Dynamic configuration for transient units
470 T}
471 T{
472 /run/systemd/generator\&.early
473 T}:T{
474 Generated units with high priority (see \fIearly\-dir\fR in \fBsystemd.generator\fR(7))
475 T}
476 T{
477 /etc/systemd/system
478 T}:T{
479 System units created by the administrator
480 T}
481 T{
482 /run/systemd/system
483 T}:T{
484 Runtime units
485 T}
486 T{
487 /run/systemd/generator
488 T}:T{
489 Generated units with medium priority (see \fInormal\-dir\fR in \fBsystemd.generator\fR(7))
490 T}
491 T{
492 /usr/local/lib/systemd/system
493 T}:T{
494 System units installed by the administrator
495 T}
496 T{
497 /usr/lib/systemd/system
498 T}:T{
499 System units installed by the distribution package manager
500 T}
501 T{
502 /run/systemd/generator\&.late
503 T}:T{
504 Generated units with low priority (see \fIlate\-dir\fR in \fBsystemd.generator\fR(7))
505 T}
506 .TE
507 .sp 1
508 .sp
509 .it 1 an-trap
510 .nr an-no-space-flag 1
511 .nr an-break-flag 1
512 .br
513 .B Table\ \&2.\ \& Load path when running in user mode (\-\-user)\&.
514 .TS
515 allbox tab(:);
516 lB lB.
517 T{
518 Path
519 T}:T{
520 Description
521 T}
522 .T&
523 l l
524 l ^
525 l l
526 l l
527 l l
528 l l
529 l l
530 l l
531 l l
532 l l
533 l l
534 l l
535 l l
536 l l
537 l l
538 l l.
539 T{
540 $XDG_CONFIG_HOME/systemd/user\&.control or ~/\&.config/systemd/user\&.control
541 T}:T{
542 Persistent and transient configuration created using the dbus API (\fI$XDG_CONFIG_HOME\fR is used if set, ~/\&.config otherwise)
543 T}
544 T{
545 $XDG_RUNTIME_DIR/systemd/user\&.control
546 T}:
547 T{
548 $XDG_RUNTIME_DIR/systemd/transient
549 T}:T{
550 Dynamic configuration for transient units
551 T}
552 T{
553 $XDG_RUNTIME_DIR/systemd/generator\&.early
554 T}:T{
555 Generated units with high priority (see \fIearly\-dir\fR in \fBsystemd.generator\fR(7))
556 T}
557 T{
558 $XDG_CONFIG_HOME/systemd/user or $HOME/\&.config/systemd/user
559 T}:T{
560 User configuration (\fI$XDG_CONFIG_HOME\fR is used if set, ~/\&.config otherwise)
561 T}
562 T{
563 $XDG_CONFIG_DIRS/systemd/user or /etc/xdg/systemd/user
564 T}:T{
565 Additional configuration directories as specified by the XDG base directory specification (\fI$XDG_CONFIG_DIRS\fR is used if set, /etc/xdg otherwise)
566 T}
567 T{
568 /etc/systemd/user
569 T}:T{
570 User units created by the administrator
571 T}
572 T{
573 $XDG_RUNTIME_DIR/systemd/user
574 T}:T{
575 Runtime units (only used when $XDG_RUNTIME_DIR is set)
576 T}
577 T{
578 /run/systemd/user
579 T}:T{
580 Runtime units
581 T}
582 T{
583 $XDG_RUNTIME_DIR/systemd/generator
584 T}:T{
585 Generated units with medium priority (see \fInormal\-dir\fR in \fBsystemd.generator\fR(7))
586 T}
587 T{
588 $XDG_DATA_HOME/systemd/user or $HOME/\&.local/share/systemd/user
589 T}:T{
590 Units of packages that have been installed in the home directory (\fI$XDG_DATA_HOME\fR is used if set, ~/\&.local/share otherwise)
591 T}
592 T{
593 $XDG_DATA_DIRS/systemd/user or /usr/local/share/systemd/user and /usr/share/systemd/user
594 T}:T{
595 Additional data directories as specified by the XDG base directory specification (\fI$XDG_DATA_DIRS\fR is used if set, /usr/local/share and /usr/share otherwise)
596 T}
597 T{
598 $dir/systemd/user for each \fI$dir\fR in \fI$XDG_DATA_DIRS\fR
599 T}:T{
600 Additional locations for installed user units, one for each entry in \fI$XDG_DATA_DIRS\fR
601 T}
602 T{
603 /usr/local/lib/systemd/user
604 T}:T{
605 User units installed by the administrator
606 T}
607 T{
608 /usr/lib/systemd/user
609 T}:T{
610 User units installed by the distribution package manager
611 T}
612 T{
613 $XDG_RUNTIME_DIR/systemd/generator\&.late
614 T}:T{
615 Generated units with low priority (see \fIlate\-dir\fR in \fBsystemd.generator\fR(7))
616 T}
617 .TE
618 .sp 1
619 .PP
620 The set of load paths for the user manager instance may be augmented or changed using various environment variables\&. And environment variables may in turn be set using environment generators, see
621 \fBsystemd.environment-generator\fR(7)\&. In particular,
622 \fI$XDG_DATA_HOME\fR
623 and
624 \fI$XDG_DATA_DIRS\fR
625 may be easily set using
626 \fBsystemd-environment-d-generator\fR(8)\&. Thus, directories listed here are just the defaults\&. To see the actual list that would be used based on compilation options and current environment use
627 .sp
628 .if n \{\
629 .RS 4
630 .\}
631 .nf
632 systemd\-analyze \-\-user unit\-paths
633 .fi
634 .if n \{\
635 .RE
636 .\}
637 .PP
638 Moreover, additional units might be loaded into systemd from directories not on the unit load path by creating a symlink pointing to a unit file in the directories\&. You can use
639 \fBsystemctl link\fR
640 for this; see
641 \fBsystemctl\fR(1)\&. The file system where the linked unit files are located must be accessible when systemd is started (e\&.g\&. anything underneath
642 /home/
643 or
644 /var/
645 is not allowed, unless those directories are located on the root file system)\&.
646 .PP
647 It is important to distinguish "linked unit files" from "unit file aliases": any symlink where the symlink
648 \fItarget\fR
649 is within the unit load path becomes an alias: the source name and the target file name must satisfy specific constraints listed above in the discussion of aliases, but the symlink target does not have to exist, and in fact the symlink target path is not used, except to check whether the target is within the unit load path\&. In contrast, a symlink which goes outside of the unit load path signifies a linked unit file\&. The symlink is followed when loading the file, but the destination name is otherwise unused (and may even not be a valid unit file name)\&. For example, symlinks
650 /etc/systemd/system/alias1\&.service
651 โ†’
652 service1\&.service,
653 /etc/systemd/system/alias2\&.service
654 โ†’
655 /usr/lib/systemd/service1\&.service,
656 /etc/systemd/system/alias3\&.service
657 โ†’
658 /etc/systemd/system/service1\&.service
659 are all valid aliases and
660 service1\&.service
661 will have four names, even if the unit file is located at
662 /run/systemd/system/service1\&.service\&. In contrast, a symlink
663 /etc/systemd/system/link1\&.service
664 โ†’
665 \&.\&./link1_service_file
666 means that
667 link1\&.service
668 is a "linked unit" and the contents of
669 /etc/systemd/link1_service_file
670 provide its configuration\&.
671 .SH "UNIT GARBAGE COLLECTION"
672 .PP
673 The system and service manager loads a unit\*(Aqs configuration automatically when a unit is referenced for the first time\&. It will automatically unload the unit configuration and state again when the unit is not needed anymore ("garbage collection")\&. A unit may be referenced through a number of different mechanisms:
674 .sp
675 .RS 4
676 .ie n \{\
677 \h'-04' 1.\h'+01'\c
678 .\}
679 .el \{\
680 .sp -1
681 .IP " 1." 4.2
682 .\}
683 Another loaded unit references it with a dependency such as
684 \fIAfter=\fR,
685 \fIWants=\fR, \&...
686 .RE
687 .sp
688 .RS 4
689 .ie n \{\
690 \h'-04' 2.\h'+01'\c
691 .\}
692 .el \{\
693 .sp -1
694 .IP " 2." 4.2
695 .\}
696 The unit is currently starting, running, reloading or stopping\&.
697 .RE
698 .sp
699 .RS 4
700 .ie n \{\
701 \h'-04' 3.\h'+01'\c
702 .\}
703 .el \{\
704 .sp -1
705 .IP " 3." 4.2
706 .\}
707 The unit is currently in the
708 \fBfailed\fR
709 state\&. (But see below\&.)
710 .RE
711 .sp
712 .RS 4
713 .ie n \{\
714 \h'-04' 4.\h'+01'\c
715 .\}
716 .el \{\
717 .sp -1
718 .IP " 4." 4.2
719 .\}
720 A job for the unit is pending\&.
721 .RE
722 .sp
723 .RS 4
724 .ie n \{\
725 \h'-04' 5.\h'+01'\c
726 .\}
727 .el \{\
728 .sp -1
729 .IP " 5." 4.2
730 .\}
731 The unit is pinned by an active IPC client program\&.
732 .RE
733 .sp
734 .RS 4
735 .ie n \{\
736 \h'-04' 6.\h'+01'\c
737 .\}
738 .el \{\
739 .sp -1
740 .IP " 6." 4.2
741 .\}
742 The unit is a special "perpetual" unit that is always active and loaded\&. Examples for perpetual units are the root mount unit
743 \-\&.mount
744 or the scope unit
745 init\&.scope
746 that the service manager itself lives in\&.
747 .RE
748 .sp
749 .RS 4
750 .ie n \{\
751 \h'-04' 7.\h'+01'\c
752 .\}
753 .el \{\
754 .sp -1
755 .IP " 7." 4.2
756 .\}
757 The unit has running processes associated with it\&.
758 .RE
759 .PP
760 The garbage collection logic may be altered with the
761 \fICollectMode=\fR
762 option, which allows configuration whether automatic unloading of units that are in
763 \fBfailed\fR
764 state is permissible, see below\&.
765 .PP
766 Note that when a unit\*(Aqs configuration and state is unloaded, all execution results, such as exit codes, exit signals, resource consumption and other statistics are lost, except for what is stored in the log subsystem\&.
767 .PP
768 Use
769 \fBsystemctl daemon\-reload\fR
770 or an equivalent command to reload unit configuration while the unit is already loaded\&. In this case, all configuration settings are flushed out and replaced with the new configuration (which however might not be in effect immediately), however all runtime state is saved/restored\&.
771 .SH "[UNIT] SECTION OPTIONS"
772 .PP
773 The unit file may include a [Unit] section, which carries generic information about the unit that is not dependent on the type of unit:
774 .PP
775 \fIDescription=\fR
776 .RS 4
777 A brief, meaningful, human\-readable text identifying the unit\&. This may be used by
778 \fBsystemd\fR
779 (and suitable UIs) as a user\-visible label for the unit, so this string should identify the unit rather than just describe it, despite the name\&. This string also should not just repeat the unit name\&.
780 "Apache HTTP Server"
781 or
782 "Postfix Mail Server"
783 are good examples\&. Bad examples are
784 "high\-performance lightweight HTTP server"
785 (too generic) or
786 "Apache"
787 (meaningless for people who do not know the Apache HTTP server project, duplicates the unit name)\&.
788 \fBsystemd\fR
789 may use this string as a noun in status messages ("Starting \fIDescription\fR\&.\&.\&.",
790 "Started \fIDescription\fR\&.",
791 "Reached target \fIDescription\fR\&.",
792 "Failed to start \fIDescription\fR\&."), so it should be capitalized, and should not be a full sentence, or a phrase with a verb conjugated in the present continuous, or end in a full stop\&. Bad examples include
793 "exiting the container",
794 "updating the database once per day\&.", or
795 "OpenSSH server second instance daemon"\&.
796 .sp
797 Added in version 201\&.
798 .RE
799 .PP
800 \fIDocumentation=\fR
801 .RS 4
802 A space\-separated list of URIs referencing documentation for this unit or its configuration\&. Accepted are only URIs of the types
803 "http://",
804 "https://",
805 "file:",
806 "info:",
807 "man:"\&. For more information about the syntax of these URIs, see
808 \fBuri\fR(7)\&. The URIs should be listed in order of relevance, starting with the most relevant\&. It is a good idea to first reference documentation that explains what the unit\*(Aqs purpose is, followed by how it is configured, followed by any other related documentation\&. This option may be specified more than once, in which case the specified list of URIs is merged\&. If the empty string is assigned to this option, the list is reset and all prior assignments will have no effect\&.
809 .sp
810 Added in version 201\&.
811 .RE
812 .PP
813 \fIWants=\fR
814 .RS 4
815 Configures (weak) requirement dependencies on other units\&. This option may be specified more than once or multiple space\-separated units may be specified in one option in which case dependencies for all listed names will be created\&. Dependencies of this type may also be configured outside of the unit configuration file by adding a symlink to a
816 \&.wants/
817 directory accompanying the unit file\&. For details, see above\&.
818 .sp
819 Units listed in this option will be started if the configuring unit is\&. However, if the listed units fail to start or cannot be added to the transaction, this has no impact on the validity of the transaction as a whole, and this unit will still be started\&. This is the recommended way to hook the start\-up of one unit to the start\-up of another unit\&.
820 .sp
821 Note that requirement dependencies do not influence the order in which services are started or stopped\&. This has to be configured independently with the
822 \fIAfter=\fR
823 or
824 \fIBefore=\fR
825 options\&. If unit
826 foo\&.service
827 pulls in unit
828 bar\&.service
829 as configured with
830 \fIWants=\fR
831 and no ordering is configured with
832 \fIAfter=\fR
833 or
834 \fIBefore=\fR, then both units will be started simultaneously and without any delay between them if
835 foo\&.service
836 is activated\&.
837 .sp
838 Added in version 201\&.
839 .RE
840 .PP
841 \fIRequires=\fR
842 .RS 4
843 Similar to
844 \fIWants=\fR, but declares a stronger requirement dependency\&. Dependencies of this type may also be configured by adding a symlink to a
845 \&.requires/
846 directory accompanying the unit file\&.
847 .sp
848 If this unit gets activated, the units listed will be activated as well\&. If one of the other units fails to activate, and an ordering dependency
849 \fIAfter=\fR
850 on the failing unit is set, this unit will not be started\&. Besides, with or without specifying
851 \fIAfter=\fR, this unit will be stopped (or restarted) if one of the other units is explicitly stopped (or restarted)\&.
852 .sp
853 Often, it is a better choice to use
854 \fIWants=\fR
855 instead of
856 \fIRequires=\fR
857 in order to achieve a system that is more robust when dealing with failing services\&.
858 .sp
859 Note that this dependency type does not imply that the other unit always has to be in active state when this unit is running\&. Specifically: failing condition checks (such as
860 \fIConditionPathExists=\fR,
861 \fIConditionPathIsSymbolicLink=\fR, \&... \(em see below) do not cause the start job of a unit with a
862 \fIRequires=\fR
863 dependency on it to fail\&. Also, some unit types may deactivate on their own (for example, a service process may decide to exit cleanly, or a device may be unplugged by the user), which is not propagated to units having a
864 \fIRequires=\fR
865 dependency\&. Use the
866 \fIBindsTo=\fR
867 dependency type together with
868 \fIAfter=\fR
869 to ensure that a unit may never be in active state without a specific other unit also in active state (see below)\&.
870 .sp
871 Added in version 201\&.
872 .RE
873 .PP
874 \fIRequisite=\fR
875 .RS 4
876 Similar to
877 \fIRequires=\fR\&. However, if the units listed here are not started already, they will not be started and the starting of this unit will fail immediately\&.
878 \fIRequisite=\fR
879 does not imply an ordering dependency, even if both units are started in the same transaction\&. Hence this setting should usually be combined with
880 \fIAfter=\fR, to ensure this unit is not started before the other unit\&.
881 .sp
882 When
883 \fIRequisite=b\&.service\fR
884 is used on
885 a\&.service, this dependency will show as
886 \fIRequisiteOf=a\&.service\fR
887 in property listing of
888 b\&.service\&.
889 \fIRequisiteOf=\fR
890 dependency cannot be specified directly\&.
891 .sp
892 Added in version 201\&.
893 .RE
894 .PP
895 \fIBindsTo=\fR
896 .RS 4
897 Configures requirement dependencies, very similar in style to
898 \fIRequires=\fR\&. However, this dependency type is stronger: in addition to the effects of
899 \fIRequires=\fR, which already stops (or restarts) the configuring unit when a listed unit is explicitly stopped (or restarted), it also does so when a listed unit stops unexpectedly (which includes when it fails)\&. Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of a mount unit might be unmounted without involvement of the system and service manager\&.
900 .sp
901 When used in conjunction with
902 \fIAfter=\fR
903 on the same unit the behaviour of
904 \fIBindsTo=\fR
905 is even stronger\&. In this case, the unit bound to strictly has to be in active state for this unit to also be in active state\&. This not only means a unit bound to another unit that suddenly enters inactive state, but also one that is bound to another unit that gets skipped due to an unmet condition check (such as
906 \fIConditionPathExists=\fR,
907 \fIConditionPathIsSymbolicLink=\fR, \&... \(em see below) will be stopped, should it be running\&. Hence, in many cases it is best to combine
908 \fIBindsTo=\fR
909 with
910 \fIAfter=\fR\&.
911 .sp
912 When
913 \fIBindsTo=b\&.service\fR
914 is used on
915 a\&.service, this dependency will show as
916 \fIBoundBy=a\&.service\fR
917 in property listing of
918 b\&.service\&.
919 \fIBoundBy=\fR
920 dependency cannot be specified directly\&.
921 .sp
922 Added in version 201\&.
923 .RE
924 .PP
925 \fIPartOf=\fR
926 .RS 4
927 Configures dependencies similar to
928 \fIRequires=\fR, but limited to stopping and restarting of units\&. When systemd stops or restarts the units listed here, the action is propagated to this unit\&. Note that this is a one\-way dependency\ \&\(em changes to this unit do not affect the listed units\&.
929 .sp
930 When
931 \fIPartOf=b\&.service\fR
932 is used on
933 a\&.service, this dependency will show as
934 \fIConsistsOf=a\&.service\fR
935 in property listing of
936 b\&.service\&.
937 \fIConsistsOf=\fR
938 dependency cannot be specified directly\&.
939 .sp
940 Added in version 201\&.
941 .RE
942 .PP
943 \fIUpholds=\fR
944 .RS 4
945 Configures dependencies similar to
946 \fIWants=\fR, but as long as this unit is up, all units listed in
947 \fIUpholds=\fR
948 are started whenever found to be inactive or failed, and no job is queued for them\&. While a
949 \fIWants=\fR
950 dependency on another unit has a one\-time effect when this units started, a
951 \fIUpholds=\fR
952 dependency on it has a continuous effect, constantly restarting the unit if necessary\&. This is an alternative to the
953 \fIRestart=\fR
954 setting of service units, to ensure they are kept running whatever happens\&. The restart happens without delay, and usual per\-unit rate\-limit applies\&.
955 .sp
956 When
957 \fIUpholds=b\&.service\fR
958 is used on
959 a\&.service, this dependency will show as
960 \fIUpheldBy=a\&.service\fR
961 in the property listing of
962 b\&.service\&.
963 .sp
964 Added in version 249\&.
965 .RE
966 .PP
967 \fIConflicts=\fR
968 .RS 4
969 A space\-separated list of unit names\&. Configures negative requirement dependencies\&. If a unit has a
970 \fIConflicts=\fR
971 requirement on a set of other units, then starting it will stop all of them and starting any of them will stop it\&.
972 .sp
973 Note that this setting does not imply an ordering dependency, similarly to the
974 \fIWants=\fR
975 and
976 \fIRequires=\fR
977 dependencies described above\&. This means that to ensure that the conflicting unit is stopped before the other unit is started, an
978 \fIAfter=\fR
979 or
980 \fIBefore=\fR
981 dependency must be declared\&. It does not matter which of the two ordering dependencies is used, because stop jobs are always ordered before start jobs, see the discussion in
982 \fIBefore=\fR/\fIAfter=\fR
983 below\&.
984 .sp
985 If unit A that conflicts with unit B is scheduled to be started at the same time as B, the transaction will either fail (in case both are required parts of the transaction) or be modified to be fixed (in case one or both jobs are not a required part of the transaction)\&. In the latter case, the job that is not required will be removed, or in case both are not required, the unit that conflicts will be started and the unit that is conflicted is stopped\&.
986 .sp
987 Added in version 201\&.
988 .RE
989 .PP
990 \fIBefore=\fR, \fIAfter=\fR
991 .RS 4
992 These two settings expect a space\-separated list of unit names\&. They may be specified more than once, in which case dependencies for all listed names are created\&.
993 .sp
994 Those two settings configure ordering dependencies between units\&. If unit
995 foo\&.service
996 contains the setting
997 \fBBefore=bar\&.service\fR
998 and both units are being started,
999 bar\&.service\*(Aqs start\-up is delayed until
1000 foo\&.service
1001 has finished starting up\&.
1002 \fIAfter=\fR
1003 is the inverse of
1004 \fIBefore=\fR, i\&.e\&. while
1005 \fIBefore=\fR
1006 ensures that the configured unit is started before the listed unit begins starting up,
1007 \fIAfter=\fR
1008 ensures the opposite, that the listed unit is fully started up before the configured unit is started\&.
1009 .sp
1010 When two units with an ordering dependency between them are shut down, the inverse of the start\-up order is applied\&. I\&.e\&. if a unit is configured with
1011 \fIAfter=\fR
1012 on another unit, the former is stopped before the latter if both are shut down\&. Given two units with any ordering dependency between them, if one unit is shut down and the other is started up, the shutdown is ordered before the start\-up\&. It does not matter if the ordering dependency is
1013 \fIAfter=\fR
1014 or
1015 \fIBefore=\fR, in this case\&. It also does not matter which of the two is shut down, as long as one is shut down and the other is started up; the shutdown is ordered before the start\-up in all cases\&. If two units have no ordering dependencies between them, they are shut down or started up simultaneously, and no ordering takes place\&. It depends on the unit type when precisely a unit has finished starting up\&. Most importantly, for service units start\-up is considered completed for the purpose of
1016 \fIBefore=\fR/\fIAfter=\fR
1017 when all its configured start\-up commands have been invoked and they either failed or reported start\-up success\&. Note that this includes
1018 \fIExecStartPost=\fR
1019 (or
1020 \fIExecStopPost=\fR
1021 for the shutdown case)\&.
1022 .sp
1023 Note that those settings are independent of and orthogonal to the requirement dependencies as configured by
1024 \fIRequires=\fR,
1025 \fIWants=\fR,
1026 \fIRequisite=\fR, or
1027 \fIBindsTo=\fR\&. It is a common pattern to include a unit name in both the
1028 \fIAfter=\fR
1029 and
1030 \fIWants=\fR
1031 options, in which case the unit listed will be started before the unit that is configured with these options\&.
1032 .sp
1033 Note that
1034 \fIBefore=\fR
1035 dependencies on device units have no effect and are not supported\&. Devices generally become available as a result of an external hotplug event, and systemd creates the corresponding device unit without delay\&.
1036 .sp
1037 Added in version 201\&.
1038 .RE
1039 .PP
1040 \fIOnFailure=\fR
1041 .RS 4
1042 A space\-separated list of one or more units that are activated when this unit enters the
1043 "failed"
1044 state\&.
1045 .sp
1046 Added in version 201\&.
1047 .RE
1048 .PP
1049 \fIOnSuccess=\fR
1050 .RS 4
1051 A space\-separated list of one or more units that are activated when this unit enters the
1052 "inactive"
1053 state\&.
1054 .sp
1055 Added in version 249\&.
1056 .RE
1057 .PP
1058 \fIPropagatesReloadTo=\fR, \fIReloadPropagatedFrom=\fR
1059 .RS 4
1060 A space\-separated list of one or more units to which reload requests from this unit shall be propagated to, or units from which reload requests shall be propagated to this unit, respectively\&. Issuing a reload request on a unit will automatically also enqueue reload requests on all units that are linked to it using these two settings\&.
1061 .sp
1062 Added in version 201\&.
1063 .RE
1064 .PP
1065 \fIPropagatesStopTo=\fR, \fIStopPropagatedFrom=\fR
1066 .RS 4
1067 A space\-separated list of one or more units to which stop requests from this unit shall be propagated to, or units from which stop requests shall be propagated to this unit, respectively\&. Issuing a stop request on a unit will automatically also enqueue stop requests on all units that are linked to it using these two settings\&.
1068 .sp
1069 Added in version 249\&.
1070 .RE
1071 .PP
1072 \fIJoinsNamespaceOf=\fR
1073 .RS 4
1074 For units that start processes (such as service units), lists one or more other units whose network and/or temporary file namespace to join\&. If this is specified on a unit (say,
1075 a\&.service
1076 has
1077 \fIJoinsNamespaceOf=b\&.service\fR), then the inverse dependency (\fIJoinsNamespaceOf=a\&.service\fR
1078 for b\&.service) is implied\&. This only applies to unit types which support the
1079 \fIPrivateNetwork=\fR,
1080 \fINetworkNamespacePath=\fR,
1081 \fIPrivateIPC=\fR,
1082 \fIIPCNamespacePath=\fR, and
1083 \fIPrivateTmp=\fR
1084 directives (see
1085 \fBsystemd.exec\fR(5)
1086 for details)\&. If a unit that has this setting set is started, its processes will see the same
1087 /tmp/,
1088 /var/tmp/, IPC namespace and network namespace as one listed unit that is started\&. If multiple listed units are already started and these do not share their namespace, then it is not defined which namespace is joined\&. Note that this setting only has an effect if
1089 \fIPrivateNetwork=\fR/\fINetworkNamespacePath=\fR,
1090 \fIPrivateIPC=\fR/\fIIPCNamespacePath=\fR
1091 and/or
1092 \fIPrivateTmp=\fR
1093 is enabled for both the unit that joins the namespace and the unit whose namespace is joined\&.
1094 .sp
1095 Added in version 209\&.
1096 .RE
1097 .PP
1098 \fIRequiresMountsFor=\fR
1099 .RS 4
1100 Takes a space\-separated list of absolute paths\&. Automatically adds dependencies of type
1101 \fIRequires=\fR
1102 and
1103 \fIAfter=\fR
1104 for all mount units required to access the specified path\&.
1105 .sp
1106 Mount points marked with
1107 \fBnoauto\fR
1108 are not mounted automatically through
1109 local\-fs\&.target, but are still honored for the purposes of this option, i\&.e\&. they will be pulled in by this unit\&.
1110 .sp
1111 Added in version 201\&.
1112 .RE
1113 .PP
1114 \fIWantsMountsFor=\fR
1115 .RS 4
1116 Same as
1117 \fIRequiresMountsFor=\fR, but adds dependencies of type
1118 \fIWants=\fR
1119 instead of
1120 \fIRequires=\fR\&.
1121 .sp
1122 Added in version 256\&.
1123 .RE
1124 .PP
1125 \fIOnSuccessJobMode=\fR, \fIOnFailureJobMode=\fR
1126 .RS 4
1127 Takes a value of
1128 "fail",
1129 "replace",
1130 "replace\-irreversibly",
1131 "isolate",
1132 "flush",
1133 "ignore\-dependencies"
1134 or
1135 "ignore\-requirements"\&. Defaults to
1136 "replace"\&. Specifies how the units listed in
1137 \fIOnSuccess=\fR/\fIOnFailure=\fR
1138 will be enqueued\&. See
1139 \fBsystemctl\fR(1)\*(Aqs
1140 \fB\-\-job\-mode=\fR
1141 option for details on the possible values\&. If this is set to
1142 "isolate", only a single unit may be listed in
1143 \fIOnSuccess=\fR/\fIOnFailure=\fR\&.
1144 .sp
1145 Added in version 209\&.
1146 .RE
1147 .PP
1148 \fIIgnoreOnIsolate=\fR
1149 .RS 4
1150 Takes a boolean argument\&. If
1151 \fBtrue\fR, this unit will not be stopped when isolating another unit\&. Defaults to
1152 \fBfalse\fR
1153 for service, target, socket, timer, and path units, and
1154 \fBtrue\fR
1155 for slice, scope, device, swap, mount, and automount units\&.
1156 .sp
1157 Added in version 201\&.
1158 .RE
1159 .PP
1160 \fIStopWhenUnneeded=\fR
1161 .RS 4
1162 Takes a boolean argument\&. If
1163 \fBtrue\fR, this unit will be stopped when it is no longer used\&. Note that, in order to minimize the work to be executed, systemd will not stop units by default unless they are conflicting with other units, or the user explicitly requested their shut down\&. If this option is set, a unit will be automatically cleaned up if no other active unit requires it\&. Defaults to
1164 \fBfalse\fR\&.
1165 .sp
1166 Added in version 201\&.
1167 .RE
1168 .PP
1169 \fIRefuseManualStart=\fR, \fIRefuseManualStop=\fR
1170 .RS 4
1171 Takes a boolean argument\&. If
1172 \fBtrue\fR, this unit can only be activated or deactivated indirectly\&. In this case, explicit start\-up or termination requested by the user is denied, however if it is started or stopped as a dependency of another unit, start\-up or termination will succeed\&. This is mostly a safety feature to ensure that the user does not accidentally activate units that are not intended to be activated explicitly, and not accidentally deactivate units that are not intended to be deactivated\&. These options default to
1173 \fBfalse\fR\&.
1174 .sp
1175 Added in version 201\&.
1176 .RE
1177 .PP
1178 \fIAllowIsolate=\fR
1179 .RS 4
1180 Takes a boolean argument\&. If
1181 \fBtrue\fR, this unit may be used with the
1182 \fBsystemctl isolate\fR
1183 command\&. Otherwise, this will be refused\&. It probably is a good idea to leave this disabled except for target units that shall be used similar to runlevels in SysV init systems, just as a precaution to avoid unusable system states\&. This option defaults to
1184 \fBfalse\fR\&.
1185 .sp
1186 Added in version 201\&.
1187 .RE
1188 .PP
1189 \fIDefaultDependencies=\fR
1190 .RS 4
1191 Takes a boolean argument\&. If
1192 \fByes\fR, (the default), a few default dependencies will implicitly be created for the unit\&. The actual dependencies created depend on the unit type\&. For example, for service units, these dependencies ensure that the service is started only after basic system initialization is completed and is properly terminated on system shutdown\&. See the respective man pages for details\&. Generally, only services involved with early boot or late shutdown should set this option to
1193 \fBno\fR\&. It is highly recommended to leave this option enabled for the majority of common units\&. If set to
1194 \fBno\fR, this option does not disable all implicit dependencies, just non\-essential ones\&.
1195 .sp
1196 Added in version 201\&.
1197 .RE
1198 .PP
1199 \fISurviveFinalKillSignal=\fR
1200 .RS 4
1201 Takes a boolean argument\&. Defaults to
1202 \fBno\fR\&. If
1203 \fByes\fR, processes belonging to this unit will not be sent the final
1204 "SIGTERM"
1205 and
1206 "SIGKILL"
1207 signals during the final phase of the system shutdown process\&. This functionality replaces the older mechanism that allowed a program to set
1208 "argv[0][0] = \*(Aq@\*(Aq"
1209 as described at
1210 \m[blue]\fBsystemd and Storage Daemons for the Root File System\fR\m[]\&\s-2\u[3]\d\s+2, which however continues to be supported\&.
1211 .sp
1212 Added in version 255\&.
1213 .RE
1214 .PP
1215 \fICollectMode=\fR
1216 .RS 4
1217 Tweaks the "garbage collection" algorithm for this unit\&. Takes one of
1218 \fBinactive\fR
1219 or
1220 \fBinactive\-or\-failed\fR\&. If set to
1221 \fBinactive\fR
1222 the unit will be unloaded if it is in the
1223 \fBinactive\fR
1224 state and is not referenced by clients, jobs or other units \(em however it is not unloaded if it is in the
1225 \fBfailed\fR
1226 state\&. In
1227 \fBfailed\fR
1228 mode, failed units are not unloaded until the user invoked
1229 \fBsystemctl reset\-failed\fR
1230 on them to reset the
1231 \fBfailed\fR
1232 state, or an equivalent command\&. This behaviour is altered if this option is set to
1233 \fBinactive\-or\-failed\fR: in this case, the unit is unloaded even if the unit is in a
1234 \fBfailed\fR
1235 state, and thus an explicitly resetting of the
1236 \fBfailed\fR
1237 state is not necessary\&. Note that if this mode is used unit results (such as exit codes, exit signals, consumed resources, \&...) are flushed out immediately after the unit completed, except for what is stored in the logging subsystem\&. Defaults to
1238 \fBinactive\fR\&.
1239 .sp
1240 Added in version 236\&.
1241 .RE
1242 .PP
1243 \fIFailureAction=\fR, \fISuccessAction=\fR
1244 .RS 4
1245 Configure the action to take when the unit stops and enters a failed state or inactive state\&. Takes one of
1246 \fBnone\fR,
1247 \fBreboot\fR,
1248 \fBreboot\-force\fR,
1249 \fBreboot\-immediate\fR,
1250 \fBpoweroff\fR,
1251 \fBpoweroff\-force\fR,
1252 \fBpoweroff\-immediate\fR,
1253 \fBexit\fR,
1254 \fBexit\-force\fR,
1255 \fBsoft\-reboot\fR,
1256 \fBsoft\-reboot\-force\fR,
1257 \fBkexec\fR,
1258 \fBkexec\-force\fR,
1259 \fBhalt\fR,
1260 \fBhalt\-force\fR
1261 and
1262 \fBhalt\-immediate\fR\&. In system mode, all options are allowed\&. In user mode, only
1263 \fBnone\fR,
1264 \fBexit\fR, and
1265 \fBexit\-force\fR
1266 are allowed\&. Both options default to
1267 \fBnone\fR\&.
1268 .sp
1269 If
1270 \fBnone\fR
1271 is set, no action will be triggered\&.
1272 \fBreboot\fR
1273 causes a reboot following the normal shutdown procedure (i\&.e\&. equivalent to
1274 \fBsystemctl reboot\fR)\&.
1275 \fBreboot\-force\fR
1276 causes a forced reboot which will terminate all processes forcibly but should cause no dirty file systems on reboot (i\&.e\&. equivalent to
1277 \fBsystemctl reboot \-f\fR) and
1278 \fBreboot\-immediate\fR
1279 causes immediate execution of the
1280 \fBreboot\fR(2)
1281 system call, which might result in data loss (i\&.e\&. equivalent to
1282 \fBsystemctl reboot \-ff\fR)\&. Similarly,
1283 \fBpoweroff\fR,
1284 \fBpoweroff\-force\fR,
1285 \fBpoweroff\-immediate\fR,
1286 \fBkexec\fR,
1287 \fBkexec\-force\fR,
1288 \fBhalt\fR,
1289 \fBhalt\-force\fR
1290 and
1291 \fBhalt\-immediate\fR
1292 have the effect of powering down the system, executing kexec, and halting the system respectively with similar semantics\&.
1293 \fBexit\fR
1294 causes the manager to exit following the normal shutdown procedure, and
1295 \fBexit\-force\fR
1296 causes it terminate without shutting down services\&. When
1297 \fBexit\fR
1298 or
1299 \fBexit\-force\fR
1300 is used by default the exit status of the main process of the unit (if this applies) is returned from the service manager\&. However, this may be overridden with
1301 \fIFailureActionExitStatus=\fR/\fISuccessActionExitStatus=\fR, see below\&.
1302 \fBsoft\-reboot\fR
1303 will trigger a userspace reboot operation\&.
1304 \fBsoft\-reboot\-force\fR
1305 does that too, but does not go through the shutdown transaction beforehand\&.
1306 .sp
1307 Added in version 236\&.
1308 .RE
1309 .PP
1310 \fIFailureActionExitStatus=\fR, \fISuccessActionExitStatus=\fR
1311 .RS 4
1312 Controls the exit status to propagate back to an invoking container manager (in case of a system service) or service manager (in case of a user manager) when the
1313 \fIFailureAction=\fR/\fISuccessAction=\fR
1314 are set to
1315 \fBexit\fR
1316 or
1317 \fBexit\-force\fR
1318 and the action is triggered\&. By default, the exit status of the main process of the triggering unit (if this applies) is propagated\&. Takes a value in the range 0\&...255 or the empty string to request default behaviour\&.
1319 .sp
1320 Added in version 240\&.
1321 .RE
1322 .PP
1323 \fIJobTimeoutSec=\fR, \fIJobRunningTimeoutSec=\fR
1324 .RS 4
1325 \fIJobTimeoutSec=\fR
1326 specifies a timeout for the whole job that starts running when the job is queued\&.
1327 \fIJobRunningTimeoutSec=\fR
1328 specifies a timeout that starts running when the queued job is actually started\&. If either limit is reached, the job will be cancelled, the unit however will not change state or even enter the
1329 "failed"
1330 mode\&.
1331 .sp
1332 Both settings take a time span with the default unit of seconds, but other units may be specified, see
1333 \fBsystemd.time\fR(7)\&. The default is
1334 "infinity"
1335 (job timeouts disabled), except for device units where
1336 \fIJobRunningTimeoutSec=\fR
1337 defaults to
1338 \fIDefaultDeviceTimeoutSec=\fR\&.
1339 .sp
1340 Note: these timeouts are independent from any unit\-specific timeouts (for example, the timeout set with
1341 \fITimeoutStartSec=\fR
1342 in service units)\&. The job timeout has no effect on the unit itself\&. Or in other words: unit\-specific timeouts are useful to abort unit state changes, and revert them\&. The job timeout set with this option however is useful to abort only the job waiting for the unit state to change\&.
1343 .sp
1344 Added in version 201\&.
1345 .RE
1346 .PP
1347 \fIJobTimeoutAction=\fR, \fIJobTimeoutRebootArgument=\fR
1348 .RS 4
1349 \fIJobTimeoutAction=\fR
1350 optionally configures an additional action to take when the timeout is hit, see description of
1351 \fIJobTimeoutSec=\fR
1352 and
1353 \fIJobRunningTimeoutSec=\fR
1354 above\&. It takes the same values as
1355 \fIFailureAction=\fR/\fISuccessAction=\fR\&. Defaults to
1356 \fBnone\fR\&.
1357 .sp
1358 \fIJobTimeoutRebootArgument=\fR
1359 configures an optional reboot string to pass to the
1360 \fBreboot\fR(2)
1361 system call\&.
1362 .sp
1363 Added in version 240\&.
1364 .RE
1365 .PP
1366 \fIStartLimitIntervalSec=\fR\fI\fIinterval\fR\fR, \fIStartLimitBurst=\fR\fI\fIburst\fR\fR
1367 .RS 4
1368 Configure unit start rate limiting\&. Units which are started more than
1369 \fIburst\fR
1370 times within an
1371 \fIinterval\fR
1372 time span are not permitted to start any more\&. Use
1373 \fIStartLimitIntervalSec=\fR
1374 to configure the checking interval and
1375 \fIStartLimitBurst=\fR
1376 to configure how many starts per interval are allowed\&.
1377 .sp
1378 \fIinterval\fR
1379 is a time span with the default unit of seconds, but other units may be specified, see
1380 \fBsystemd.time\fR(7)\&. The special value
1381 "infinity"
1382 can be used to limit the total number of start attempts, even if they happen at large time intervals\&. Defaults to
1383 \fIDefaultStartLimitIntervalSec=\fR
1384 in manager configuration file, and may be set to 0 to disable any kind of rate limiting\&.
1385 \fIburst\fR
1386 is a number and defaults to
1387 \fIDefaultStartLimitBurst=\fR
1388 in manager configuration file\&.
1389 .sp
1390 These configuration options are particularly useful in conjunction with the service setting
1391 \fIRestart=\fR
1392 (see
1393 \fBsystemd.service\fR(5)); however, they apply to all kinds of starts (including manual), not just those triggered by the
1394 \fIRestart=\fR
1395 logic\&.
1396 .sp
1397 Note that units which are configured for
1398 \fIRestart=\fR, and which reach the start limit are not attempted to be restarted anymore; however, they may still be restarted manually or from a timer or socket at a later point, after the
1399 \fIinterval\fR
1400 has passed\&. From that point on, the restart logic is activated again\&.
1401 \fBsystemctl reset\-failed\fR
1402 will cause the restart rate counter for a service to be flushed, which is useful if the administrator wants to manually start a unit and the start limit interferes with that\&. Rate\-limiting is enforced after any unit condition checks are executed, and hence unit activations with failing conditions do not count towards the rate limit\&.
1403 .sp
1404 When a unit is unloaded due to the garbage collection logic (see above) its rate limit counters are flushed out too\&. This means that configuring start rate limiting for a unit that is not referenced continuously has no effect\&.
1405 .sp
1406 This setting does not apply to slice, target, device, and scope units, since they are unit types whose activation may either never fail, or may succeed only a single time\&.
1407 .sp
1408 Added in version 229\&.
1409 .RE
1410 .PP
1411 \fIStartLimitAction=\fR
1412 .RS 4
1413 Configure an additional action to take if the rate limit configured with
1414 \fIStartLimitIntervalSec=\fR
1415 and
1416 \fIStartLimitBurst=\fR
1417 is hit\&. Takes the same values as the
1418 \fIFailureAction=\fR/\fISuccessAction=\fR
1419 settings\&. If
1420 \fBnone\fR
1421 is set, hitting the rate limit will trigger no action except that the start will not be permitted\&. Defaults to
1422 \fBnone\fR\&.
1423 .sp
1424 Added in version 229\&.
1425 .RE
1426 .PP
1427 \fIRebootArgument=\fR
1428 .RS 4
1429 Configure the optional argument for the
1430 \fBreboot\fR(2)
1431 system call if
1432 \fIStartLimitAction=\fR
1433 or
1434 \fIFailureAction=\fR
1435 is a reboot action\&. This works just like the optional argument to
1436 \fBsystemctl reboot\fR
1437 command\&.
1438 .sp
1439 Added in version 229\&.
1440 .RE
1441 .PP
1442 \fISourcePath=\fR
1443 .RS 4
1444 A path to a configuration file this unit has been generated from\&. This is primarily useful for implementation of generator tools that convert configuration from an external configuration file format into native unit files\&. This functionality should not be used in normal units\&.
1445 .sp
1446 Added in version 201\&.
1447 .RE
1448 .SS "Conditions and Asserts"
1449 .PP
1450 Unit files may also include a number of
1451 \fICondition\&...=\fR
1452 and
1453 \fIAssert\&...=\fR
1454 settings\&. Before the unit is started, systemd will verify that the specified conditions and asserts are true\&. If not, the starting of the unit will be (mostly silently) skipped (in case of conditions), or aborted with an error message (in case of asserts)\&. Failing conditions or asserts will not result in the unit being moved into the
1455 "failed"
1456 state\&. The conditions and asserts are checked at the time the queued start job is to be executed\&. The ordering dependencies are still respected, so other units are still pulled in and ordered as if this unit was successfully activated, and the conditions and asserts are executed the precise moment the unit would normally start and thus can validate system state after the units ordered before completed initialization\&. Use condition expressions for skipping units that do not apply to the local system, for example because the kernel or runtime environment does not require their functionality\&.
1457 .PP
1458 If multiple conditions are specified, the unit will be executed if all of them apply (i\&.e\&. a logical AND is applied)\&. Condition checks can use a pipe symbol ("|") after the equals sign ("Condition\&...=|\&..."), which causes the condition to become a
1459 \fItriggering\fR
1460 condition\&. If at least one triggering condition is defined for a unit, then the unit will be started if at least one of the triggering conditions of the unit applies and all of the regular (i\&.e\&. non\-triggering) conditions apply\&. If you prefix an argument with the pipe symbol and an exclamation mark, the pipe symbol must be passed first, the exclamation second\&. If any of these options is assigned the empty string, the list of conditions is reset completely, all previous condition settings (of any kind) will have no effect\&.
1461 .PP
1462 The
1463 \fIAssertArchitecture=\fR,
1464 \fIAssertVirtualization=\fR, \&... options are similar to conditions but cause the start job to fail (instead of being skipped)\&. The failed check is logged\&. Units with unmet conditions are considered to be in a clean state and will be garbage collected if they are not referenced\&. This means that when queried, the condition failure may or may not show up in the state of the unit\&.
1465 .PP
1466 Note that neither assertion nor condition expressions result in unit state changes\&. Also note that both are checked at the time the job is to be executed, i\&.e\&. long after depending jobs and it itself were queued\&. Thus, neither condition nor assertion expressions are suitable for conditionalizing unit dependencies\&.
1467 .PP
1468 The
1469 \fBcondition\fR
1470 verb of
1471 \fBsystemd-analyze\fR(1)
1472 can be used to test condition and assert expressions\&.
1473 .PP
1474 Except for
1475 \fIConditionPathIsSymbolicLink=\fR, all path checks follow symlinks\&.
1476 .PP
1477 \fIConditionArchitecture=\fR
1478 .RS 4
1479 Check whether the system is running on a specific architecture\&. Takes one of
1480 "x86",
1481 "x86\-64",
1482 "ppc",
1483 "ppc\-le",
1484 "ppc64",
1485 "ppc64\-le",
1486 "ia64",
1487 "parisc",
1488 "parisc64",
1489 "s390",
1490 "s390x",
1491 "sparc",
1492 "sparc64",
1493 "mips",
1494 "mips\-le",
1495 "mips64",
1496 "mips64\-le",
1497 "alpha",
1498 "arm",
1499 "arm\-be",
1500 "arm64",
1501 "arm64\-be",
1502 "sh",
1503 "sh64",
1504 "m68k",
1505 "tilegx",
1506 "cris",
1507 "arc",
1508 "arc\-be", or
1509 "native"\&.
1510 .sp
1511 Use
1512 \fBsystemd-analyze\fR(1)
1513 for the complete list of known architectures\&.
1514 .sp
1515 The architecture is determined from the information returned by
1516 \fBuname\fR(2)
1517 and is thus subject to
1518 \fBpersonality\fR(2)\&. Note that a
1519 \fIPersonality=\fR
1520 setting in the same unit file has no effect on this condition\&. A special architecture name
1521 "native"
1522 is mapped to the architecture the system manager itself is compiled for\&. The test may be negated by prepending an exclamation mark\&.
1523 .sp
1524 Added in version 201\&.
1525 .RE
1526 .PP
1527 \fIConditionFirmware=\fR
1528 .RS 4
1529 Check whether the system\*(Aqs firmware is of a certain type\&. The following values are possible:
1530 .sp
1531 .RS 4
1532 .ie n \{\
1533 \h'-04'\(bu\h'+03'\c
1534 .\}
1535 .el \{\
1536 .sp -1
1537 .IP \(bu 2.3
1538 .\}
1539 "uefi"
1540 matches systems with EFI\&.
1541 .RE
1542 .sp
1543 .RS 4
1544 .ie n \{\
1545 \h'-04'\(bu\h'+03'\c
1546 .\}
1547 .el \{\
1548 .sp -1
1549 .IP \(bu 2.3
1550 .\}
1551 "device\-tree"
1552 matches systems with a device tree\&.
1553 .RE
1554 .sp
1555 .RS 4
1556 .ie n \{\
1557 \h'-04'\(bu\h'+03'\c
1558 .\}
1559 .el \{\
1560 .sp -1
1561 .IP \(bu 2.3
1562 .\}
1563 "device\-tree\-compatible(\fIvalue\fR)"
1564 matches systems with a device tree that are compatible with
1565 "value"\&.
1566 .RE
1567 .sp
1568 .RS 4
1569 .ie n \{\
1570 \h'-04'\(bu\h'+03'\c
1571 .\}
1572 .el \{\
1573 .sp -1
1574 .IP \(bu 2.3
1575 .\}
1576 "smbios\-field(\fIfield\fR \fIoperator\fR \fIvalue\fR)"
1577 matches systems with a SMBIOS field containing a certain value\&.
1578 \fIfield\fR
1579 is the name of the SMBIOS field exposed as
1580 "sysfs"
1581 attribute file below
1582 /sys/class/dmi/id/\&.
1583 \fIoperator\fR
1584 is one of
1585 "<",
1586 "<=",
1587 ">=",
1588 ">",
1589 "==",
1590 "<>"
1591 for version comparisons,
1592 "="
1593 and
1594 "!="
1595 for literal string comparisons, or
1596 "$=",
1597 "!$="
1598 for shell\-style glob comparisons\&.
1599 \fIvalue\fR
1600 is the expected value of the SMBIOS field value (possibly containing shell style globs in case
1601 "$="/"!$="
1602 is used)\&.
1603 .RE
1604 .sp
1605 Added in version 249\&.
1606 .RE
1607 .PP
1608 \fIConditionVirtualization=\fR
1609 .RS 4
1610 Check whether the system is executed in a virtualized environment and optionally test whether it is a specific implementation\&. Takes either boolean value to check if being executed in any virtualized environment, or one of
1611 "vm"
1612 and
1613 "container"
1614 to test against a generic type of virtualization solution, or one of
1615 "qemu",
1616 "kvm",
1617 "amazon",
1618 "zvm",
1619 "vmware",
1620 "microsoft",
1621 "oracle",
1622 "powervm",
1623 "xen",
1624 "bochs",
1625 "uml",
1626 "bhyve",
1627 "qnx",
1628 "apple",
1629 "sre",
1630 "openvz",
1631 "lxc",
1632 "lxc\-libvirt",
1633 "systemd\-nspawn",
1634 "docker",
1635 "podman",
1636 "rkt",
1637 "wsl",
1638 "proot",
1639 "pouch",
1640 "acrn"
1641 to test against a specific implementation, or
1642 "private\-users"
1643 to check whether we are running in a user namespace\&. See
1644 \fBsystemd-detect-virt\fR(1)
1645 for a full list of known virtualization technologies and their identifiers\&. If multiple virtualization technologies are nested, only the innermost is considered\&. The test may be negated by prepending an exclamation mark\&.
1646 .sp
1647 Added in version 244\&.
1648 .RE
1649 .PP
1650 \fIConditionHost=\fR
1651 .RS 4
1652 \fIConditionHost=\fR
1653 may be used to match against the hostname, machine ID, boot ID or product UUID of the host\&. This either takes a hostname string (optionally with shell style globs) which is tested against the locally set hostname as returned by
1654 \fBgethostname\fR(2), or a 128bit ID or UUID, formatted as string\&. The latter is compared against machine ID, boot ID and the firmware product UUID if there is any\&. See
1655 \fBmachine-id\fR(5)
1656 for details about the machine ID\&. The test may be negated by prepending an exclamation mark\&.
1657 .sp
1658 Added in version 244\&.
1659 .RE
1660 .PP
1661 \fIConditionKernelCommandLine=\fR
1662 .RS 4
1663 \fIConditionKernelCommandLine=\fR
1664 may be used to check whether a specific kernel command line option is set (or if prefixed with the exclamation mark \(em unset)\&. The argument must either be a single word, or an assignment (i\&.e\&. two words, separated by
1665 "=")\&. In the former case the kernel command line is searched for the word appearing as is, or as left hand side of an assignment\&. In the latter case, the exact assignment is looked for with right and left hand side matching\&. This operates on the kernel command line communicated to userspace via
1666 /proc/cmdline, except when the service manager is invoked as payload of a container manager, in which case the command line of
1667 PID 1
1668 is used instead (i\&.e\&.
1669 /proc/1/cmdline)\&.
1670 .sp
1671 Added in version 244\&.
1672 .RE
1673 .PP
1674 \fIConditionKernelVersion=\fR
1675 .RS 4
1676 \fIConditionKernelVersion=\fR
1677 may be used to check whether the kernel version (as reported by
1678 \fBuname \-r\fR) matches a certain expression, or if prefixed with the exclamation mark, does not match\&. The argument must be a list of (potentially quoted) expressions\&. Each expression starts with one of
1679 "="
1680 or
1681 "!="
1682 for string comparisons,
1683 "<",
1684 "<=",
1685 "==",
1686 "<>",
1687 ">=",
1688 ">"
1689 for version comparisons, or
1690 "$=",
1691 "!$="
1692 for a shell\-style glob match\&. If no operator is specified,
1693 "$="
1694 is implied\&.
1695 .sp
1696 Note that using the kernel version string is an unreliable way to determine which features are supported by a kernel, because of the widespread practice of backporting drivers, features, and fixes from newer upstream kernels into older versions provided by distributions\&. Hence, this check is inherently unportable and should not be used for units which may be used on different distributions\&.
1697 .sp
1698 Added in version 244\&.
1699 .RE
1700 .PP
1701 \fIConditionVersion=\fR
1702 .RS 4
1703 \fIConditionVersion=\fR
1704 may be used to check whether a software version matches a certain expression, or if prefixed with the exclamation mark, does not match\&. The first argument is the software whose version has to be checked\&. Currently
1705 "kernel",
1706 "systemd"
1707 and
1708 "glibc"
1709 are supported\&. If this argument is omitted,
1710 "kernel"
1711 is implied\&. The second argument must be a list of (potentially quoted) expressions\&. Each expression starts with one of
1712 "="
1713 or
1714 "!="
1715 for string comparisons,
1716 "<",
1717 "<=",
1718 "==",
1719 "<>",
1720 ">=",
1721 ">"
1722 for version comparisons, or
1723 "$=",
1724 "!$="
1725 for a shell\-style glob match\&. If no operator is specified,
1726 "$="
1727 is implied\&.
1728 .sp
1729 Added in version 258\&.
1730 .RE
1731 .PP
1732 \fIConditionCredential=\fR
1733 .RS 4
1734 \fIConditionCredential=\fR
1735 may be used to check whether a credential by the specified name was passed into the service manager\&. See
1736 \m[blue]\fBSystem and Service Credentials\fR\m[]\&\s-2\u[4]\d\s+2
1737 for details about credentials\&. If used in services for the system service manager this may be used to conditionalize services based on system credentials passed in\&. If used in services for the per\-user service manager this may be used to conditionalize services based on credentials passed into the
1738 unit@\&.service
1739 service instance belonging to the user\&. The argument must be a valid credential name\&.
1740 .sp
1741 Added in version 252\&.
1742 .RE
1743 .PP
1744 \fIConditionEnvironment=\fR
1745 .RS 4
1746 \fIConditionEnvironment=\fR
1747 may be used to check whether a specific environment variable is set (or if prefixed with the exclamation mark \(em unset) in the service manager\*(Aqs environment block\&. The argument may be a single word, to check if the variable with this name is defined in the environment block, or an assignment ("\fIname\fR=\fIvalue\fR"), to check if the variable with this exact value is defined\&. Note that the environment block of the service manager itself is checked, i\&.e\&. not any variables defined with
1748 \fIEnvironment=\fR
1749 or
1750 \fIEnvironmentFile=\fR, as described above\&. This is particularly useful when the service manager runs inside a containerized environment or as per\-user service manager, in order to check for variables passed in by the enclosing container manager or PAM\&.
1751 .sp
1752 Added in version 246\&.
1753 .RE
1754 .PP
1755 \fIConditionSecurity=\fR
1756 .RS 4
1757 \fIConditionSecurity=\fR
1758 may be used to check whether the given security technology is enabled on the system\&. Currently, the following values are recognized:
1759 .sp
1760 .it 1 an-trap
1761 .nr an-no-space-flag 1
1762 .nr an-break-flag 1
1763 .br
1764 .B Table\ \&3.\ \&Recognized security technologies
1765 .TS
1766 allbox tab(:);
1767 lB lB.
1768 T{
1769 Value
1770 T}:T{
1771 Description
1772 T}
1773 .T&
1774 l l
1775 l l
1776 l l
1777 l l
1778 l l
1779 l l
1780 l l
1781 l l
1782 l l
1783 l l.
1784 T{
1785 selinux
1786 T}:T{
1787 SELinux MAC
1788 T}
1789 T{
1790 apparmor
1791 T}:T{
1792 AppArmor MAC
1793 T}
1794 T{
1795 tomoyo
1796 T}:T{
1797 Tomoyo MAC
1798 T}
1799 T{
1800 smack
1801 T}:T{
1802 SMACK MAC
1803 T}
1804 T{
1805 ima
1806 T}:T{
1807 Integrity Measurement Architecture (IMA)
1808 T}
1809 T{
1810 audit
1811 T}:T{
1812 Linux Audit Framework
1813 T}
1814 T{
1815 uefi\-secureboot
1816 T}:T{
1817 UEFI SecureBoot
1818 T}
1819 T{
1820 tpm2
1821 T}:T{
1822 Trusted Platform Module 2\&.0 (TPM2) (with full UEFI support, including the TCG PC Client
1823 Platform Firmware Profile)
1824 T}
1825 T{
1826 cvm
1827 T}:T{
1828 Confidential virtual machine (SEV/TDX)
1829 T}
1830 T{
1831 measured\-uki
1832 T}:T{
1833 Unified Kernel Image with PCR 11 Measurements, as per \fBsystemd-stub\fR(7)\&. Added in version 255\&.
1834 T}
1835 .TE
1836 .sp 1
1837 The test may be negated by prepending an exclamation mark\&.
1838 .sp
1839 Added in version 244\&.
1840 .RE
1841 .PP
1842 \fIConditionCapability=\fR
1843 .RS 4
1844 Check whether the given capability exists in the capability bounding set of the service manager (i\&.e\&. this does not check whether capability is actually available in the permitted or effective sets, see
1845 \fBcapabilities\fR(7)
1846 for details)\&. Pass a capability name such as
1847 "CAP_MKNOD", possibly prefixed with an exclamation mark to negate the check\&.
1848 .sp
1849 Added in version 244\&.
1850 .RE
1851 .PP
1852 \fIConditionACPower=\fR
1853 .RS 4
1854 Check whether the system has AC power, or is exclusively battery powered at the time of activation of the unit\&. This takes a boolean argument\&. If set to
1855 "true", the condition will hold only if at least one AC connector of the system is connected to a power source, or if no AC connectors are known\&. Conversely, if set to
1856 "false", the condition will hold only if there is at least one AC connector known and all AC connectors are disconnected from a power source\&.
1857 .sp
1858 Added in version 244\&.
1859 .RE
1860 .PP
1861 \fIConditionNeedsUpdate=\fR
1862 .RS 4
1863 Takes one of
1864 /var/
1865 or
1866 /etc/
1867 as argument, possibly prefixed with a
1868 "!"
1869 (to invert the condition)\&. This condition may be used to conditionalize units on whether the specified directory requires an update because
1870 /usr/\*(Aqs modification time is newer than the stamp file
1871 \&.updated
1872 in the specified directory\&. This is useful to implement offline updates of the vendor operating system resources in
1873 /usr/
1874 that require updating of
1875 /etc/
1876 or
1877 /var/
1878 on the next following boot\&. Units making use of this condition should order themselves before
1879 \fBsystemd-update-done.service\fR(8), to make sure they run before the stamp file\*(Aqs modification time gets reset indicating a completed update\&.
1880 .sp
1881 If the
1882 \fIsystemd\&.condition_needs_update=\fR
1883 option is specified on the kernel command line (taking a boolean), it will override the result of this condition check, taking precedence over any file modification time checks\&. If the kernel command line option is used,
1884 systemd\-update\-done\&.service
1885 will not have immediate effect on any following
1886 \fIConditionNeedsUpdate=\fR
1887 checks, until the system is rebooted where the kernel command line option is not specified anymore\&.
1888 .sp
1889 Note that to make this scheme effective, the timestamp of
1890 /usr/
1891 should be explicitly updated after its contents are modified\&. The kernel will automatically update modification timestamp on a directory only when immediate children of a directory are modified; an modification of nested files will not automatically result in mtime of
1892 /usr/
1893 being updated\&.
1894 .sp
1895 Also note that if the update method includes a call to execute appropriate post\-update steps itself, it should not touch the timestamp of
1896 /usr/\&. In a typical distribution packaging scheme, packages will do any required update steps as part of the installation or upgrade, to make package contents immediately usable\&.
1897 \fIConditionNeedsUpdate=\fR
1898 should be used with other update mechanisms where such an immediate update does not happen\&.
1899 .sp
1900 Added in version 244\&.
1901 .RE
1902 .PP
1903 \fIConditionFirstBoot=\fR
1904 .RS 4
1905 Takes a boolean argument\&. This condition may be used to conditionalize units on whether the system is booting up for the first time\&. This roughly means that
1906 /etc/
1907 was unpopulated when the system started booting (for details, see "First Boot Semantics" in
1908 \fBmachine-id\fR(5))\&. First Boot is considered finished (this condition will evaluate as false) after the manager has finished the startup phase\&.
1909 .sp
1910 This condition may be used to populate
1911 /etc/
1912 on the first boot after factory reset, or when a new system instance boots up for the first time\&.
1913 .sp
1914 Note that the service manager itself will perform setup steps during First Boot: it will initialize
1915 \fBmachine-id\fR(5)
1916 and preset all units, enabling or disabling them according to the
1917 \fBsystemd.preset\fR(5)
1918 settings\&. Additional setup may be performed via units with
1919 \fIConditionFirstBoot=yes\fR\&.
1920 .sp
1921 For robustness, units with
1922 \fIConditionFirstBoot=yes\fR
1923 should order themselves before
1924 first\-boot\-complete\&.target
1925 and pull in this passive target with
1926 \fIWants=\fR\&. This ensures that in a case of an aborted first boot, these units will be re\-run during the next system startup\&.
1927 .sp
1928 If the
1929 \fIsystemd\&.condition_first_boot=\fR
1930 option is specified on the kernel command line (taking a boolean), it will override the result of this condition check, taking precedence over
1931 /etc/machine\-id
1932 existence checks\&.
1933 .sp
1934 Added in version 244\&.
1935 .RE
1936 .PP
1937 \fIConditionPathExists=\fR
1938 .RS 4
1939 Check for the existence of a file\&. If the specified absolute path name does not exist, the condition will fail\&. If the absolute path name passed to
1940 \fIConditionPathExists=\fR
1941 is prefixed with an exclamation mark ("!"), the test is negated, and the unit is only started if the path does not exist\&.
1942 .sp
1943 Added in version 244\&.
1944 .RE
1945 .PP
1946 \fIConditionPathExistsGlob=\fR
1947 .RS 4
1948 \fIConditionPathExistsGlob=\fR
1949 is similar to
1950 \fIConditionPathExists=\fR, but checks for the existence of at least one file or directory matching the specified globbing pattern\&.
1951 .sp
1952 Added in version 244\&.
1953 .RE
1954 .PP
1955 \fIConditionPathIsDirectory=\fR
1956 .RS 4
1957 \fIConditionPathIsDirectory=\fR
1958 is similar to
1959 \fIConditionPathExists=\fR
1960 but verifies that a certain path exists and is a directory\&.
1961 .sp
1962 Added in version 244\&.
1963 .RE
1964 .PP
1965 \fIConditionPathIsSymbolicLink=\fR
1966 .RS 4
1967 \fIConditionPathIsSymbolicLink=\fR
1968 is similar to
1969 \fIConditionPathExists=\fR
1970 but verifies that a certain path exists and is a symbolic link\&.
1971 .sp
1972 Added in version 244\&.
1973 .RE
1974 .PP
1975 \fIConditionPathIsMountPoint=\fR
1976 .RS 4
1977 \fIConditionPathIsMountPoint=\fR
1978 is similar to
1979 \fIConditionPathExists=\fR
1980 but verifies that a certain path exists and is a mount point\&.
1981 .sp
1982 Added in version 244\&.
1983 .RE
1984 .PP
1985 \fIConditionPathIsReadWrite=\fR
1986 .RS 4
1987 \fIConditionPathIsReadWrite=\fR
1988 is similar to
1989 \fIConditionPathExists=\fR
1990 but verifies that the underlying file system is readable and writable (i\&.e\&. not mounted read\-only)\&.
1991 .sp
1992 Added in version 244\&.
1993 .RE
1994 .PP
1995 \fIConditionPathIsEncrypted=\fR
1996 .RS 4
1997 \fIConditionPathIsEncrypted=\fR
1998 is similar to
1999 \fIConditionPathExists=\fR
2000 but verifies that the underlying file system\*(Aqs backing block device is encrypted using dm\-crypt/LUKS\&. Note that this check does not cover ext4 per\-directory encryption, and only detects block level encryption\&. Moreover, if the specified path resides on a file system on top of a loopback block device, only encryption above the loopback device is detected\&. It is not detected whether the file system backing the loopback block device is encrypted\&.
2001 .sp
2002 Added in version 246\&.
2003 .RE
2004 .PP
2005 \fIConditionDirectoryNotEmpty=\fR
2006 .RS 4
2007 \fIConditionDirectoryNotEmpty=\fR
2008 is similar to
2009 \fIConditionPathExists=\fR
2010 but verifies that a certain path exists and is a non\-empty directory\&.
2011 .sp
2012 Added in version 244\&.
2013 .RE
2014 .PP
2015 \fIConditionFileNotEmpty=\fR
2016 .RS 4
2017 \fIConditionFileNotEmpty=\fR
2018 is similar to
2019 \fIConditionPathExists=\fR
2020 but verifies that a certain path exists and refers to a regular file with a non\-zero size\&.
2021 .sp
2022 Added in version 244\&.
2023 .RE
2024 .PP
2025 \fIConditionFileIsExecutable=\fR
2026 .RS 4
2027 \fIConditionFileIsExecutable=\fR
2028 is similar to
2029 \fIConditionPathExists=\fR
2030 but verifies that a certain path exists, is a regular file, and marked executable\&.
2031 .sp
2032 Added in version 244\&.
2033 .RE
2034 .PP
2035 \fIConditionUser=\fR
2036 .RS 4
2037 \fIConditionUser=\fR
2038 takes a numeric
2039 "UID", a UNIX user name, or the special value
2040 "@system"\&. This condition may be used to check whether the service manager is running as the given user\&. The special value
2041 "@system"
2042 can be used to check if the user id is within the system user range\&. This option is not useful for system services, as the system manager exclusively runs as the root user, and thus the test result is constant\&.
2043 .sp
2044 Added in version 244\&.
2045 .RE
2046 .PP
2047 \fIConditionGroup=\fR
2048 .RS 4
2049 \fIConditionGroup=\fR
2050 is similar to
2051 \fIConditionUser=\fR
2052 but verifies that the service manager\*(Aqs real or effective group, or any of its auxiliary groups, match the specified group or GID\&. This setting does not support the special value
2053 "@system"\&.
2054 .sp
2055 Added in version 244\&.
2056 .RE
2057 .PP
2058 \fIConditionControlGroupController=\fR
2059 .RS 4
2060 Check whether given cgroup controllers (e\&.g\&.
2061 "cpu") are available for use on the system or whether the legacy v1 cgroup or the modern v2 cgroup hierarchy is used\&.
2062 .sp
2063 Multiple controllers may be passed with a space separating them; in this case, the condition will only pass if all listed controllers are available for use\&. Controllers unknown to systemd are ignored\&. Valid controllers are
2064 "cpu",
2065 "io",
2066 "memory", and
2067 "pids"\&. Even if available in the kernel, a particular controller may not be available if it was disabled on the kernel command line with
2068 \fIcgroup_disable=controller\fR\&.
2069 .sp
2070 Alternatively, two special strings
2071 "v1"
2072 and
2073 "v2"
2074 may be specified (without any controller names)\&.
2075 "v2"
2076 will pass if the unified v2 cgroup hierarchy is used, and
2077 "v1"
2078 will pass if the legacy v1 hierarchy or the hybrid hierarchy are used\&. Note that legacy or hybrid hierarchies have been deprecated\&. See
2079 \fBsystemd\fR(1)
2080 for more information\&.
2081 .sp
2082 Added in version 244\&.
2083 .RE
2084 .PP
2085 \fIConditionMemory=\fR
2086 .RS 4
2087 Verify that the specified amount of system memory is available to the current system\&. Takes a memory size in bytes as argument, optionally prefixed with a comparison operator
2088 "<",
2089 "<=",
2090 "="
2091 (or
2092 "=="),
2093 "!="
2094 (or
2095 "<>"),
2096 ">=",
2097 ">"\&. On bare\-metal systems compares the amount of physical memory in the system with the specified size, adhering to the specified comparison operator\&. In containers compares the amount of memory assigned to the container instead\&.
2098 .sp
2099 Added in version 244\&.
2100 .RE
2101 .PP
2102 \fIConditionCPUs=\fR
2103 .RS 4
2104 Verify that the specified number of CPUs is available to the current system\&. Takes a number of CPUs as argument, optionally prefixed with a comparison operator
2105 "<",
2106 "<=",
2107 "="
2108 (or
2109 "=="),
2110 "!="
2111 (or
2112 "<>"),
2113 ">=",
2114 ">"\&. Compares the number of CPUs in the CPU affinity mask configured of the service manager itself with the specified number, adhering to the specified comparison operator\&. On physical systems the number of CPUs in the affinity mask of the service manager usually matches the number of physical CPUs, but in special and virtual environments might differ\&. In particular, in containers the affinity mask usually matches the number of CPUs assigned to the container and not the physically available ones\&.
2115 .sp
2116 Added in version 244\&.
2117 .RE
2118 .PP
2119 \fIConditionCPUFeature=\fR
2120 .RS 4
2121 Verify that a given CPU feature is available via the
2122 "CPUID"
2123 instruction\&. This condition only does something on i386 and x86\-64 processors\&. On other processors it is assumed that the CPU does not support the given feature\&. It checks the leaves
2124 "1",
2125 "7",
2126 "0x80000001", and
2127 "0x80000007"\&. Valid values are:
2128 "fpu",
2129 "vme",
2130 "de",
2131 "pse",
2132 "tsc",
2133 "msr",
2134 "pae",
2135 "mce",
2136 "cx8",
2137 "apic",
2138 "sep",
2139 "mtrr",
2140 "pge",
2141 "mca",
2142 "cmov",
2143 "pat",
2144 "pse36",
2145 "clflush",
2146 "mmx",
2147 "fxsr",
2148 "sse",
2149 "sse2",
2150 "ht",
2151 "pni",
2152 "pclmul",
2153 "monitor",
2154 "ssse3",
2155 "fma3",
2156 "cx16",
2157 "sse4_1",
2158 "sse4_2",
2159 "movbe",
2160 "popcnt",
2161 "aes",
2162 "xsave",
2163 "osxsave",
2164 "avx",
2165 "f16c",
2166 "rdrand",
2167 "bmi1",
2168 "avx2",
2169 "bmi2",
2170 "rdseed",
2171 "adx",
2172 "sha_ni",
2173 "syscall",
2174 "rdtscp",
2175 "lm",
2176 "lahf_lm",
2177 "abm",
2178 "constant_tsc"\&.
2179 .sp
2180 Added in version 248\&.
2181 .RE
2182 .PP
2183 \fIConditionOSRelease=\fR
2184 .RS 4
2185 Verify that a specific
2186 "key=value"
2187 pair is set in the host\*(Aqs
2188 \fBos-release\fR(5)\&.
2189 .sp
2190 Other than exact string matching (with
2191 "="
2192 and
2193 "!="), relative comparisons are supported for versioned parameters (e\&.g\&.
2194 "VERSION_ID"; with
2195 "<",
2196 "<=",
2197 "==",
2198 "<>",
2199 ">=",
2200 ">"), and shell\-style wildcard comparisons ("*",
2201 "?",
2202 "[]") are supported with the
2203 "$="
2204 (match) and
2205 "!$="
2206 (non\-match)\&.
2207 .sp
2208 If the given key is not found in the file, the match is done against an empty value\&.
2209 .sp
2210 Added in version 249\&.
2211 .RE
2212 .PP
2213 \fIConditionMemoryPressure=\fR, \fIConditionCPUPressure=\fR, \fIConditionIOPressure=\fR
2214 .RS 4
2215 Verify that the overall system (memory, CPU or IO) pressure is below or equal to a threshold\&. This setting takes a threshold value as argument\&. It can be specified as a simple percentage value, suffixed with
2216 "%", in which case the pressure will be measured as an average over the last five minutes before the attempt to start the unit is performed\&. Alternatively, the average timespan can also be specified using
2217 "/"
2218 as a separator, for example:
2219 "10%/1min"\&. The supported timespans match what the kernel provides, and are limited to
2220 "10sec",
2221 "1min"
2222 and
2223 "5min"\&. The
2224 "full"
2225 PSI will be checked first, and if not found
2226 "some"
2227 will be checked\&. For more details, see the documentation on
2228 \m[blue]\fBPSI (Pressure Stall Information)\fR\m[]\&\s-2\u[5]\d\s+2\&.
2229 .sp
2230 Optionally, the threshold value can be prefixed with the slice unit under which the pressure will be checked, followed by a
2231 ":"\&. If the slice unit is not specified, the overall system pressure will be measured, instead of a particular cgroup\*(Aqs\&.
2232 .sp
2233 Added in version 250\&.
2234 .RE
2235 .PP
2236 \fIConditionKernelModuleLoaded=\fR
2237 .RS 4
2238 Test whether the specified kernel module has been loaded and is already fully initialized\&.
2239 .sp
2240 Added in version 258\&.
2241 .RE
2242 .PP
2243 \fIAssertArchitecture=\fR, \fIAssertVirtualization=\fR, \fIAssertHost=\fR, \fIAssertKernelCommandLine=\fR, \fIAssertKernelVersion=\fR, \fIAssertVersion=\fR, \fIAssertCredential=\fR, \fIAssertEnvironment=\fR, \fIAssertSecurity=\fR, \fIAssertCapability=\fR, \fIAssertACPower=\fR, \fIAssertNeedsUpdate=\fR, \fIAssertFirstBoot=\fR, \fIAssertPathExists=\fR, \fIAssertPathExistsGlob=\fR, \fIAssertPathIsDirectory=\fR, \fIAssertPathIsSymbolicLink=\fR, \fIAssertPathIsMountPoint=\fR, \fIAssertPathIsReadWrite=\fR, \fIAssertPathIsEncrypted=\fR, \fIAssertDirectoryNotEmpty=\fR, \fIAssertFileNotEmpty=\fR, \fIAssertFileIsExecutable=\fR, \fIAssertUser=\fR, \fIAssertGroup=\fR, \fIAssertControlGroupController=\fR, \fIAssertMemory=\fR, \fIAssertCPUs=\fR, \fIAssertCPUFeature=\fR, \fIAssertOSRelease=\fR, \fIAssertMemoryPressure=\fR, \fIAssertCPUPressure=\fR, \fIAssertIOPressure=\fR, \fIAssertKernelModuleLoaded=\fR
2244 .RS 4
2245 Similar to the
2246 \fIConditionArchitecture=\fR,
2247 \fIConditionVirtualization=\fR, \&..., condition settings described above, these settings add assertion checks to the start\-up of the unit\&. However, unlike the conditions settings, any assertion setting that is not met results in failure of the start job (which means this is logged loudly)\&. Note that hitting a configured assertion does not cause the unit to enter the
2248 "failed"
2249 state (or in fact result in any state change of the unit), it affects only the job queued for it\&. Use assertion expressions for units that cannot operate when specific requirements are not met, and when this is something the administrator or user should look into\&.
2250 .sp
2251 Added in version 218\&.
2252 .RE
2253 .SH "MAPPING OF UNIT PROPERTIES TO THEIR INVERSES"
2254 .PP
2255 Unit settings that create a relationship with a second unit usually show up in properties of both units, for example in
2256 \fBsystemctl show\fR
2257 output\&. In some cases the name of the property is the same as the name of the configuration setting, but not always\&. This table lists the properties that are shown on two units which are connected through some dependency, and shows which property on "source" unit corresponds to which property on the "target" unit\&.
2258 .sp
2259 .it 1 an-trap
2260 .nr an-no-space-flag 1
2261 .nr an-break-flag 1
2262 .br
2263 .B Table\ \&4.\ \& "Forward" and "reverse" unit properties
2264 .TS
2265 allbox tab(:);
2266 lB lB lB s.
2267 T{
2268 "Forward" property
2269 T}:T{
2270 "Reverse" property
2271 T}:T{
2272 Where used
2273 T}
2274 .T&
2275 l l l s
2276 l l ^ ^
2277 l l l l
2278 l l l l
2279 l l l l
2280 l l l l
2281 l l l l
2282 l l l l
2283 l l l l
2284 l l l s
2285 l l l s
2286 l l ^ ^
2287 l l l s
2288 l l ^ ^
2289 l l l l.
2290 T{
2291 \fIBefore=\fR
2292 T}:T{
2293 \fIAfter=\fR
2294 T}:T{
2295 [Unit] section
2296 T}
2297 T{
2298 \fIAfter=\fR
2299 T}:T{
2300 \fIBefore=\fR
2301 T}::
2302 T{
2303 \fIRequires=\fR
2304 T}:T{
2305 \fIRequiredBy=\fR
2306 T}:T{
2307 [Unit] section
2308 T}:T{
2309 [Install] section
2310 T}
2311 T{
2312 \fIWants=\fR
2313 T}:T{
2314 \fIWantedBy=\fR
2315 T}:T{
2316 [Unit] section
2317 T}:T{
2318 [Install] section
2319 T}
2320 T{
2321 \fIUpholds=\fR
2322 T}:T{
2323 \fIUpheldBy=\fR
2324 T}:T{
2325 [Unit] section
2326 T}:T{
2327 [Install] section
2328 T}
2329 T{
2330 \fIPartOf=\fR
2331 T}:T{
2332 \fIConsistsOf=\fR
2333 T}:T{
2334 [Unit] section
2335 T}:T{
2336 an automatic property
2337 T}
2338 T{
2339 \fIBindsTo=\fR
2340 T}:T{
2341 \fIBoundBy=\fR
2342 T}:T{
2343 [Unit] section
2344 T}:T{
2345 an automatic property
2346 T}
2347 T{
2348 \fIRequisite=\fR
2349 T}:T{
2350 \fIRequisiteOf=\fR
2351 T}:T{
2352 [Unit] section
2353 T}:T{
2354 an automatic property
2355 T}
2356 T{
2357 \fIConflicts=\fR
2358 T}:T{
2359 \fIConflictedBy=\fR
2360 T}:T{
2361 [Unit] section
2362 T}:T{
2363 an automatic property
2364 T}
2365 T{
2366 \fITriggers=\fR
2367 T}:T{
2368 \fITriggeredBy=\fR
2369 T}:T{
2370 Automatic properties, see notes below
2371 T}
2372 T{
2373 \fIPropagatesReloadTo=\fR
2374 T}:T{
2375 \fIReloadPropagatedFrom=\fR
2376 T}:T{
2377 [Unit] section
2378 T}
2379 T{
2380 \fIReloadPropagatedFrom=\fR
2381 T}:T{
2382 \fIPropagatesReloadTo=\fR
2383 T}::
2384 T{
2385 \fIPropagatesStopTo=\fR
2386 T}:T{
2387 \fIStopPropagatedFrom=\fR
2388 T}:T{
2389 [Unit] section
2390 T}
2391 T{
2392 \fIStopPropagatedFrom=\fR
2393 T}:T{
2394 \fIPropagatesStopTo=\fR
2395 T}::
2396 T{
2397 \fIFollowing=\fR
2398 T}:T{
2399 n/a
2400 T}:T{
2401 An automatic property
2402 T}:T{
2403 \ \&
2404 T}
2405 .TE
2406 .sp 1
2407 .PP
2408 Note:
2409 \fIWantedBy=\fR,
2410 \fIRequiredBy=\fR, and
2411 \fIUpheldBy=\fR
2412 are used in the [Install] section to create symlinks in
2413 \&.wants/,
2414 \&.requires/, and
2415 \&.upholds/
2416 directories\&. They cannot be used directly as a unit configuration setting\&.
2417 .PP
2418 Note:
2419 \fIConsistsOf=\fR,
2420 \fIBoundBy=\fR,
2421 \fIRequisiteOf=\fR,
2422 \fIConflictedBy=\fR
2423 are created implicitly along with their reverses and cannot be specified directly\&.
2424 .PP
2425 Note:
2426 \fITriggers=\fR
2427 is created implicitly between a socket, path unit, or an automount unit, and the unit they activate\&. By default, a unit with the same name is triggered, but this can be overridden using
2428 \fISockets=\fR,
2429 \fIService=\fR, and
2430 \fIUnit=\fR
2431 settings\&. See
2432 \fBsystemd.service\fR(5),
2433 \fBsystemd.socket\fR(5),
2434 \fBsystemd.path\fR(5), and
2435 \fBsystemd.automount\fR(5)
2436 for details\&.
2437 \fITriggeredBy=\fR
2438 is created implicitly on the triggered unit\&.
2439 .PP
2440 Note:
2441 \fIFollowing=\fR
2442 is used to group device aliases and points to the "primary" device unit that systemd is using to track device state, usually corresponding to a sysfs path\&. It does not show up in the "target" unit\&.
2443 .SH "[INSTALL] SECTION OPTIONS"
2444 .PP
2445 Unit files may include an [Install] section, which carries installation information for the unit\&. This section is not interpreted by
2446 \fBsystemd\fR(1)
2447 during runtime; it is used by the
2448 \fBenable\fR
2449 and
2450 \fBdisable\fR
2451 commands of the
2452 \fBsystemctl\fR(1)
2453 tool during installation of a unit\&.
2454 .PP
2455 \fIAlias=\fR
2456 .RS 4
2457 A space\-separated list of additional names this unit shall be installed under\&. The names listed here must have the same suffix (i\&.e\&. type) as the unit filename\&. This option may be specified more than once, in which case all listed names are used\&. At installation time,
2458 \fBsystemctl enable\fR
2459 will create symlinks from these names to the unit filename\&. Note that not all unit types support such alias names, and this setting is not supported for them\&. Specifically, mount, slice, swap, and automount units do not support aliasing\&.
2460 .sp
2461 Added in version 201\&.
2462 .RE
2463 .PP
2464 \fIWantedBy=\fR, \fIRequiredBy=\fR, \fIUpheldBy=\fR
2465 .RS 4
2466 This option may be used more than once, or a space\-separated list of unit names may be given\&. A symbolic link is created in the
2467 \&.wants/,
2468 \&.requires/, or
2469 \&.upholds/
2470 directory of each of the listed units when this unit is installed by
2471 \fBsystemctl enable\fR\&. This has the effect of a dependency of type
2472 \fIWants=\fR,
2473 \fIRequires=\fR, or
2474 \fIUpholds=\fR
2475 being added from the listed unit to the current unit\&. See the description of the mentioned dependency types in the [Unit] section for details\&.
2476 .sp
2477 In case of template units listing non template units, the listing unit must have
2478 \fIDefaultInstance=\fR
2479 set, or
2480 \fBsystemctl enable\fR
2481 must be called with an instance name\&. The instance (default or specified) will be added to the
2482 \&.wants/,
2483 \&.requires/, or
2484 \&.upholds/
2485 list of the listed unit\&. For example,
2486 \fBWantedBy=getty\&.target\fR
2487 in a service
2488 getty@\&.service
2489 will result in
2490 \fBsystemctl enable getty@tty2\&.service\fR
2491 creating a
2492 getty\&.target\&.wants/getty@tty2\&.service
2493 link to
2494 getty@\&.service\&. This also applies to listing specific instances of templated units: this specific instance will gain the dependency\&. A template unit may also list a template unit, in which case a generic dependency will be added where each instance of the listing unit will have a dependency on an instance of the listed template with the same instance value\&. For example,
2495 \fBWantedBy=container@\&.target\fR
2496 in a service
2497 monitor@\&.service
2498 will result in
2499 \fBsystemctl enable monitor@\&.service\fR
2500 creating a
2501 container@\&.target\&.wants/monitor@\&.service
2502 link to
2503 monitor@\&.service, which applies to all instances of
2504 container@\&.target\&.
2505 .sp
2506 Added in version 201\&.
2507 .RE
2508 .PP
2509 \fIAlso=\fR
2510 .RS 4
2511 Additional units to install/deinstall when this unit is installed/deinstalled\&. If the user requests installation/deinstallation of a unit with this option configured,
2512 \fBsystemctl enable\fR
2513 and
2514 \fBsystemctl disable\fR
2515 will automatically install/uninstall units listed in this option as well\&.
2516 .sp
2517 This option may be used more than once, or a space\-separated list of unit names may be given\&.
2518 .sp
2519 Added in version 201\&.
2520 .RE
2521 .PP
2522 \fIDefaultInstance=\fR
2523 .RS 4
2524 In template unit files, this specifies for which instance the unit shall be enabled if the template is enabled without any explicitly set instance\&. This option has no effect in non\-template unit files\&. The specified string must be usable as instance identifier\&.
2525 .sp
2526 Added in version 215\&.
2527 .RE
2528 .PP
2529 The following specifiers are interpreted in the Install section: %a, %b, %B, %g, %G, %H, %i, %j, %l, %m, %n, %N, %o, %p, %u, %U, %v, %w, %W, %%\&. For their meaning see the next section\&.
2530 .SH "SPECIFIERS"
2531 .PP
2532 Many settings resolve specifiers which may be used to write generic unit files referring to runtime or unit parameters that are replaced when the unit files are loaded\&. Specifiers must be known and resolvable for the setting to be valid\&. The following specifiers are understood:
2533 .sp
2534 .it 1 an-trap
2535 .nr an-no-space-flag 1
2536 .nr an-break-flag 1
2537 .br
2538 .B Table\ \&5.\ \&Specifiers available in unit files
2539 .TS
2540 allbox tab(:);
2541 lB lB lB.
2542 T{
2543 Specifier
2544 T}:T{
2545 Meaning
2546 T}:T{
2547 Details
2548 T}
2549 .T&
2550 l l l
2551 l l l
2552 l l l
2553 l l l
2554 l l l
2555 l l l
2556 l l l
2557 l l l
2558 l l l
2559 l l l
2560 l l l
2561 l l l
2562 l l l
2563 l l l
2564 l l l
2565 l l l
2566 l l l
2567 l l l
2568 l l l
2569 l l l
2570 l l l
2571 l l l
2572 l l l
2573 l l l
2574 l l l
2575 l l l
2576 l l l
2577 l l l
2578 l l l
2579 l l l
2580 l l l
2581 l l l
2582 l l l
2583 l l l
2584 l l l
2585 l l l
2586 l l l
2587 l l l
2588 l l l
2589 l l l.
2590 T{
2591 "%a"
2592 T}:T{
2593 Architecture
2594 T}:T{
2595 A short string identifying the architecture of the local system\&. A string such as \fBx86\fR, \fBx86\-64\fR or \fBarm64\fR\&. See the architectures defined for \fIConditionArchitecture=\fR above for a full list\&.
2596 T}
2597 T{
2598 "%A"
2599 T}:T{
2600 Operating system image version
2601 T}:T{
2602 The operating system image version identifier of the running system, as read from the \fIIMAGE_VERSION=\fR field of /etc/os\-release\&. If not set, resolves to an empty string\&. See \fBos-release\fR(5) for more information\&.
2603 T}
2604 T{
2605 "%b"
2606 T}:T{
2607 Boot ID
2608 T}:T{
2609 The boot ID of the running system, formatted as string\&. See \fBrandom\fR(4) for more information\&.
2610 T}
2611 T{
2612 "%B"
2613 T}:T{
2614 Operating system build ID
2615 T}:T{
2616 The operating system build identifier of the running system, as read from the \fIBUILD_ID=\fR field of /etc/os\-release\&. If not set, resolves to an empty string\&. See \fBos-release\fR(5) for more information\&.
2617 T}
2618 T{
2619 "%C"
2620 T}:T{
2621 Cache directory root
2622 T}:T{
2623 This is either /var/cache (for the system manager) or the path "$XDG_CACHE_HOME" resolves to (for user managers)\&.
2624 T}
2625 T{
2626 "%d"
2627 T}:T{
2628 Credentials directory
2629 T}:T{
2630 This is the value of the "$CREDENTIALS_DIRECTORY" environment variable if available\&. See section "Credentials" in \fBsystemd.exec\fR(5) for more information\&.
2631 T}
2632 T{
2633 "%D"
2634 T}:T{
2635 Shared data directory
2636 T}:T{
2637 This is either /usr/share/ (for the system manager) or the path "$XDG_DATA_HOME" resolves to (for user managers)\&.
2638 T}
2639 T{
2640 "%E"
2641 T}:T{
2642 Configuration directory root
2643 T}:T{
2644 This is either /etc/ (for the system manager) or the path "$XDG_CONFIG_HOME" resolves to (for user managers)\&.
2645 T}
2646 T{
2647 "%f"
2648 T}:T{
2649 Unescaped filename
2650 T}:T{
2651 This is either the unescaped instance name (if applicable) with / prepended (if applicable), or the unescaped prefix name prepended with /\&. This implements unescaping according to the rules for escaping absolute file system paths discussed above\&.
2652 T}
2653 T{
2654 "%g"
2655 T}:T{
2656 User group
2657 T}:T{
2658 This is the name of the group running the service manager instance\&. In case of the system manager this resolves to "root"\&.
2659 T}
2660 T{
2661 "%G"
2662 T}:T{
2663 User GID
2664 T}:T{
2665 This is the numeric GID of the user running the service manager instance\&. In case of the system manager this resolves to "0"\&.
2666 T}
2667 T{
2668 "%h"
2669 T}:T{
2670 User home directory
2671 T}:T{
2672 This is the home directory of the \fIuser running the service manager instance\fR\&. In case of the system manager this resolves to "/root"\&.
2673
2674 Note that this setting is \fInot\fR influenced by the \fIUser=\fR setting configurable in the [Service] section of the service unit\&.
2675 T}
2676 T{
2677 "%H"
2678 T}:T{
2679 Host name
2680 T}:T{
2681 The hostname of the running system at the point in time the unit configuration is loaded\&.
2682 T}
2683 T{
2684 "%i"
2685 T}:T{
2686 Instance name
2687 T}:T{
2688 For instantiated units this is the string between the first "@" character and the type suffix\&. Empty for non\-instantiated units\&.
2689 T}
2690 T{
2691 "%I"
2692 T}:T{
2693 Unescaped instance name
2694 T}:T{
2695 Same as "%i", but with escaping undone\&.
2696 T}
2697 T{
2698 "%j"
2699 T}:T{
2700 Final component of the prefix
2701 T}:T{
2702 This is the string between the last "\-" and the end of the prefix name\&. If there is no "\-", this is the same as "%p"\&.
2703 T}
2704 T{
2705 "%J"
2706 T}:T{
2707 Unescaped final component of the prefix
2708 T}:T{
2709 Same as "%j", but with escaping undone\&.
2710 T}
2711 T{
2712 "%l"
2713 T}:T{
2714 Short host name
2715 T}:T{
2716 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\&.
2717 T}
2718 T{
2719 "%L"
2720 T}:T{
2721 Log directory root
2722 T}:T{
2723 This is either /var/log (for the system manager) or the path \fI$XDG_STATE_HOME\fR resolves to with /log appended (for user managers)\&.
2724 T}
2725 T{
2726 "%m"
2727 T}:T{
2728 Machine ID
2729 T}:T{
2730 The machine ID of the running system, formatted as string\&. See \fBmachine-id\fR(5) for more information\&.
2731 T}
2732 T{
2733 "%M"
2734 T}:T{
2735 Operating system image identifier
2736 T}:T{
2737 The operating system image identifier of the running system, as read from the \fIIMAGE_ID=\fR field of /etc/os\-release\&. If not set, resolves to an empty string\&. See \fBos-release\fR(5) for more information\&.
2738 T}
2739 T{
2740 "%n"
2741 T}:T{
2742 Full unit name
2743 T}:T{
2744 \ \&
2745 T}
2746 T{
2747 "%N"
2748 T}:T{
2749 Full unit name
2750 T}:T{
2751 Same as "%n", but with the type suffix removed\&.
2752 T}
2753 T{
2754 "%o"
2755 T}:T{
2756 Operating system ID
2757 T}:T{
2758 The operating system identifier of the running system, as read from the \fIID=\fR field of /etc/os\-release\&. See \fBos-release\fR(5) for more information\&.
2759 T}
2760 T{
2761 "%p"
2762 T}:T{
2763 Prefix name
2764 T}:T{
2765 For instantiated units, this refers to the string before the first "@" character of the unit name\&. For non\-instantiated units, same as "%N"\&.
2766 T}
2767 T{
2768 "%P"
2769 T}:T{
2770 Unescaped prefix name
2771 T}:T{
2772 Same as "%p", but with escaping undone\&.
2773 T}
2774 T{
2775 "%q"
2776 T}:T{
2777 Pretty host name
2778 T}:T{
2779 The pretty hostname of the running system at the point in time the unit configuration is loaded, as read from the \fIPRETTY_HOSTNAME=\fR field of /etc/machine\-info\&. If not set, resolves to the short hostname\&. See \fBmachine-info\fR(5) for more information\&.
2780 T}
2781 T{
2782 "%s"
2783 T}:T{
2784 User shell
2785 T}:T{
2786 This is the shell of the user running the service manager instance\&.
2787 T}
2788 T{
2789 "%S"
2790 T}:T{
2791 State directory root
2792 T}:T{
2793 This is either /var/lib (for the system manager) or the path \fI$XDG_STATE_HOME\fR resolves to (for user managers)\&.
2794 T}
2795 T{
2796 "%t"
2797 T}:T{
2798 Runtime directory root
2799 T}:T{
2800 This is either /run/ (for the system manager) or the path "$XDG_RUNTIME_DIR" resolves to (for user managers)\&.
2801 T}
2802 T{
2803 "%T"
2804 T}:T{
2805 Directory for temporary files
2806 T}:T{
2807 This is either /tmp or the path "$TMPDIR", "$TEMP" or "$TMP" are set to\&. (Note that the directory may be specified without a trailing slash\&.)
2808 T}
2809 T{
2810 "%u"
2811 T}:T{
2812 User name
2813 T}:T{
2814 This is the name of the \fIuser running the service manager instance\fR\&. In case of the system manager this resolves to "root"\&.
2815
2816 Note that this setting is \fInot\fR influenced by the \fIUser=\fR setting configurable in the [Service] section of the service unit\&.
2817 T}
2818 T{
2819 "%U"
2820 T}:T{
2821 User UID
2822 T}:T{
2823 This is the numeric UID of the \fIuser running the service manager instance\fR\&. In case of the system manager this resolves to "0"\&.
2824
2825 Note that this setting is \fInot\fR influenced by the \fIUser=\fR setting configurable in the [Service] section of the service unit\&.
2826 T}
2827 T{
2828 "%v"
2829 T}:T{
2830 Kernel release
2831 T}:T{
2832 Identical to \fBuname \-r\fR output\&.
2833 T}
2834 T{
2835 "%V"
2836 T}:T{
2837 Directory for larger and persistent temporary files
2838 T}:T{
2839 This is either /var/tmp or the path "$TMPDIR", "$TEMP" or "$TMP" are set to\&. (Note that the directory may be specified without a trailing slash\&.)
2840 T}
2841 T{
2842 "%w"
2843 T}:T{
2844 Operating system version ID
2845 T}:T{
2846 The operating system version identifier of the running system, as read from the \fIVERSION_ID=\fR field of /etc/os\-release\&. If not set, resolves to an empty string\&. See \fBos-release\fR(5) for more information\&.
2847 T}
2848 T{
2849 "%W"
2850 T}:T{
2851 Operating system variant ID
2852 T}:T{
2853 The operating system variant identifier of the running system, as read from the \fIVARIANT_ID=\fR field of /etc/os\-release\&. If not set, resolves to an empty string\&. See \fBos-release\fR(5) for more information\&.
2854 T}
2855 T{
2856 "%y"
2857 T}:T{
2858 The path to the fragment
2859 T}:T{
2860 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 do not have a fragment file, this specifier will raise an error\&.
2861 T}
2862 T{
2863 "%Y"
2864 T}:T{
2865 The directory of the fragment
2866 T}:T{
2867 This is the directory part of "%y"\&.
2868 T}
2869 T{
2870 "%%"
2871 T}:T{
2872 Single percent sign
2873 T}:T{
2874 Use "%%" in place of "%" to specify a single percent sign\&.
2875 T}
2876 .TE
2877 .sp 1
2878 .SH "EXAMPLES"
2879 .PP
2880 \fBExample\ \&1.\ \&Allowing units to be enabled\fR
2881 .PP
2882 The following snippet (highlighted) allows a unit (e\&.g\&.
2883 foo\&.service) to be enabled via
2884 \fBsystemctl enable\fR:
2885 .sp
2886 .if n \{\
2887 .RS 4
2888 .\}
2889 .nf
2890 [Unit]
2891 Description=Foo
2892
2893 [Service]
2894 ExecStart=/usr/sbin/foo\-daemon
2895
2896 \fI[Install]\fR
2897 \fIWantedBy=multi\-user\&.target\fR
2898 .fi
2899 .if n \{\
2900 .RE
2901 .\}
2902 .PP
2903 After running
2904 \fBsystemctl enable\fR, a symlink
2905 /etc/systemd/system/multi\-user\&.target\&.wants/foo\&.service
2906 linking to the actual unit will be created\&. It tells systemd to pull in the unit when starting
2907 multi\-user\&.target\&. The inverse
2908 \fBsystemctl disable\fR
2909 will remove that symlink again\&.
2910 .PP
2911 \fBExample\ \&2.\ \&Overriding vendor settings\fR
2912 .PP
2913 There are two methods of overriding vendor settings in unit files: copying the unit file from
2914 /usr/lib/systemd/system
2915 to
2916 /etc/systemd/system
2917 and modifying the chosen settings\&. Alternatively, one can create a directory named
2918 \fIunit\fR\&.d/
2919 within
2920 /etc/systemd/system
2921 and place a drop\-in file
2922 \fIname\fR\&.conf
2923 there that only changes the specific settings one is interested in\&. Note that multiple such drop\-in files are read if present, processed in lexicographic order of their filename\&.
2924 .PP
2925 The advantage of the first method is that one easily overrides the complete unit, the vendor unit is not parsed at all anymore\&. It has the disadvantage that improvements to the unit file by the vendor are not automatically incorporated on updates\&.
2926 .PP
2927 The advantage of the second method is that one only overrides the settings one specifically wants, where updates to the unit by the vendor automatically apply\&. This has the disadvantage that some future updates by the vendor might be incompatible with the local changes\&.
2928 .PP
2929 This also applies for user instances of systemd, but with different locations for the unit files\&. See the section on unit load paths for further details\&.
2930 .PP
2931 Suppose there is a vendor\-supplied unit
2932 /usr/lib/systemd/system/httpd\&.service
2933 with the following contents:
2934 .sp
2935 .if n \{\
2936 .RS 4
2937 .\}
2938 .nf
2939 [Unit]
2940 Description=Some HTTP Server
2941 After=remote\-fs\&.target sqldb\&.service
2942 Requires=sqldb\&.service
2943 AssertPathExists=/srv/webserver
2944
2945 [Service]
2946 Type=notify
2947 ExecStart=/usr/sbin/some\-fancy\-httpd\-server
2948 Nice=5
2949
2950 [Install]
2951 WantedBy=multi\-user\&.target
2952 .fi
2953 .if n \{\
2954 .RE
2955 .\}
2956 .PP
2957 Now one wants to change some settings as an administrator: firstly, in the local setup,
2958 /srv/webserver
2959 might not exist, because the HTTP server is configured to use
2960 /srv/www
2961 instead\&. Secondly, the local configuration makes the HTTP server also depend on a memory cache service,
2962 memcached\&.service, that should be pulled in (\fIRequires=\fR) and also be ordered appropriately (\fIAfter=\fR)\&. Thirdly, in order to harden the service a bit more, the administrator would like to set the
2963 \fIPrivateTmp=\fR
2964 setting (see
2965 \fBsystemd.exec\fR(5)
2966 for details)\&. And lastly, the administrator would like to reset the niceness of the service to its default value of 0\&.
2967 .PP
2968 The first possibility is to copy the unit file to
2969 /etc/systemd/system/httpd\&.service
2970 and change the chosen settings:
2971 .sp
2972 .if n \{\
2973 .RS 4
2974 .\}
2975 .nf
2976 [Unit]
2977 Description=Some HTTP Server
2978 After=remote\-fs\&.target sqldb\&.service \fImemcached\&.service\fR
2979 Requires=sqldb\&.service \fImemcached\&.service\fR
2980 AssertPathExists=\fI/srv/www\fR
2981
2982 [Service]
2983 Type=notify
2984 ExecStart=/usr/sbin/some\-fancy\-httpd\-server
2985 \fINice=0\fR
2986 \fIPrivateTmp=yes\fR
2987
2988 [Install]
2989 WantedBy=multi\-user\&.target
2990 .fi
2991 .if n \{\
2992 .RE
2993 .\}
2994 .PP
2995 Alternatively, the administrator could create a drop\-in file
2996 /etc/systemd/system/httpd\&.service\&.d/local\&.conf
2997 with the following contents:
2998 .sp
2999 .if n \{\
3000 .RS 4
3001 .\}
3002 .nf
3003 [Unit]
3004 After=memcached\&.service
3005 Requires=memcached\&.service
3006 # Reset all assertions and then re\-add the condition we want
3007 AssertPathExists=
3008 AssertPathExists=/srv/www
3009
3010 [Service]
3011 Nice=0
3012 PrivateTmp=yes
3013 .fi
3014 .if n \{\
3015 .RE
3016 .\}
3017 .PP
3018 Note that for drop\-in files, if one wants to remove entries from a setting that is parsed as a list (and is not a dependency), such as
3019 \fIAssertPathExists=\fR
3020 (or e\&.g\&.
3021 \fIExecStart=\fR
3022 in service units), one needs to first clear the list before re\-adding all entries except the one that is to be removed\&. Dependencies (\fIAfter=\fR, etc\&.) cannot be reset to an empty list, so dependencies can only be added in drop\-ins\&. If you want to remove dependencies, you have to override the entire unit\&.
3023 .PP
3024 \fBExample\ \&3.\ \&Top level drop\-ins with template units\fR
3025 .PP
3026 Top level per\-type drop\-ins can be used to change some aspect of all units of a particular type\&. For example, by creating the
3027 /etc/systemd/system/service\&.d/
3028 directory with a drop\-in file, the contents of the drop\-in file can be applied to all service units\&. We can take this further by having the top\-level drop\-in instantiate a secondary helper unit\&. Consider for example the following set of units and drop\-in files where we install an
3029 \fIOnFailure=\fR
3030 dependency for all service units\&.
3031 .PP
3032 /etc/systemd/system/failure\-handler@\&.service:
3033 .sp
3034 .if n \{\
3035 .RS 4
3036 .\}
3037 .nf
3038 [Unit]
3039 Description=My Failure Handler For %i
3040
3041 [Service]
3042 Type=oneshot
3043 # Perform some special action for when %i exits unexpectedly\&.
3044 ExecStart=/usr/sbin/myfailurehandler %i
3045 .fi
3046 .if n \{\
3047 .RE
3048 .\}
3049 .PP
3050 We can then add an instance of
3051 failure\-handler@\&.service
3052 as an
3053 \fIOnFailure=\fR
3054 dependency for all service units\&.
3055 .PP
3056 /etc/systemd/system/service\&.d/10\-all\&.conf:
3057 .sp
3058 .if n \{\
3059 .RS 4
3060 .\}
3061 .nf
3062 [Unit]
3063 OnFailure=failure\-handler@%N\&.service
3064 .fi
3065 .if n \{\
3066 .RE
3067 .\}
3068 .PP
3069 Now, after running
3070 \fBsystemctl daemon\-reload\fR
3071 all services will have acquired an
3072 \fIOnFailure=\fR
3073 dependency on
3074 failure\-handler@%N\&.service\&. The template instance units will also have gained the dependency which results in the creation of a recursive dependency chain\&. systemd will try to detect these recursive dependency chains where a template unit directly and recursively depends on itself and will remove such dependencies automatically if it finds them\&. If systemd does not detect the recursive dependency chain, we can break the chain ourselves by disabling the drop\-in for the template instance units via a symlink to
3075 /dev/null:
3076 .sp
3077 .if n \{\
3078 .RS 4
3079 .\}
3080 .nf
3081 \fBmkdir /etc/systemd/system/failure\-handler@\&.service\&.d/\fR
3082 \fBln \-s /dev/null /etc/systemd/system/failure\-handler@\&.service\&.d/10\-all\&.conf\fR
3083 \fBsystemctl daemon\-reload\fR
3084 .fi
3085 .if n \{\
3086 .RE
3087 .\}
3088 .PP
3089 This ensures that if a
3090 failure\-handler@\&.service
3091 instance fails it will not trigger an instance named
3092 failure\-handler@failure\-handler\&.service\&.
3093 .SH "SEE ALSO"
3094 .PP
3095 \fBsystemd\fR(1), \fBsystemctl\fR(1), \fBsystemd-system.conf\fR(5), \fBsystemd.special\fR(7), \fBsystemd.service\fR(5), \fBsystemd.socket\fR(5), \fBsystemd.device\fR(5), \fBsystemd.mount\fR(5), \fBsystemd.automount\fR(5), \fBsystemd.swap\fR(5), \fBsystemd.target\fR(5), \fBsystemd.path\fR(5), \fBsystemd.timer\fR(5), \fBsystemd.scope\fR(5), \fBsystemd.slice\fR(5), \fBsystemd.time\fR(7), \fBsystemd-analyze\fR(1), \fBcapabilities\fR(7), \fBsystemd.directives\fR(7), \fBuname\fR(1)
3096 .SH "NOTES"
3097 .IP " 1." 4
3098 Interface Portability and Stability Promise
3099 .RS 4
3100 \%https://systemd.io/PORTABILITY_AND_STABILITY/
3101 .RE
3102 .IP " 2." 4
3103 ๐Ÿ’ฃ๐Ÿ’ฅ๐Ÿงจ๐Ÿ’ฅ๐Ÿ’ฅ๐Ÿ’ฃ Please note that those configuration files must be available at all times. If
3104 /usr/local/
3105 is a separate partition, it may not be available during early boot, and must not be used for configuration.
3106 .IP " 3." 4
3107 systemd and Storage Daemons for the Root File System
3108 .RS 4
3109 \%https://systemd.io/ROOT_STORAGE_DAEMONS
3110 .RE
3111 .IP " 4." 4
3112 System and Service Credentials
3113 .RS 4
3114 \%https://systemd.io/CREDENTIALS
3115 .RE
3116 .IP " 5." 4
3117 PSI (Pressure Stall Information)
3118 .RS 4
3119 \%https://docs.kernel.org/accounting/psi.html
3120 .RE