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