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