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