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. The restart happens without delay, and
644 usual per-unit rate-limit applies.
645
646 When Upholds=b.service is used on a.service, this dependency will
647 show as UpheldBy=a.service in the property listing of b.service.
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. If this is specified on a unit (say, a.service has
745 JoinsNamespaceOf=b.service), then this the inverse dependency
746 (JoinsNamespaceOf=a.service for b.service) is implied. This only
747 applies to unit types which support the PrivateNetwork=,
748 NetworkNamespacePath=, PrivateIPC=, IPCNamespacePath=, and
749 PrivateTmp= directives (see systemd.exec(5) for details). If a unit
750 that has this setting set is started, its processes will see the
751 same /tmp/, /var/tmp/, IPC namespace and network namespace as one
752 listed unit that is started. If multiple listed units are already
753 started and these do not share their namespace, then it is not
754 defined which namespace is joined. Note that this setting only has
755 an effect if PrivateNetwork=/NetworkNamespacePath=,
756 PrivateIPC=/IPCNamespacePath= and/or PrivateTmp= is enabled for
757 both the unit that joins the namespace and the unit whose namespace
758 is joined.
759
760 RequiresMountsFor=
761 Takes a space-separated list of absolute paths. Automatically adds
762 dependencies of type Requires= and After= for all mount units
763 required to access the specified path.
764
765 Mount points marked with noauto are not mounted automatically
766 through local-fs.target, but are still honored for the purposes of
767 this option, i.e. they will be pulled in by this unit.
768
769 OnSuccessJobMode=, OnFailureJobMode=
770 Takes a value of "fail", "replace", "replace-irreversibly",
771 "isolate", "flush", "ignore-dependencies" or "ignore-requirements".
772 Defaults to "replace". Specifies how the units listed in
773 OnSuccess=/OnFailure= will be enqueued. See systemctl(1)'s
774 --job-mode= option for details on the possible values. If this is
775 set to "isolate", only a single unit may be listed in
776 OnSuccess=/OnFailure=.
777
778 IgnoreOnIsolate=
779 Takes a boolean argument. If true, this unit will not be stopped
780 when isolating another unit. Defaults to false for service, target,
781 socket, timer, and path units, and true for slice, scope, device,
782 swap, mount, and automount units.
783
784 StopWhenUnneeded=
785 Takes a boolean argument. If true, this unit will be stopped when
786 it is no longer used. Note that, in order to minimize the work to
787 be executed, systemd will not stop units by default unless they are
788 conflicting with other units, or the user explicitly requested
789 their shut down. If this option is set, a unit will be
790 automatically cleaned up if no other active unit requires it.
791 Defaults to false.
792
793 RefuseManualStart=, RefuseManualStop=
794 Takes a boolean argument. If true, this unit can only be activated
795 or deactivated indirectly. In this case, explicit start-up or
796 termination requested by the user is denied, however if it is
797 started or stopped as a dependency of another unit, start-up or
798 termination will succeed. This is mostly a safety feature to ensure
799 that the user does not accidentally activate units that are not
800 intended to be activated explicitly, and not accidentally
801 deactivate units that are not intended to be deactivated. These
802 options default to false.
803
804 AllowIsolate=
805 Takes a boolean argument. If true, this unit may be used with the
806 systemctl isolate command. Otherwise, this will be refused. It
807 probably is a good idea to leave this disabled except for target
808 units that shall be used similar to runlevels in SysV init systems,
809 just as a precaution to avoid unusable system states. This option
810 defaults to false.
811
812 DefaultDependencies=
813 Takes a boolean argument. If yes, (the default), a few default
814 dependencies will implicitly be created for the unit. The actual
815 dependencies created depend on the unit type. For example, for
816 service units, these dependencies ensure that the service is
817 started only after basic system initialization is completed and is
818 properly terminated on system shutdown. See the respective man
819 pages for details. Generally, only services involved with early
820 boot or late shutdown should set this option to no. It is highly
821 recommended to leave this option enabled for the majority of common
822 units. If set to no, this option does not disable all implicit
823 dependencies, just non-essential ones.
824
825 CollectMode=
826 Tweaks the "garbage collection" algorithm for this unit. Takes one
827 of inactive or inactive-or-failed. If set to inactive the unit will
828 be unloaded if it is in the inactive state and is not referenced by
829 clients, jobs or other units — however it is not unloaded if it is
830 in the failed state. In failed mode, failed units are not unloaded
831 until the user invoked systemctl reset-failed on them to reset the
832 failed state, or an equivalent command. This behaviour is altered
833 if this option is set to inactive-or-failed: in this case the unit
834 is unloaded even if the unit is in a failed state, and thus an
835 explicitly resetting of the failed state is not necessary. Note
836 that if this mode is used unit results (such as exit codes, exit
837 signals, consumed resources, ...) are flushed out immediately after
838 the unit completed, except for what is stored in the logging
839 subsystem. Defaults to inactive.
840
841 FailureAction=, SuccessAction=
842 Configure the action to take when the unit stops and enters a
843 failed state or inactive state. Takes one of none, reboot,
844 reboot-force, reboot-immediate, poweroff, poweroff-force,
845 poweroff-immediate, exit, exit-force, soft-reboot,
846 soft-reboot-force, kexec, kexec-force, halt, halt-force and
847 halt-immediate. In system mode, all options are allowed. In user
848 mode, only none, exit, exit-force, soft-reboot and
849 soft-reboot-force are allowed. Both options default to none.
850
851 If none is set, no action will be triggered. reboot causes a
852 reboot following the normal shutdown procedure (i.e. equivalent to
853 systemctl reboot). reboot-force causes a forced reboot which will
854 terminate all processes forcibly but should cause no dirty file
855 systems on reboot (i.e. equivalent to systemctl reboot -f) and
856 reboot-immediate causes immediate execution of the reboot(2) system
857 call, which might result in data loss (i.e. equivalent to systemctl
858 reboot -ff). Similarly, poweroff, poweroff-force,
859 poweroff-immediate, kexec, kexec-force, halt, halt-force and
860 halt-immediate have the effect of powering down the system,
861 executing kexec, and halting the system respectively with similar
862 semantics. exit causes the manager to exit following the normal
863 shutdown procedure, and exit-force causes it terminate without
864 shutting down services. When exit or exit-force is used by default
865 the exit status of the main process of the unit (if this applies)
866 is returned from the service manager. However, this may be
867 overridden with FailureActionExitStatus=/SuccessActionExitStatus=,
868 see below. soft-reboot will trigger a userspace reboot operation.
869 soft-reboot-force does that too, but does not go through the
870 shutdown transaction beforehand.
871
872 FailureActionExitStatus=, SuccessActionExitStatus=
873 Controls the exit status to propagate back to an invoking container
874 manager (in case of a system service) or service manager (in case
875 of a user manager) when the FailureAction=/SuccessAction= are set
876 to exit or exit-force and the action is triggered. By default the
877 exit status of the main process of the triggering unit (if this
878 applies) is propagated. Takes a value in the range 0...255 or the
879 empty string to request default behaviour.
880
881 JobTimeoutSec=, JobRunningTimeoutSec=
882 JobTimeoutSec= specifies a timeout for the whole job that starts
883 running when the job is queued. JobRunningTimeoutSec= specifies a
884 timeout that starts running when the queued job is actually
885 started. If either limit is reached, the job will be cancelled, the
886 unit however will not change state or even enter the "failed" mode.
887
888 Both settings take a time span with the default unit of seconds,
889 but other units may be specified, see systemd.time(5). The default
890 is "infinity" (job timeouts disabled), except for device units
891 where JobRunningTimeoutSec= defaults to DefaultDeviceTimeoutSec=.
892
893 Note: these timeouts are independent from any unit-specific
894 timeouts (for example, the timeout set with TimeoutStartSec= in
895 service units). The job timeout has no effect on the unit itself.
896 Or in other words: unit-specific timeouts are useful to abort unit
897 state changes, and revert them. The job timeout set with this
898 option however is useful to abort only the job waiting for the unit
899 state to change.
900
901 JobTimeoutAction=, JobTimeoutRebootArgument=
902 JobTimeoutAction= optionally configures an additional action to
903 take when the timeout is hit, see description of JobTimeoutSec= and
904 JobRunningTimeoutSec= above. It takes the same values as
905 StartLimitAction=. Defaults to none.
906
907 JobTimeoutRebootArgument= configures an optional reboot string to
908 pass to the reboot(2) system call.
909
910 StartLimitIntervalSec=interval, StartLimitBurst=burst
911 Configure unit start rate limiting. Units which are started more
912 than burst times within an interval time span are not permitted to
913 start any more. Use StartLimitIntervalSec= to configure the
914 checking interval and StartLimitBurst= to configure how many starts
915 per interval are allowed.
916
917 interval is a time span with the default unit of seconds, but other
918 units may be specified, see systemd.time(5). Defaults to
919 DefaultStartLimitIntervalSec= in manager configuration file, and
920 may be set to 0 to disable any kind of rate limiting. burst is a
921 number and defaults to DefaultStartLimitBurst= in manager
922 configuration file.
923
924 These configuration options are particularly useful in conjunction
925 with the service setting Restart= (see systemd.service(5));
926 however, they apply to all kinds of starts (including manual), not
927 just those triggered by the Restart= logic.
928
929 Note that units which are configured for Restart=, and which reach
930 the start limit are not attempted to be restarted anymore; however,
931 they may still be restarted manually or from a timer or socket at a
932 later point, after the interval has passed. From that point on, the
933 restart logic is activated again. systemctl reset-failed will
934 cause the restart rate counter for a service to be flushed, which
935 is useful if the administrator wants to manually start a unit and
936 the start limit interferes with that. Rate-limiting is enforced
937 after any unit condition checks are executed, and hence unit
938 activations with failing conditions do not count towards the rate
939 limit.
940
941 When a unit is unloaded due to the garbage collection logic (see
942 above) its rate limit counters are flushed out too. This means that
943 configuring start rate limiting for a unit that is not referenced
944 continuously has no effect.
945
946 This setting does not apply to slice, target, device, and scope
947 units, since they are unit types whose activation may either never
948 fail, or may succeed only a single time.
949
950 StartLimitAction=
951 Configure an additional action to take if the rate limit configured
952 with StartLimitIntervalSec= and StartLimitBurst= is hit. Takes the
953 same values as the FailureAction=/SuccessAction= settings. If none
954 is set, hitting the rate limit will trigger no action except that
955 the start will not be permitted. Defaults to none.
956
957 RebootArgument=
958 Configure the optional argument for the reboot(2) system call if
959 StartLimitAction= or FailureAction= is a reboot action. This works
960 just like the optional argument to systemctl reboot command.
961
962 SourcePath=
963 A path to a configuration file this unit has been generated from.
964 This is primarily useful for implementation of generator tools that
965 convert configuration from an external configuration file format
966 into native unit files. This functionality should not be used in
967 normal units.
968
969 Conditions and Asserts
970 Unit files may also include a number of Condition...= and Assert...=
971 settings. Before the unit is started, systemd will verify that the
972 specified conditions and asserts are true. If not, the starting of the
973 unit will be (mostly silently) skipped (in case of conditions), or
974 aborted with an error message (in case of asserts). Failing conditions
975 or asserts will not result in the unit being moved into the "failed"
976 state. The conditions and asserts are checked at the time the queued
977 start job is to be executed. The ordering dependencies are still
978 respected, so other units are still pulled in and ordered as if this
979 unit was successfully activated, and the conditions and asserts are
980 executed the precise moment the unit would normally start and thus can
981 validate system state after the units ordered before completed
982 initialization. Use condition expressions for skipping units that do
983 not apply to the local system, for example because the kernel or
984 runtime environment doesn't require their functionality.
985
986 If multiple conditions are specified, the unit will be executed if all
987 of them apply (i.e. a logical AND is applied). Condition checks can use
988 a pipe symbol ("|") after the equals sign ("Condition...=|..."), which
989 causes the condition to become a triggering condition. If at least one
990 triggering condition is defined for a unit, then the unit will be
991 started if at least one of the triggering conditions of the unit
992 applies and all of the regular (i.e. non-triggering) conditions apply.
993 If you prefix an argument with the pipe symbol and an exclamation mark,
994 the pipe symbol must be passed first, the exclamation second. If any of
995 these options is assigned the empty string, the list of conditions is
996 reset completely, all previous condition settings (of any kind) will
997 have no effect.
998
999 The AssertArchitecture=, AssertVirtualization=, ... options are similar
1000 to conditions but cause the start job to fail (instead of being
1001 skipped). The failed check is logged. Units with unmet conditions are
1002 considered to be in a clean state and will be garbage collected if they
1003 are not referenced. This means that when queried, the condition failure
1004 may or may not show up in the state of the unit.
1005
1006 Note that neither assertion nor condition expressions result in unit
1007 state changes. Also note that both are checked at the time the job is
1008 to be executed, i.e. long after depending jobs and it itself were
1009 queued. Thus, neither condition nor assertion expressions are suitable
1010 for conditionalizing unit dependencies.
1011
1012 The condition verb of systemd-analyze(1) can be used to test condition
1013 and assert expressions.
1014
1015 Except for ConditionPathIsSymbolicLink=, all path checks follow
1016 symlinks.
1017
1018 ConditionArchitecture=
1019 Check whether the system is running on a specific architecture.
1020 Takes one of "x86", "x86-64", "ppc", "ppc-le", "ppc64", "ppc64-le",
1021 "ia64", "parisc", "parisc64", "s390", "s390x", "sparc", "sparc64",
1022 "mips", "mips-le", "mips64", "mips64-le", "alpha", "arm", "arm-be",
1023 "arm64", "arm64-be", "sh", "sh64", "m68k", "tilegx", "cris", "arc",
1024 "arc-be", or "native".
1025
1026 The architecture is determined from the information returned by
1027 uname(2) and is thus subject to personality(2). Note that a
1028 Personality= setting in the same unit file has no effect on this
1029 condition. A special architecture name "native" is mapped to the
1030 architecture the system manager itself is compiled for. The test
1031 may be negated by prepending an exclamation mark.
1032
1033 ConditionFirmware=
1034 Check whether the system's firmware is of a certain type. The
1035 following values are possible:
1036
1037 • "uefi" matches systems with EFI.
1038
1039 • "device-tree" matches systems with a device tree.
1040
1041 • "device-tree-compatible(value)" matches systems with a device
1042 tree that are compatible with "value".
1043
1044 • "smbios-field(field operator value)" matches systems with a
1045 SMBIOS field containing a certain value. field is the name of
1046 the SMBIOS field exposed as "sysfs" attribute file below
1047 /sys/class/dmi/id/. operator is one of "<", "<=", ">=", ">",
1048 "==", "<>" for version comparisons, "=" and "!=" for literal
1049 string comparisons, or "$=", "!$=" for shell-style glob
1050 comparisons. value is the expected value of the SMBIOS field
1051 value (possibly containing shell style globs in case "$="/"!$="
1052 is used).
1053
1054 ConditionVirtualization=
1055 Check whether the system is executed in a virtualized environment
1056 and optionally test whether it is a specific implementation. Takes
1057 either boolean value to check if being executed in any virtualized
1058 environment, or one of "vm" and "container" to test against a
1059 generic type of virtualization solution, or one of "qemu", "kvm",
1060 "amazon", "zvm", "vmware", "microsoft", "oracle", "powervm", "xen",
1061 "bochs", "uml", "bhyve", "qnx", "apple", "sre", "openvz", "lxc",
1062 "lxc-libvirt", "systemd-nspawn", "docker", "podman", "rkt", "wsl",
1063 "proot", "pouch", "acrn" to test against a specific implementation,
1064 or "private-users" to check whether we are running in a user
1065 namespace. See systemd-detect-virt(1) for a full list of known
1066 virtualization technologies and their identifiers. If multiple
1067 virtualization technologies are nested, only the innermost is
1068 considered. The test may be negated by prepending an exclamation
1069 mark.
1070
1071 ConditionHost=
1072 ConditionHost= may be used to match against the hostname or machine
1073 ID of the host. This either takes a hostname string (optionally
1074 with shell style globs) which is tested against the locally set
1075 hostname as returned by gethostname(2), or a machine ID formatted
1076 as string (see machine-id(5)). The test may be negated by
1077 prepending an exclamation mark.
1078
1079 ConditionKernelCommandLine=
1080 ConditionKernelCommandLine= may be used to check whether a specific
1081 kernel command line option is set (or if prefixed with the
1082 exclamation mark — unset). The argument must either be a single
1083 word, or an assignment (i.e. two words, separated by "="). In the
1084 former case the kernel command line is searched for the word
1085 appearing as is, or as left hand side of an assignment. In the
1086 latter case, the exact assignment is looked for with right and left
1087 hand side matching. This operates on the kernel command line
1088 communicated to userspace via /proc/cmdline, except when the
1089 service manager is invoked as payload of a container manager, in
1090 which case the command line of PID 1 is used instead (i.e.
1091 /proc/1/cmdline).
1092
1093 ConditionKernelVersion=
1094 ConditionKernelVersion= may be used to check whether the kernel
1095 version (as reported by uname -r) matches a certain expression, or
1096 if prefixed with the exclamation mark, does not match. The argument
1097 must be a list of (potentially quoted) expressions. Each expression
1098 starts with one of "=" or "!=" for string comparisons, "<", "<=",
1099 "==", "<>", ">=", ">" for version comparisons, or "$=", "!$=" for a
1100 shell-style glob match. If no operator is specified, "$=" is
1101 implied.
1102
1103 Note that using the kernel version string is an unreliable way to
1104 determine which features are supported by a kernel, because of the
1105 widespread practice of backporting drivers, features, and fixes
1106 from newer upstream kernels into older versions provided by
1107 distributions. Hence, this check is inherently unportable and
1108 should not be used for units which may be used on different
1109 distributions.
1110
1111 ConditionCredential=
1112 ConditionCredential= may be used to check whether a credential by
1113 the specified name was passed into the service manager. See System
1114 and Service Credentials[2] for details about credentials. If used
1115 in services for the system service manager this may be used to
1116 conditionalize services based on system credentials passed in. If
1117 used in services for the per-user service manager this may be used
1118 to conditionalize services based on credentials passed into the
1119 unit@.service service instance belonging to the user. The argument
1120 must be a valid credential name.
1121
1122 ConditionEnvironment=
1123 ConditionEnvironment= may be used to check whether a specific
1124 environment variable is set (or if prefixed with the exclamation
1125 mark — unset) in the service manager's environment block. The
1126 argument may be a single word, to check if the variable with this
1127 name is defined in the environment block, or an assignment
1128 ("name=value"), to check if the variable with this exact value is
1129 defined. Note that the environment block of the service manager
1130 itself is checked, i.e. not any variables defined with Environment=
1131 or EnvironmentFile=, as described above. This is particularly
1132 useful when the service manager runs inside a containerized
1133 environment or as per-user service manager, in order to check for
1134 variables passed in by the enclosing container manager or PAM.
1135
1136 ConditionSecurity=
1137 ConditionSecurity= may be used to check whether the given security
1138 technology is enabled on the system. Currently, the recognized
1139 values are "selinux", "apparmor", "tomoyo", "ima", "smack",
1140 "audit", "uefi-secureboot", "tpm2" and "cvm". The test may be
1141 negated by prepending an exclamation mark.
1142
1143 ConditionCapability=
1144 Check whether the given capability exists in the capability
1145 bounding set of the service manager (i.e. this does not check
1146 whether capability is actually available in the permitted or
1147 effective sets, see capabilities(7) for details). Pass a capability
1148 name such as "CAP_MKNOD", possibly prefixed with an exclamation
1149 mark to negate the check.
1150
1151 ConditionACPower=
1152 Check whether the system has AC power, or is exclusively battery
1153 powered at the time of activation of the unit. This takes a boolean
1154 argument. If set to "true", the condition will hold only if at
1155 least one AC connector of the system is connected to a power
1156 source, or if no AC connectors are known. Conversely, if set to
1157 "false", the condition will hold only if there is at least one AC
1158 connector known and all AC connectors are disconnected from a power
1159 source.
1160
1161 ConditionNeedsUpdate=
1162 Takes one of /var/ or /etc/ as argument, possibly prefixed with a
1163 "!" (to invert the condition). This condition may be used to
1164 conditionalize units on whether the specified directory requires an
1165 update because /usr/'s modification time is newer than the stamp
1166 file .updated in the specified directory. This is useful to
1167 implement offline updates of the vendor operating system resources
1168 in /usr/ that require updating of /etc/ or /var/ on the next
1169 following boot. Units making use of this condition should order
1170 themselves before systemd-update-done.service(8), to make sure they
1171 run before the stamp file's modification time gets reset indicating
1172 a completed update.
1173
1174 If the systemd.condition-needs-update= option is specified on the
1175 kernel command line (taking a boolean), it will override the result
1176 of this condition check, taking precedence over any file
1177 modification time checks. If the kernel command line option is
1178 used, systemd-update-done.service will not have immediate effect on
1179 any following ConditionNeedsUpdate= checks, until the system is
1180 rebooted where the kernel command line option is not specified
1181 anymore.
1182
1183 Note that to make this scheme effective, the timestamp of /usr/
1184 should be explicitly updated after its contents are modified. The
1185 kernel will automatically update modification timestamp on a
1186 directory only when immediate children of a directory are modified;
1187 an modification of nested files will not automatically result in
1188 mtime of /usr/ being updated.
1189
1190 Also note that if the update method includes a call to execute
1191 appropriate post-update steps itself, it should not touch the
1192 timestamp of /usr/. In a typical distribution packaging scheme,
1193 packages will do any required update steps as part of the
1194 installation or upgrade, to make package contents immediately
1195 usable. ConditionNeedsUpdate= should be used with other update
1196 mechanisms where such an immediate update does not happen.
1197
1198 ConditionFirstBoot=
1199 Takes a boolean argument. This condition may be used to
1200 conditionalize units on whether the system is booting up for the
1201 first time. This roughly means that /etc/ was unpopulated when the
1202 system started booting (for details, see "First Boot Semantics" in
1203 machine-id(5)). First boot is considered finished (this condition
1204 will evaluate as false) after the manager has finished the startup
1205 phase.
1206
1207 This condition may be used to populate /etc/ on the first boot
1208 after factory reset, or when a new system instance boots up for the
1209 first time.
1210
1211 For robustness, units with ConditionFirstBoot=yes should order
1212 themselves before first-boot-complete.target and pull in this
1213 passive target with Wants=. This ensures that in a case of an
1214 aborted first boot, these units will be re-run during the next
1215 system startup.
1216
1217 If the systemd.condition-first-boot= option is specified on the
1218 kernel command line (taking a boolean), it will override the result
1219 of this condition check, taking precedence over /etc/machine-id
1220 existence checks.
1221
1222 ConditionPathExists=
1223 Check for the existence of a file. If the specified absolute path
1224 name does not exist, the condition will fail. If the absolute path
1225 name passed to ConditionPathExists= is prefixed with an exclamation
1226 mark ("!"), the test is negated, and the unit is only started if
1227 the path does not exist.
1228
1229 ConditionPathExistsGlob=
1230 ConditionPathExistsGlob= is similar to ConditionPathExists=, but
1231 checks for the existence of at least one file or directory matching
1232 the specified globbing pattern.
1233
1234 ConditionPathIsDirectory=
1235 ConditionPathIsDirectory= is similar to ConditionPathExists= but
1236 verifies that a certain path exists and is a directory.
1237
1238 ConditionPathIsSymbolicLink=
1239 ConditionPathIsSymbolicLink= is similar to ConditionPathExists= but
1240 verifies that a certain path exists and is a symbolic link.
1241
1242 ConditionPathIsMountPoint=
1243 ConditionPathIsMountPoint= is similar to ConditionPathExists= but
1244 verifies that a certain path exists and is a mount point.
1245
1246 ConditionPathIsReadWrite=
1247 ConditionPathIsReadWrite= is similar to ConditionPathExists= but
1248 verifies that the underlying file system is readable and writable
1249 (i.e. not mounted read-only).
1250
1251 ConditionPathIsEncrypted=
1252 ConditionPathIsEncrypted= is similar to ConditionPathExists= but
1253 verifies that the underlying file system's backing block device is
1254 encrypted using dm-crypt/LUKS. Note that this check does not cover
1255 ext4 per-directory encryption, and only detects block level
1256 encryption. Moreover, if the specified path resides on a file
1257 system on top of a loopback block device, only encryption above the
1258 loopback device is detected. It is not detected whether the file
1259 system backing the loopback block device is encrypted.
1260
1261 ConditionDirectoryNotEmpty=
1262 ConditionDirectoryNotEmpty= is similar to ConditionPathExists= but
1263 verifies that a certain path exists and is a non-empty directory.
1264
1265 ConditionFileNotEmpty=
1266 ConditionFileNotEmpty= is similar to ConditionPathExists= but
1267 verifies that a certain path exists and refers to a regular file
1268 with a non-zero size.
1269
1270 ConditionFileIsExecutable=
1271 ConditionFileIsExecutable= is similar to ConditionPathExists= but
1272 verifies that a certain path exists, is a regular file, and marked
1273 executable.
1274
1275 ConditionUser=
1276 ConditionUser= takes a numeric "UID", a UNIX user name, or the
1277 special value "@system". This condition may be used to check
1278 whether the service manager is running as the given user. The
1279 special value "@system" can be used to check if the user id is
1280 within the system user range. This option is not useful for system
1281 services, as the system manager exclusively runs as the root user,
1282 and thus the test result is constant.
1283
1284 ConditionGroup=
1285 ConditionGroup= is similar to ConditionUser= but verifies that the
1286 service manager's real or effective group, or any of its auxiliary
1287 groups, match the specified group or GID. This setting does not
1288 support the special value "@system".
1289
1290 ConditionControlGroupController=
1291 Check whether given cgroup controllers (e.g. "cpu") are available
1292 for use on the system or whether the legacy v1 cgroup or the modern
1293 v2 cgroup hierarchy is used.
1294
1295 Multiple controllers may be passed with a space separating them; in
1296 this case the condition will only pass if all listed controllers
1297 are available for use. Controllers unknown to systemd are ignored.
1298 Valid controllers are "cpu", "io", "memory", and "pids". Even if
1299 available in the kernel, a particular controller may not be
1300 available if it was disabled on the kernel command line with
1301 cgroup_disable=controller.
1302
1303 Alternatively, two special strings "v1" and "v2" may be specified
1304 (without any controller names). "v2" will pass if the unified v2
1305 cgroup hierarchy is used, and "v1" will pass if the legacy v1
1306 hierarchy or the hybrid hierarchy are used. Note that legacy or
1307 hybrid hierarchies have been deprecated. See systemd(1) for more
1308 information.
1309
1310 ConditionMemory=
1311 Verify that the specified amount of system memory is available to
1312 the current system. Takes a memory size in bytes as argument,
1313 optionally prefixed with a comparison operator "<", "<=", "=" (or
1314 "=="), "!=" (or "<>"), ">=", ">". On bare-metal systems compares
1315 the amount of physical memory in the system with the specified
1316 size, adhering to the specified comparison operator. In containers
1317 compares the amount of memory assigned to the container instead.
1318
1319 ConditionCPUs=
1320 Verify that the specified number of CPUs is available to the
1321 current system. Takes a number of CPUs as argument, optionally
1322 prefixed with a comparison operator "<", "<=", "=" (or "=="), "!="
1323 (or "<>"), ">=", ">". Compares the number of CPUs in the CPU
1324 affinity mask configured of the service manager itself with the
1325 specified number, adhering to the specified comparison operator. On
1326 physical systems the number of CPUs in the affinity mask of the
1327 service manager usually matches the number of physical CPUs, but in
1328 special and virtual environments might differ. In particular, in
1329 containers the affinity mask usually matches the number of CPUs
1330 assigned to the container and not the physically available ones.
1331
1332 ConditionCPUFeature=
1333 Verify that a given CPU feature is available via the "CPUID"
1334 instruction. This condition only does something on i386 and x86-64
1335 processors. On other processors it is assumed that the CPU does not
1336 support the given feature. It checks the leaves "1", "7",
1337 "0x80000001", and "0x80000007". Valid values are: "fpu", "vme",
1338 "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "apic", "sep",
1339 "mtrr", "pge", "mca", "cmov", "pat", "pse36", "clflush", "mmx",
1340 "fxsr", "sse", "sse2", "ht", "pni", "pclmul", "monitor", "ssse3",
1341 "fma3", "cx16", "sse4_1", "sse4_2", "movbe", "popcnt", "aes",
1342 "xsave", "osxsave", "avx", "f16c", "rdrand", "bmi1", "avx2",
1343 "bmi2", "rdseed", "adx", "sha_ni", "syscall", "rdtscp", "lm",
1344 "lahf_lm", "abm", "constant_tsc".
1345
1346 ConditionOSRelease=
1347 Verify that a specific "key=value" pair is set in the host's os-
1348 release(5).
1349
1350 Other than exact string matching (with "=" and "!="), relative
1351 comparisons are supported for versioned parameters (e.g.
1352 "VERSION_ID"; with "<", "<=", "==", "<>", ">=", ">"), and
1353 shell-style wildcard comparisons ("*", "?", "[]") are supported
1354 with the "$=" (match) and "!$=" (non-match).
1355
1356 ConditionMemoryPressure=, ConditionCPUPressure=, ConditionIOPressure=
1357 Verify that the overall system (memory, CPU or IO) pressure is
1358 below or equal to a threshold. This setting takes a threshold value
1359 as argument. It can be specified as a simple percentage value,
1360 suffixed with "%", in which case the pressure will be measured as
1361 an average over the last five minutes before the attempt to start
1362 the unit is performed. Alternatively, the average timespan can also
1363 be specified using "/" as a separator, for example: "10%/1min". The
1364 supported timespans match what the kernel provides, and are limited
1365 to "10sec", "1min" and "5min". The "full" PSI will be checked
1366 first, and if not found "some" will be checked. For more details,
1367 see the documentation on PSI (Pressure Stall Information)[3].
1368
1369 Optionally, the threshold value can be prefixed with the slice unit
1370 under which the pressure will be checked, followed by a ":". If the
1371 slice unit is not specified, the overall system pressure will be
1372 measured, instead of a particular cgroup's.
1373
1374 AssertArchitecture=, AssertVirtualization=, AssertHost=,
1375 AssertKernelCommandLine=, AssertKernelVersion=, AssertCredential=,
1376 AssertEnvironment=, AssertSecurity=, AssertCapability=, AssertACPower=,
1377 AssertNeedsUpdate=, AssertFirstBoot=, AssertPathExists=,
1378 AssertPathExistsGlob=, AssertPathIsDirectory=,
1379 AssertPathIsSymbolicLink=, AssertPathIsMountPoint=,
1380 AssertPathIsReadWrite=, AssertPathIsEncrypted=,
1381 AssertDirectoryNotEmpty=, AssertFileNotEmpty=, AssertFileIsExecutable=,
1382 AssertUser=, AssertGroup=, AssertControlGroupController=,
1383 AssertMemory=, AssertCPUs=, AssertCPUFeature=, AssertOSRelease=,
1384 AssertMemoryPressure=, AssertCPUPressure=, AssertIOPressure=
1385 Similar to the ConditionArchitecture=, ConditionVirtualization=,
1386 ..., condition settings described above, these settings add
1387 assertion checks to the start-up of the unit. However, unlike the
1388 conditions settings, any assertion setting that is not met results
1389 in failure of the start job (which means this is logged loudly).
1390 Note that hitting a configured assertion does not cause the unit to
1391 enter the "failed" state (or in fact result in any state change of
1392 the unit), it affects only the job queued for it. Use assertion
1393 expressions for units that cannot operate when specific
1394 requirements are not met, and when this is something the
1395 administrator or user should look into.
1396
1398 Unit settings that create a relationship with a second unit usually
1399 show up in properties of both units, for example in systemctl show
1400 output. In some cases the name of the property is the same as the name
1401 of the configuration setting, but not always. This table lists the
1402 properties that are shown on two units which are connected through some
1403 dependency, and shows which property on "source" unit corresponds to
1404 which property on the "target" unit.
1405
1406 Table 3. Forward and reverse unit properties
1407 ┌──────────────────────┬───────────────────────┬─────────────────────────────────┐
1408 │"Forward" │ "Reverse" │ Where used │
1409 │property │ property │ │
1410 ├──────────────────────┼───────────────────────┼─────────────────────────────────┤
1411 │Before= │ After= │ │
1412 ├──────────────────────┼───────────────────────┤ [Unit] section │
1413 │After= │ Before= │ │
1414 ├──────────────────────┼───────────────────────┼─────────────────┬───────────────┤
1415 │Requires= │ RequiredBy= │ [Unit] section │ [Install] │
1416 │ │ │ │ section │
1417 ├──────────────────────┼───────────────────────┼─────────────────┼───────────────┤
1418 │Wants= │ WantedBy= │ [Unit] section │ [Install] │
1419 │ │ │ │ section │
1420 ├──────────────────────┼───────────────────────┼─────────────────┼───────────────┤
1421 │Upholds= │ UpheldBy= │ [Unit] section │ [Install] │
1422 │ │ │ │ section │
1423 ├──────────────────────┼───────────────────────┼─────────────────┼───────────────┤
1424 │PartOf= │ ConsistsOf= │ [Unit] section │ an automatic │
1425 │ │ │ │ property │
1426 ├──────────────────────┼───────────────────────┼─────────────────┼───────────────┤
1427 │BindsTo= │ BoundBy= │ [Unit] section │ an automatic │
1428 │ │ │ │ property │
1429 ├──────────────────────┼───────────────────────┼─────────────────┼───────────────┤
1430 │Requisite= │ RequisiteOf= │ [Unit] section │ an automatic │
1431 │ │ │ │ property │
1432 ├──────────────────────┼───────────────────────┼─────────────────┼───────────────┤
1433 │Conflicts= │ ConflictedBy= │ [Unit] section │ an automatic │
1434 │ │ │ │ property │
1435 ├──────────────────────┼───────────────────────┼─────────────────┴───────────────┤
1436 │Triggers= │ TriggeredBy= │ Automatic properties, see notes │
1437 │ │ │ below │
1438 ├──────────────────────┼───────────────────────┼─────────────────────────────────┤
1439 │PropagatesReloadTo= │ ReloadPropagatedFrom= │ │
1440 ├──────────────────────┼───────────────────────┤ [Unit] section │
1441 │ReloadPropagatedFrom= │ PropagatesReloadTo= │ │
1442 ├──────────────────────┼───────────────────────┼─────────────────────────────────┤
1443 │PropagatesStopTo= │ StopPropagatedFrom= │ │
1444 ├──────────────────────┼───────────────────────┤ [Unit] section │
1445 │StopPropagatedFrom= │ PropagatesStopTo= │ │
1446 ├──────────────────────┼───────────────────────┼─────────────────┬───────────────┤
1447 │Following= │ n/a │ An automatic │ │
1448 │ │ │ property │ │
1449 └──────────────────────┴───────────────────────┴─────────────────┴───────────────┘
1450
1451 Note: WantedBy=, RequiredBy=, and UpheldBy= are used in the [Install]
1452 section to create symlinks in .wants/, .requires/, and .upholds/
1453 directories. They cannot be used directly as a unit configuration
1454 setting.
1455
1456 Note: ConsistsOf=, BoundBy=, RequisiteOf=, ConflictedBy= are created
1457 implicitly along with their reverses and cannot be specified directly.
1458
1459 Note: Triggers= is created implicitly between a socket, path unit, or
1460 an automount unit, and the unit they activate. By default a unit with
1461 the same name is triggered, but this can be overridden using Sockets=,
1462 Service=, and Unit= settings. See systemd.service(5),
1463 systemd.socket(5), systemd.path(5), and systemd.automount(5) for
1464 details. TriggeredBy= is created implicitly on the triggered unit.
1465
1466 Note: Following= is used to group device aliases and points to the
1467 "primary" device unit that systemd is using to track device state,
1468 usually corresponding to a sysfs path. It does not show up in the
1469 "target" unit.
1470
1472 Unit files may include an [Install] section, which carries installation
1473 information for the unit. This section is not interpreted by systemd(1)
1474 during runtime; it is used by the enable and disable commands of the
1475 systemctl(1) tool during installation of a unit.
1476
1477 Alias=
1478 A space-separated list of additional names this unit shall be
1479 installed under. The names listed here must have the same suffix
1480 (i.e. type) as the unit filename. This option may be specified more
1481 than once, in which case all listed names are used. At installation
1482 time, systemctl enable will create symlinks from these names to the
1483 unit filename. Note that not all unit types support such alias
1484 names, and this setting is not supported for them. Specifically,
1485 mount, slice, swap, and automount units do not support aliasing.
1486
1487 WantedBy=, RequiredBy=, UpheldBy=
1488 This option may be used more than once, or a space-separated list
1489 of unit names may be given. A symbolic link is created in the
1490 .wants/, .requires/, or .upholds/ directory of each of the listed
1491 units when this unit is installed by systemctl enable. This has the
1492 effect of a dependency of type Wants=, Requires=, or Upholds= being
1493 added from the listed unit to the current unit. See the description
1494 of the mentioned dependency types in the [Unit] section for
1495 details.
1496
1497 In case of template units listing non template units, the listing
1498 unit must have DefaultInstance= set, or systemctl enable must be
1499 called with an instance name. The instance (default or specified)
1500 will be added to the .wants/, .requires/, or .upholds/ list of the
1501 listed unit. For example, WantedBy=getty.target in a service
1502 getty@.service will result in systemctl enable getty@tty2.service
1503 creating a getty.target.wants/getty@tty2.service link to
1504 getty@.service. This also applies to listing specific instances of
1505 templated units: this specific instance will gain the dependency. A
1506 template unit may also list a template unit, in which case a
1507 generic dependency will be added where each instance of the listing
1508 unit will have a dependency on an instance of the listed template
1509 with the same instance value. For example,
1510 WantedBy=container@.target in a service monitor@.service will
1511 result in systemctl enable monitor@.service creating a
1512 container@.target.wants/monitor@.service link to monitor@.service,
1513 which applies to all instances of container@.target.
1514
1515 Also=
1516 Additional units to install/deinstall when this unit is
1517 installed/deinstalled. If the user requests
1518 installation/deinstallation of a unit with this option configured,
1519 systemctl enable and systemctl disable will automatically
1520 install/uninstall units listed in this option as well.
1521
1522 This option may be used more than once, or a space-separated list
1523 of unit names may be given.
1524
1525 DefaultInstance=
1526 In template unit files, this specifies for which instance the unit
1527 shall be enabled if the template is enabled without any explicitly
1528 set instance. This option has no effect in non-template unit files.
1529 The specified string must be usable as instance identifier.
1530
1531 The following specifiers are interpreted in the Install section: %a,
1532 %b, %B, %g, %G, %H, %i, %j, %l, %m, %n, %N, %o, %p, %u, %U, %v, %w, %W,
1533 %%. For their meaning see the next section.
1534
1536 Many settings resolve specifiers which may be used to write generic
1537 unit files referring to runtime or unit parameters that are replaced
1538 when the unit files are loaded. Specifiers must be known and resolvable
1539 for the setting to be valid. The following specifiers are understood:
1540
1541 Table 4. Specifiers available in unit files
1542 ┌──────────┬─────────────────────┬──────────────────────────┐
1543 │Specifier │ Meaning │ Details │
1544 ├──────────┼─────────────────────┼──────────────────────────┤
1545 │"%a" │ Architecture │ A short string │
1546 │ │ │ identifying the │
1547 │ │ │ architecture of the │
1548 │ │ │ local system. A │
1549 │ │ │ string such as x86, │
1550 │ │ │ x86-64 or arm64. │
1551 │ │ │ See the │
1552 │ │ │ architectures │
1553 │ │ │ defined for │
1554 │ │ │ ConditionArchitecture= │
1555 │ │ │ above for a full │
1556 │ │ │ list. │
1557 ├──────────┼─────────────────────┼──────────────────────────┤
1558 │"%A" │ Operating system │ The operating system │
1559 │ │ image version │ image version │
1560 │ │ │ identifier of the │
1561 │ │ │ running system, as │
1562 │ │ │ read from the │
1563 │ │ │ IMAGE_VERSION= field │
1564 │ │ │ of /etc/os-release. If │
1565 │ │ │ not set, resolves to │
1566 │ │ │ an empty string. See │
1567 │ │ │ os-release(5) for more │
1568 │ │ │ information. │
1569 ├──────────┼─────────────────────┼──────────────────────────┤
1570 │"%b" │ Boot ID │ The boot ID of the │
1571 │ │ │ running system, │
1572 │ │ │ formatted as string. │
1573 │ │ │ See random(4) for more │
1574 │ │ │ information. │
1575 ├──────────┼─────────────────────┼──────────────────────────┤
1576 │"%B" │ Operating system │ The operating system │
1577 │ │ build ID │ build identifier of │
1578 │ │ │ the running system, as │
1579 │ │ │ read from the │
1580 │ │ │ BUILD_ID= field of │
1581 │ │ │ /etc/os-release. If │
1582 │ │ │ not set, resolves to │
1583 │ │ │ an empty string. See │
1584 │ │ │ os-release(5) for more │
1585 │ │ │ information. │
1586 ├──────────┼─────────────────────┼──────────────────────────┤
1587 │"%C" │ Cache directory │ This is either │
1588 │ │ root │ /var/cache (for the │
1589 │ │ │ system manager) or the │
1590 │ │ │ path "$XDG_CACHE_HOME" │
1591 │ │ │ resolves to (for user │
1592 │ │ │ managers). │
1593 ├──────────┼─────────────────────┼──────────────────────────┤
1594 │"%d" │ Credentials │ This is the value of │
1595 │ │ directory │ the │
1596 │ │ │ "$CREDENTIALS_DIRECTORY" │
1597 │ │ │ environment variable │
1598 │ │ │ if available. See │
1599 │ │ │ section "Credentials" │
1600 │ │ │ in systemd.exec(5) for │
1601 │ │ │ more information. │
1602 ├──────────┼─────────────────────┼──────────────────────────┤
1603 │"%E" │ Configuration │ This is either /etc/ │
1604 │ │ directory root │ (for the system manager) │
1605 │ │ │ or the path │
1606 │ │ │ "$XDG_CONFIG_HOME" │
1607 │ │ │ resolves to (for user │
1608 │ │ │ managers). │
1609 ├──────────┼─────────────────────┼──────────────────────────┤
1610 │"%f" │ Unescaped filename │ This is either the │
1611 │ │ │ unescaped instance name │
1612 │ │ │ (if applicable) with / │
1613 │ │ │ prepended (if │
1614 │ │ │ applicable), or the │
1615 │ │ │ unescaped prefix name │
1616 │ │ │ prepended with /. This │
1617 │ │ │ implements unescaping │
1618 │ │ │ according to the rules │
1619 │ │ │ for escaping absolute │
1620 │ │ │ file system paths │
1621 │ │ │ discussed above. │
1622 ├──────────┼─────────────────────┼──────────────────────────┤
1623 │"%g" │ User group │ This is the name of the │
1624 │ │ │ group running the │
1625 │ │ │ service manager │
1626 │ │ │ instance. In case of the │
1627 │ │ │ system manager this │
1628 │ │ │ resolves to "root". │
1629 ├──────────┼─────────────────────┼──────────────────────────┤
1630 │"%G" │ User GID │ This is the numeric GID │
1631 │ │ │ of the user running the │
1632 │ │ │ service manager │
1633 │ │ │ instance. In case of the │
1634 │ │ │ system manager this │
1635 │ │ │ resolves to "0". │
1636 ├──────────┼─────────────────────┼──────────────────────────┤
1637 │"%h" │ User home directory │ This is the home │
1638 │ │ │ directory of the user │
1639 │ │ │ running the service │
1640 │ │ │ manager instance. In │
1641 │ │ │ case of the system │
1642 │ │ │ manager this resolves to │
1643 │ │ │ "/root". │
1644 │ │ │ │
1645 │ │ │ Note that this setting │
1646 │ │ │ is not influenced by the │
1647 │ │ │ User= setting │
1648 │ │ │ configurable in the │
1649 │ │ │ [Service] section of the │
1650 │ │ │ service unit. │
1651 ├──────────┼─────────────────────┼──────────────────────────┤
1652 │"%H" │ Host name │ The hostname of the │
1653 │ │ │ running system at the │
1654 │ │ │ point in time the unit │
1655 │ │ │ configuration is loaded. │
1656 ├──────────┼─────────────────────┼──────────────────────────┤
1657 │"%i" │ Instance name │ For instantiated units │
1658 │ │ │ this is the string │
1659 │ │ │ between the first "@" │
1660 │ │ │ character and the type │
1661 │ │ │ suffix. Empty for │
1662 │ │ │ non-instantiated units. │
1663 ├──────────┼─────────────────────┼──────────────────────────┤
1664 │"%I" │ Unescaped instance │ Same as "%i", but with │
1665 │ │ name │ escaping undone. │
1666 ├──────────┼─────────────────────┼──────────────────────────┤
1667 │"%j" │ Final component of │ This is the string │
1668 │ │ the prefix │ between the last "-" and │
1669 │ │ │ the end of the prefix │
1670 │ │ │ name. If there is no │
1671 │ │ │ "-", this is the same as │
1672 │ │ │ "%p". │
1673 ├──────────┼─────────────────────┼──────────────────────────┤
1674 │"%J" │ Unescaped final │ Same as "%j", but with │
1675 │ │ component of the │ escaping undone. │
1676 │ │ prefix │ │
1677 ├──────────┼─────────────────────┼──────────────────────────┤
1678 │"%l" │ Short host name │ The hostname of the │
1679 │ │ │ running system at the │
1680 │ │ │ point in time the unit │
1681 │ │ │ configuration is loaded, │
1682 │ │ │ truncated at the first │
1683 │ │ │ dot to remove any domain │
1684 │ │ │ component. │
1685 ├──────────┼─────────────────────┼──────────────────────────┤
1686 │"%L" │ Log directory root │ This is either /var/log │
1687 │ │ │ (for the system manager) │
1688 │ │ │ or the path │
1689 │ │ │ $XDG_STATE_HOME resolves │
1690 │ │ │ to with /log appended │
1691 │ │ │ (for user managers). │
1692 ├──────────┼─────────────────────┼──────────────────────────┤
1693 │"%m" │ Machine ID │ The machine ID of the │
1694 │ │ │ running system, │
1695 │ │ │ formatted as string. See │
1696 │ │ │ machine-id(5) for more │
1697 │ │ │ information. │
1698 ├──────────┼─────────────────────┼──────────────────────────┤
1699 │"%M" │ Operating system │ The operating system │
1700 │ │ image identifier │ image identifier of the │
1701 │ │ │ running system, as read │
1702 │ │ │ from the IMAGE_ID= field │
1703 │ │ │ of /etc/os-release. If │
1704 │ │ │ not set, resolves to an │
1705 │ │ │ empty string. See os- │
1706 │ │ │ release(5) for more │
1707 │ │ │ information. │
1708 ├──────────┼─────────────────────┼──────────────────────────┤
1709 │"%n" │ Full unit name │ │
1710 ├──────────┼─────────────────────┼──────────────────────────┤
1711 │"%N" │ Full unit name │ Same as "%n", but with │
1712 │ │ │ the type suffix removed. │
1713 ├──────────┼─────────────────────┼──────────────────────────┤
1714 │"%o" │ Operating system ID │ The operating system │
1715 │ │ │ identifier of the │
1716 │ │ │ running system, as read │
1717 │ │ │ from the ID= field of │
1718 │ │ │ /etc/os-release. See os- │
1719 │ │ │ release(5) for more │
1720 │ │ │ information. │
1721 ├──────────┼─────────────────────┼──────────────────────────┤
1722 │"%p" │ Prefix name │ For instantiated units, │
1723 │ │ │ this refers to the │
1724 │ │ │ string before the first │
1725 │ │ │ "@" character of the │
1726 │ │ │ unit name. For │
1727 │ │ │ non-instantiated units, │
1728 │ │ │ same as "%N". │
1729 ├──────────┼─────────────────────┼──────────────────────────┤
1730 │"%P" │ Unescaped prefix │ Same as "%p", but with │
1731 │ │ name │ escaping undone. │
1732 ├──────────┼─────────────────────┼──────────────────────────┤
1733 │"%q" │ Pretty host name │ The pretty hostname of │
1734 │ │ │ the running system at │
1735 │ │ │ the point in time the │
1736 │ │ │ unit configuration is │
1737 │ │ │ loaded, as read from the │
1738 │ │ │ PRETTY_HOSTNAME= field │
1739 │ │ │ of /etc/machine-info. If │
1740 │ │ │ not set, resolves to the │
1741 │ │ │ short hostname. See │
1742 │ │ │ machine-info(5) for more │
1743 │ │ │ information. │
1744 ├──────────┼─────────────────────┼──────────────────────────┤
1745 │"%s" │ User shell │ This is the shell of the │
1746 │ │ │ user running the service │
1747 │ │ │ manager instance. │
1748 ├──────────┼─────────────────────┼──────────────────────────┤
1749 │"%S" │ State directory │ This is either /var/lib │
1750 │ │ root │ (for the system manager) │
1751 │ │ │ or the path │
1752 │ │ │ $XDG_STATE_HOME resolves │
1753 │ │ │ to (for user managers). │
1754 ├──────────┼─────────────────────┼──────────────────────────┤
1755 │"%t" │ Runtime directory │ This is either /run/ │
1756 │ │ root │ (for the system manager) │
1757 │ │ │ or the path │
1758 │ │ │ "$XDG_RUNTIME_DIR" │
1759 │ │ │ resolves to (for user │
1760 │ │ │ managers). │
1761 ├──────────┼─────────────────────┼──────────────────────────┤
1762 │"%T" │ Directory for │ This is either /tmp or │
1763 │ │ temporary files │ the path "$TMPDIR", │
1764 │ │ │ "$TEMP" or "$TMP" are │
1765 │ │ │ set to. (Note that the │
1766 │ │ │ directory may be │
1767 │ │ │ specified without a │
1768 │ │ │ trailing slash.) │
1769 ├──────────┼─────────────────────┼──────────────────────────┤
1770 │"%u" │ User name │ This is the name of the │
1771 │ │ │ user running the service │
1772 │ │ │ manager instance. In │
1773 │ │ │ case of the system │
1774 │ │ │ manager this resolves to │
1775 │ │ │ "root". │
1776 │ │ │ │
1777 │ │ │ Note that this setting │
1778 │ │ │ is not influenced by the │
1779 │ │ │ User= setting │
1780 │ │ │ configurable in the │
1781 │ │ │ [Service] section of the │
1782 │ │ │ service unit. │
1783 ├──────────┼─────────────────────┼──────────────────────────┤
1784 │"%U" │ User UID │ This is the numeric UID │
1785 │ │ │ of the user running the │
1786 │ │ │ service manager │
1787 │ │ │ instance. In case of the │
1788 │ │ │ system manager this │
1789 │ │ │ resolves to "0". │
1790 │ │ │ │
1791 │ │ │ Note that this setting │
1792 │ │ │ is not influenced by the │
1793 │ │ │ User= setting │
1794 │ │ │ configurable in the │
1795 │ │ │ [Service] section of the │
1796 │ │ │ service unit. │
1797 ├──────────┼─────────────────────┼──────────────────────────┤
1798 │"%v" │ Kernel release │ Identical to uname -r │
1799 │ │ │ output. │
1800 ├──────────┼─────────────────────┼──────────────────────────┤
1801 │"%V" │ Directory for │ This is either /var/tmp │
1802 │ │ larger and │ or the path "$TMPDIR", │
1803 │ │ persistent │ "$TEMP" or "$TMP" are │
1804 │ │ temporary files │ set to. (Note that the │
1805 │ │ │ directory may be │
1806 │ │ │ specified without a │
1807 │ │ │ trailing slash.) │
1808 ├──────────┼─────────────────────┼──────────────────────────┤
1809 │"%w" │ Operating system │ The operating system │
1810 │ │ version ID │ version identifier of │
1811 │ │ │ the running system, as │
1812 │ │ │ read from the │
1813 │ │ │ VERSION_ID= field of │
1814 │ │ │ /etc/os-release. If not │
1815 │ │ │ set, resolves to an │
1816 │ │ │ empty string. See os- │
1817 │ │ │ release(5) for more │
1818 │ │ │ information. │
1819 ├──────────┼─────────────────────┼──────────────────────────┤
1820 │"%W" │ Operating system │ The operating system │
1821 │ │ variant ID │ variant identifier of │
1822 │ │ │ the running system, as │
1823 │ │ │ read from the │
1824 │ │ │ VARIANT_ID= field of │
1825 │ │ │ /etc/os-release. If not │
1826 │ │ │ set, resolves to an │
1827 │ │ │ empty string. See os- │
1828 │ │ │ release(5) for more │
1829 │ │ │ information. │
1830 ├──────────┼─────────────────────┼──────────────────────────┤
1831 │"%y" │ The path to the │ This is the path where │
1832 │ │ fragment │ the main part of the │
1833 │ │ │ unit file is located. │
1834 │ │ │ For linked unit files, │
1835 │ │ │ the real path outside of │
1836 │ │ │ the unit search │
1837 │ │ │ directories is used. For │
1838 │ │ │ units that don't have a │
1839 │ │ │ fragment file, this │
1840 │ │ │ specifier will raise an │
1841 │ │ │ error. │
1842 ├──────────┼─────────────────────┼──────────────────────────┤
1843 │"%Y" │ The directory of │ This is the directory │
1844 │ │ the fragment │ part of "%y". │
1845 ├──────────┼─────────────────────┼──────────────────────────┤
1846 │"%%" │ Single percent sign │ Use "%%" in place of "%" │
1847 │ │ │ to specify a single │
1848 │ │ │ percent sign. │
1849 └──────────┴─────────────────────┴──────────────────────────┘
1850
1852 Example 1. Allowing units to be enabled
1853
1854 The following snippet (highlighted) allows a unit (e.g. foo.service)
1855 to be enabled via systemctl enable:
1856
1857 [Unit]
1858 Description=Foo
1859
1860 [Service]
1861 ExecStart=/usr/sbin/foo-daemon
1862
1863 [Install]
1864 WantedBy=multi-user.target
1865
1866 After running systemctl enable, a symlink
1867 /etc/systemd/system/multi-user.target.wants/foo.service linking to the
1868 actual unit will be created. It tells systemd to pull in the unit when
1869 starting multi-user.target. The inverse systemctl disable will remove
1870 that symlink again.
1871
1872 Example 2. Overriding vendor settings
1873
1874 There are two methods of overriding vendor settings in unit files:
1875 copying the unit file from /usr/lib/systemd/system to
1876 /etc/systemd/system and modifying the chosen settings. Alternatively,
1877 one can create a directory named unit.d/ within /etc/systemd/system and
1878 place a drop-in file name.conf there that only changes the specific
1879 settings one is interested in. Note that multiple such drop-in files
1880 are read if present, processed in lexicographic order of their
1881 filename.
1882
1883 The advantage of the first method is that one easily overrides the
1884 complete unit, the vendor unit is not parsed at all anymore. It has the
1885 disadvantage that improvements to the unit file by the vendor are not
1886 automatically incorporated on updates.
1887
1888 The advantage of the second method is that one only overrides the
1889 settings one specifically wants, where updates to the unit by the
1890 vendor automatically apply. This has the disadvantage that some future
1891 updates by the vendor might be incompatible with the local changes.
1892
1893 This also applies for user instances of systemd, but with different
1894 locations for the unit files. See the section on unit load paths for
1895 further details.
1896
1897 Suppose there is a vendor-supplied unit
1898 /usr/lib/systemd/system/httpd.service with the following contents:
1899
1900 [Unit]
1901 Description=Some HTTP server
1902 After=remote-fs.target sqldb.service
1903 Requires=sqldb.service
1904 AssertPathExists=/srv/webserver
1905
1906 [Service]
1907 Type=notify
1908 ExecStart=/usr/sbin/some-fancy-httpd-server
1909 Nice=5
1910
1911 [Install]
1912 WantedBy=multi-user.target
1913
1914 Now one wants to change some settings as an administrator: firstly, in
1915 the local setup, /srv/webserver might not exist, because the HTTP
1916 server is configured to use /srv/www instead. Secondly, the local
1917 configuration makes the HTTP server also depend on a memory cache
1918 service, memcached.service, that should be pulled in (Requires=) and
1919 also be ordered appropriately (After=). Thirdly, in order to harden the
1920 service a bit more, the administrator would like to set the PrivateTmp=
1921 setting (see systemd.exec(5) for details). And lastly, the
1922 administrator would like to reset the niceness of the service to its
1923 default value of 0.
1924
1925 The first possibility is to copy the unit file to
1926 /etc/systemd/system/httpd.service and change the chosen settings:
1927
1928 [Unit]
1929 Description=Some HTTP server
1930 After=remote-fs.target sqldb.service memcached.service
1931 Requires=sqldb.service memcached.service
1932 AssertPathExists=/srv/www
1933
1934 [Service]
1935 Type=notify
1936 ExecStart=/usr/sbin/some-fancy-httpd-server
1937 Nice=0
1938 PrivateTmp=yes
1939
1940 [Install]
1941 WantedBy=multi-user.target
1942
1943 Alternatively, the administrator could create a drop-in file
1944 /etc/systemd/system/httpd.service.d/local.conf with the following
1945 contents:
1946
1947 [Unit]
1948 After=memcached.service
1949 Requires=memcached.service
1950 # Reset all assertions and then re-add the condition we want
1951 AssertPathExists=
1952 AssertPathExists=/srv/www
1953
1954 [Service]
1955 Nice=0
1956 PrivateTmp=yes
1957
1958 Note that for drop-in files, if one wants to remove entries from a
1959 setting that is parsed as a list (and is not a dependency), such as
1960 AssertPathExists= (or e.g. ExecStart= in service units), one needs to
1961 first clear the list before re-adding all entries except the one that
1962 is to be removed. Dependencies (After=, etc.) cannot be reset to an
1963 empty list, so dependencies can only be added in drop-ins. If you want
1964 to remove dependencies, you have to override the entire unit.
1965
1966 Example 3. Top level drop-ins with template units
1967
1968 Top level per-type drop-ins can be used to change some aspect of all
1969 units of a particular type. For example, by creating the
1970 /etc/systemd/system/service.d/ directory with a drop-in file, the
1971 contents of the drop-in file can be applied to all service units. We
1972 can take this further by having the top-level drop-in instantiate a
1973 secondary helper unit. Consider for example the following set of units
1974 and drop-in files where we install an OnFailure= dependency for all
1975 service units.
1976
1977 /etc/systemd/system/failure-handler@.service:
1978
1979 [Unit]
1980 Description=My failure handler for %i
1981
1982 [Service]
1983 Type=oneshot
1984 # Perform some special action for when %i exits unexpectedly.
1985 ExecStart=/usr/sbin/myfailurehandler %i
1986
1987
1988 We can then add an instance of failure-handler@.service as an
1989 OnFailure= dependency for all service units.
1990
1991 /etc/systemd/system/service.d/10-all.conf:
1992
1993 [Unit]
1994 OnFailure=failure-handler@%N.service
1995
1996
1997 Now, after running systemctl daemon-reload all services will have
1998 acquired an OnFailure= dependency on failure-handler@%N.service. The
1999 template instance units will also have gained the dependency which
2000 results in the creation of a recursive dependency chain. systemd will
2001 try to detect these recursive dependency chains where a template unit
2002 directly and recursively depends on itself and will remove such
2003 dependencies automatically if it finds them. If systemd doesn't detect
2004 the recursive dependency chain, we can break the chain ourselves by
2005 disabling the drop-in for the template instance units via a symlink to
2006 /dev/null:
2007
2008 mkdir /etc/systemd/system/failure-handler@.service.d/
2009 ln -s /dev/null /etc/systemd/system/failure-handler@.service.d/10-all.conf
2010 systemctl daemon-reload
2011
2012
2013 This ensures that if a failure-handler@.service instance fails it will
2014 not trigger an instance named failure-handler@failure-handler.service.
2015
2017 systemd(1), systemctl(1), systemd-system.conf(5), systemd.special(7),
2018 systemd.service(5), systemd.socket(5), systemd.device(5),
2019 systemd.mount(5), systemd.automount(5), systemd.swap(5),
2020 systemd.target(5), systemd.path(5), systemd.timer(5), systemd.scope(5),
2021 systemd.slice(5), systemd.time(7), systemd-analyze(1), capabilities(7),
2022 systemd.directives(7), uname(1)
2023
2025 1. Interface Portability and Stability Promise
2026 https://systemd.io/PORTABILITY_AND_STABILITY/
2027
2028 2. System and Service Credentials
2029 https://systemd.io/CREDENTIALS
2030
2031 3. PSI (Pressure Stall Information)
2032 https://docs.kernel.org/accounting/psi.html
2033
2034
2035
2036systemd 254 SYSTEMD.UNIT(5)