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