1SYSTEMD.EXEC(5) systemd.exec SYSTEMD.EXEC(5)
2
3
4
6 systemd.exec - Execution environment configuration
7
9 service.service, socket.socket, mount.mount, swap.swap
10
12 Unit configuration files for services, sockets, mount points, and swap
13 devices share a subset of configuration options which define the
14 execution environment of spawned processes.
15
16 This man page lists the configuration options shared by these four unit
17 types. See systemd.unit(5) for the common options of all unit
18 configuration files, and systemd.service(5), systemd.socket(5),
19 systemd.swap(5), and systemd.mount(5) for more information on the
20 specific unit configuration files. The execution specific configuration
21 options are configured in the [Service], [Socket], [Mount], or [Swap]
22 sections, depending on the unit type.
23
24 In addition, options which control resources through Linux Control
25 Groups (cgroups) are listed in systemd.resource-control(5). Those
26 options complement options listed here.
27
29 A few execution parameters result in additional, automatic dependencies
30 to be added:
31
32 • Units with WorkingDirectory=, RootDirectory=, RootImage=,
33 RuntimeDirectory=, StateDirectory=, CacheDirectory=, LogsDirectory=
34 or ConfigurationDirectory= set automatically gain dependencies of
35 type Requires= and After= on all mount units required to access the
36 specified paths. This is equivalent to having them listed
37 explicitly in RequiresMountsFor=.
38
39 • Similarly, units with PrivateTmp= enabled automatically get mount
40 unit dependencies for all mounts required to access /tmp/ and
41 /var/tmp/. They will also gain an automatic After= dependency on
42 systemd-tmpfiles-setup.service(8).
43
44 • Units whose standard output or error output is connected to journal
45 or kmsg (or their combinations with console output, see below)
46 automatically acquire dependencies of type After= on
47 systemd-journald.socket.
48
49 • Units using LogNamespace= will automatically gain ordering and
50 requirement dependencies on the two socket units associated with
51 systemd-journald@.service instances.
52
54 The following settings may be used to change a service's view of the
55 filesystem. Please note that the paths must be absolute and must not
56 contain a ".." path component.
57
58 ExecSearchPath=
59 Takes a colon separated list of absolute paths relative to which
60 the executable used by the Exec*= (e.g. ExecStart=, ExecStop=,
61 etc.) properties can be found. ExecSearchPath= overrides $PATH if
62 $PATH is not supplied by the user through Environment=,
63 EnvironmentFile= or PassEnvironment=. Assigning an empty string
64 removes previous assignments and setting ExecSearchPath= to a value
65 multiple times will append to the previous setting.
66
67 WorkingDirectory=
68 Takes a directory path relative to the service's root directory
69 specified by RootDirectory=, or the special value "~". Sets the
70 working directory for executed processes. If set to "~", the home
71 directory of the user specified in User= is used. If not set,
72 defaults to the root directory when systemd is running as a system
73 instance and the respective user's home directory if run as user.
74 If the setting is prefixed with the "-" character, a missing
75 working directory is not considered fatal. If
76 RootDirectory=/RootImage= is not set, then WorkingDirectory= is
77 relative to the root of the system running the service manager.
78 Note that setting this parameter might result in additional
79 dependencies to be added to the unit (see above).
80
81 RootDirectory=
82 Takes a directory path relative to the host's root directory (i.e.
83 the root of the system running the service manager). Sets the root
84 directory for executed processes, with the chroot(2) system call.
85 If this is used, it must be ensured that the process binary and all
86 its auxiliary files are available in the chroot() jail. Note that
87 setting this parameter might result in additional dependencies to
88 be added to the unit (see above).
89
90 The MountAPIVFS= and PrivateUsers= settings are particularly useful
91 in conjunction with RootDirectory=. For details, see below.
92
93 If RootDirectory=/RootImage= are used together with NotifyAccess=
94 the notification socket is automatically mounted from the host into
95 the root environment, to ensure the notification interface can work
96 correctly.
97
98 Note that services using RootDirectory=/RootImage= will not be able
99 to log via the syslog or journal protocols to the host logging
100 infrastructure, unless the relevant sockets are mounted from the
101 host, specifically:
102
103 Example 1. Mounting logging sockets into root environment
104
105 BindReadOnlyPaths=/dev/log /run/systemd/journal/socket /run/systemd/journal/stdout
106
107 This option is only available for system services, or for services
108 running in per-user instances of the service manager when
109 PrivateUsers= is enabled.
110
111 RootImage=
112 Takes a path to a block device node or regular file as argument.
113 This call is similar to RootDirectory= however mounts a file system
114 hierarchy from a block device node or loopback file instead of a
115 directory. The device node or file system image file needs to
116 contain a file system without a partition table, or a file system
117 within an MBR/MS-DOS or GPT partition table with only a single
118 Linux-compatible partition, or a set of file systems within a GPT
119 partition table that follows the Discoverable Partitions
120 Specification[1].
121
122 When DevicePolicy= is set to "closed" or "strict", or set to "auto"
123 and DeviceAllow= is set, then this setting adds /dev/loop-control
124 with rw mode, "block-loop" and "block-blkext" with rwm mode to
125 DeviceAllow=. See systemd.resource-control(5) for the details about
126 DevicePolicy= or DeviceAllow=. Also, see PrivateDevices= below, as
127 it may change the setting of DevicePolicy=.
128
129 Units making use of RootImage= automatically gain an After=
130 dependency on systemd-udevd.service.
131
132 This option is only available for system services and is not
133 supported for services running in per-user instances of the service
134 manager.
135
136 RootImageOptions=
137 Takes a comma-separated list of mount options that will be used on
138 disk images specified by RootImage=. Optionally a partition name
139 can be prefixed, followed by colon, in case the image has multiple
140 partitions, otherwise partition name "root" is implied. Options for
141 multiple partitions can be specified in a single line with space
142 separators. Assigning an empty string removes previous assignments.
143 Duplicated options are ignored. For a list of valid mount options,
144 please refer to mount(8).
145
146 Valid partition names follow the Discoverable Partitions
147 Specification[1]: root, usr, home, srv, esp, xbootldr, tmp, var.
148
149 This option is only available for system services and is not
150 supported for services running in per-user instances of the service
151 manager.
152
153 RootHash=
154 Takes a data integrity (dm-verity) root hash specified in
155 hexadecimal, or the path to a file containing a root hash in ASCII
156 hexadecimal format. This option enables data integrity checks using
157 dm-verity, if the used image contains the appropriate integrity
158 data (see above) or if RootVerity= is used. The specified hash must
159 match the root hash of integrity data, and is usually at least 256
160 bits (and hence 64 formatted hexadecimal characters) long (in case
161 of SHA256 for example). If this option is not specified, but the
162 image file carries the "user.verity.roothash" extended file
163 attribute (see xattr(7)), then the root hash is read from it, also
164 as formatted hexadecimal characters. If the extended file attribute
165 is not found (or is not supported by the underlying file system),
166 but a file with the .roothash suffix is found next to the image
167 file, bearing otherwise the same name (except if the image has the
168 .raw suffix, in which case the root hash file must not have it in
169 its name), the root hash is read from it and automatically used,
170 also as formatted hexadecimal characters.
171
172 If the disk image contains a separate /usr/ partition it may also
173 be Verity protected, in which case the root hash may configured via
174 an extended attribute "user.verity.usrhash" or a .usrhash file
175 adjacent to the disk image. There's currently no option to
176 configure the root hash for the /usr/ file system via the unit file
177 directly.
178
179 This option is only available for system services and is not
180 supported for services running in per-user instances of the service
181 manager.
182
183 RootHashSignature=
184 Takes a PKCS7 signature of the RootHash= option as a path to a
185 DER-encoded signature file, or as an ASCII base64 string encoding
186 of a DER-encoded signature prefixed by "base64:". The dm-verity
187 volume will only be opened if the signature of the root hash is
188 valid and signed by a public key present in the kernel keyring. If
189 this option is not specified, but a file with the .roothash.p7s
190 suffix is found next to the image file, bearing otherwise the same
191 name (except if the image has the .raw suffix, in which case the
192 signature file must not have it in its name), the signature is read
193 from it and automatically used.
194
195 If the disk image contains a separate /usr/ partition it may also
196 be Verity protected, in which case the signature for the root hash
197 may configured via a .usrhash.p7s file adjacent to the disk image.
198 There's currently no option to configure the root hash signature
199 for the /usr/ via the unit file directly.
200
201 This option is only available for system services and is not
202 supported for services running in per-user instances of the service
203 manager.
204
205 RootVerity=
206 Takes the path to a data integrity (dm-verity) file. This option
207 enables data integrity checks using dm-verity, if RootImage= is
208 used and a root-hash is passed and if the used image itself does
209 not contains the integrity data. The integrity data must be matched
210 by the root hash. If this option is not specified, but a file with
211 the .verity suffix is found next to the image file, bearing
212 otherwise the same name (except if the image has the .raw suffix,
213 in which case the verity data file must not have it in its name),
214 the verity data is read from it and automatically used.
215
216 This option is supported only for disk images that contain a single
217 file system, without an enveloping partition table. Images that
218 contain a GPT partition table should instead include both root file
219 system and matching Verity data in the same image, implementing the
220 Discoverable Partitions Specification[1].
221
222 This option is only available for system services and is not
223 supported for services running in per-user instances of the service
224 manager.
225
226 MountAPIVFS=
227 Takes a boolean argument. If on, a private mount namespace for the
228 unit's processes is created and the API file systems /proc/, /sys/,
229 /dev/ and /run/ (as an empty "tmpfs") are mounted inside of it,
230 unless they are already mounted. Note that this option has no
231 effect unless used in conjunction with RootDirectory=/RootImage= as
232 these four mounts are generally mounted in the host anyway, and
233 unless the root directory is changed, the private mount namespace
234 will be a 1:1 copy of the host's, and include these four mounts.
235 Note that the /dev/ file system of the host is bind mounted if this
236 option is used without PrivateDevices=. To run the service with a
237 private, minimal version of /dev/, combine this option with
238 PrivateDevices=.
239
240 In order to allow propagating mounts at runtime in a safe manner,
241 /run/systemd/propagate on the host will be used to set up new
242 mounts, and /run/host/incoming/ in the private namespace will be
243 used as an intermediate step to store them before being moved to
244 the final mount point.
245
246 ProtectProc=
247 Takes one of "noaccess", "invisible", "ptraceable" or "default"
248 (which it defaults to). When set, this controls the "hidepid="
249 mount option of the "procfs" instance for the unit that controls
250 which directories with process metainformation (/proc/PID) are
251 visible and accessible: when set to "noaccess" the ability to
252 access most of other users' process metadata in /proc/ is taken
253 away for processes of the service. When set to "invisible"
254 processes owned by other users are hidden from /proc/. If
255 "ptraceable" all processes that cannot be ptrace()'ed by a process
256 are hidden to it. If "default" no restrictions on /proc/ access or
257 visibility are made. For further details see The /proc
258 Filesystem[2]. It is generally recommended to run most system
259 services with this option set to "invisible". This option is
260 implemented via file system namespacing, and thus cannot be used
261 with services that shall be able to install mount points in the
262 host file system hierarchy. Note that the root user is unaffected
263 by this option, so to be effective it has to be used together with
264 User= or DynamicUser=yes, and also without the "CAP_SYS_PTRACE"
265 capability, which also allows a process to bypass this feature. It
266 cannot be used for services that need to access metainformation
267 about other users' processes. This option implies MountAPIVFS=.
268
269 If the kernel doesn't support per-mount point hidepid= mount
270 options this setting remains without effect, and the unit's
271 processes will be able to access and see other process as if the
272 option was not used.
273
274 This option is only available for system services and is not
275 supported for services running in per-user instances of the service
276 manager.
277
278 ProcSubset=
279 Takes one of "all" (the default) and "pid". If "pid", all files and
280 directories not directly associated with process management and
281 introspection are made invisible in the /proc/ file system
282 configured for the unit's processes. This controls the "subset="
283 mount option of the "procfs" instance for the unit. For further
284 details see The /proc Filesystem[2]. Note that Linux exposes
285 various kernel APIs via /proc/, which are made unavailable with
286 this setting. Since these APIs are used frequently this option is
287 useful only in a few, specific cases, and is not suitable for most
288 non-trivial programs.
289
290 Much like ProtectProc= above, this is implemented via file system
291 mount namespacing, and hence the same restrictions apply: it is
292 only available to system services, it disables mount propagation to
293 the host mount table, and it implies MountAPIVFS=. Also, like
294 ProtectProc= this setting is gracefully disabled if the used kernel
295 does not support the "subset=" mount option of "procfs".
296
297 BindPaths=, BindReadOnlyPaths=
298 Configures unit-specific bind mounts. A bind mount makes a
299 particular file or directory available at an additional place in
300 the unit's view of the file system. Any bind mounts created with
301 this option are specific to the unit, and are not visible in the
302 host's mount table. This option expects a whitespace separated list
303 of bind mount definitions. Each definition consists of a
304 colon-separated triple of source path, destination path and option
305 string, where the latter two are optional. If only a source path is
306 specified the source and destination is taken to be the same. The
307 option string may be either "rbind" or "norbind" for configuring a
308 recursive or non-recursive bind mount. If the destination path is
309 omitted, the option string must be omitted too. Each bind mount
310 definition may be prefixed with "-", in which case it will be
311 ignored when its source path does not exist.
312
313 BindPaths= creates regular writable bind mounts (unless the source
314 file system mount is already marked read-only), while
315 BindReadOnlyPaths= creates read-only bind mounts. These settings
316 may be used more than once, each usage appends to the unit's list
317 of bind mounts. If the empty string is assigned to either of these
318 two options the entire list of bind mounts defined prior to this is
319 reset. Note that in this case both read-only and regular bind
320 mounts are reset, regardless which of the two settings is used.
321
322 This option is particularly useful when RootDirectory=/RootImage=
323 is used. In this case the source path refers to a path on the host
324 file system, while the destination path refers to a path below the
325 root directory of the unit.
326
327 Note that the destination directory must exist or systemd must be
328 able to create it. Thus, it is not possible to use those options
329 for mount points nested underneath paths specified in
330 InaccessiblePaths=, or under /home/ and other protected directories
331 if ProtectHome=yes is specified. TemporaryFileSystem= with ":ro"
332 or ProtectHome=tmpfs should be used instead.
333
334 MountImages=
335 This setting is similar to RootImage= in that it mounts a file
336 system hierarchy from a block device node or loopback file, but the
337 destination directory can be specified as well as mount options.
338 This option expects a whitespace separated list of mount
339 definitions. Each definition consists of a colon-separated tuple of
340 source path and destination definitions, optionally followed by
341 another colon and a list of mount options.
342
343 Mount options may be defined as a single comma-separated list of
344 options, in which case they will be implicitly applied to the root
345 partition on the image, or a series of colon-separated tuples of
346 partition name and mount options. Valid partition names and mount
347 options are the same as for RootImageOptions= setting described
348 above.
349
350 Each mount definition may be prefixed with "-", in which case it
351 will be ignored when its source path does not exist. The source
352 argument is a path to a block device node or regular file. If
353 source or destination contain a ":", it needs to be escaped as
354 "\:". The device node or file system image file needs to follow the
355 same rules as specified for RootImage=. Any mounts created with
356 this option are specific to the unit, and are not visible in the
357 host's mount table.
358
359 These settings may be used more than once, each usage appends to
360 the unit's list of mount paths. If the empty string is assigned,
361 the entire list of mount paths defined prior to this is reset.
362
363 Note that the destination directory must exist or systemd must be
364 able to create it. Thus, it is not possible to use those options
365 for mount points nested underneath paths specified in
366 InaccessiblePaths=, or under /home/ and other protected directories
367 if ProtectHome=yes is specified.
368
369 When DevicePolicy= is set to "closed" or "strict", or set to "auto"
370 and DeviceAllow= is set, then this setting adds /dev/loop-control
371 with rw mode, "block-loop" and "block-blkext" with rwm mode to
372 DeviceAllow=. See systemd.resource-control(5) for the details about
373 DevicePolicy= or DeviceAllow=. Also, see PrivateDevices= below, as
374 it may change the setting of DevicePolicy=.
375
376 This option is only available for system services and is not
377 supported for services running in per-user instances of the service
378 manager.
379
380 ExtensionImages=
381 This setting is similar to MountImages= in that it mounts a file
382 system hierarchy from a block device node or loopback file, but
383 instead of providing a destination path, an overlay will be set up.
384 This option expects a whitespace separated list of mount
385 definitions. Each definition consists of a source path, optionally
386 followed by a colon and a list of mount options.
387
388 A read-only OverlayFS will be set up on top of /usr/ and /opt/
389 hierarchies. The order in which the images are listed will
390 determine the order in which the overlay is laid down: images
391 specified first to last will result in overlayfs layers bottom to
392 top.
393
394 Mount options may be defined as a single comma-separated list of
395 options, in which case they will be implicitly applied to the root
396 partition on the image, or a series of colon-separated tuples of
397 partition name and mount options. Valid partition names and mount
398 options are the same as for RootImageOptions= setting described
399 above.
400
401 Each mount definition may be prefixed with "-", in which case it
402 will be ignored when its source path does not exist. The source
403 argument is a path to a block device node or regular file. If the
404 source path contains a ":", it needs to be escaped as "\:". The
405 device node or file system image file needs to follow the same
406 rules as specified for RootImage=. Any mounts created with this
407 option are specific to the unit, and are not visible in the host's
408 mount table.
409
410 These settings may be used more than once, each usage appends to
411 the unit's list of image paths. If the empty string is assigned,
412 the entire list of mount paths defined prior to this is reset.
413
414 Each image must carry a
415 /usr/lib/extension-release.d/extension-release.IMAGE file, with the
416 appropriate metadata which matches RootImage=/RootDirectory= or the
417 host. See: os-release(5).
418
419 When DevicePolicy= is set to "closed" or "strict", or set to "auto"
420 and DeviceAllow= is set, then this setting adds /dev/loop-control
421 with rw mode, "block-loop" and "block-blkext" with rwm mode to
422 DeviceAllow=. See systemd.resource-control(5) for the details about
423 DevicePolicy= or DeviceAllow=. Also, see PrivateDevices= below, as
424 it may change the setting of DevicePolicy=.
425
426 This option is only available for system services and is not
427 supported for services running in per-user instances of the service
428 manager.
429
430 ExtensionDirectories=
431 This setting is similar to BindReadOnlyPaths= in that it mounts a
432 file system hierarchy from a directory, but instead of providing a
433 destination path, an overlay will be set up. This option expects a
434 whitespace separated list of source directories.
435
436 A read-only OverlayFS will be set up on top of /usr/ and /opt/
437 hierarchies. The order in which the directories are listed will
438 determine the order in which the overlay is laid down: directories
439 specified first to last will result in overlayfs layers bottom to
440 top.
441
442 Each directory listed in ExtensionDirectories= may be prefixed with
443 "-", in which case it will be ignored when its source path does not
444 exist. Any mounts created with this option are specific to the
445 unit, and are not visible in the host's mount table.
446
447 These settings may be used more than once, each usage appends to
448 the unit's list of directories paths. If the empty string is
449 assigned, the entire list of mount paths defined prior to this is
450 reset.
451
452 Each directory must contain a
453 /usr/lib/extension-release.d/extension-release.IMAGE file, with the
454 appropriate metadata which matches RootImage=/RootDirectory= or the
455 host. See: os-release(5).
456
457 Note that usage from user units requires overlayfs support in
458 unprivileged user namespaces, which was first introduced in kernel
459 v5.11.
460
461 This option is only available for system services, or for services
462 running in per-user instances of the service manager when
463 PrivateUsers= is enabled.
464
466 These options are only available for system services and are not
467 supported for services running in per-user instances of the service
468 manager.
469
470 User=, Group=
471 Set the UNIX user or group that the processes are executed as,
472 respectively. Takes a single user or group name, or a numeric ID as
473 argument. For system services (services run by the system service
474 manager, i.e. managed by PID 1) and for user services of the root
475 user (services managed by root's instance of systemd --user), the
476 default is "root", but User= may be used to specify a different
477 user. For user services of any other user, switching user identity
478 is not permitted, hence the only valid setting is the same user the
479 user's service manager is running as. If no group is set, the
480 default group of the user is used. This setting does not affect
481 commands whose command line is prefixed with "+".
482
483 Note that this enforces only weak restrictions on the user/group
484 name syntax, but will generate warnings in many cases where
485 user/group names do not adhere to the following rules: the
486 specified name should consist only of the characters a-z, A-Z, 0-9,
487 "_" and "-", except for the first character which must be one of
488 a-z, A-Z and "_" (i.e. digits and "-" are not permitted as first
489 character). The user/group name must have at least one character,
490 and at most 31. These restrictions are made in order to avoid
491 ambiguities and to ensure user/group names and unit files remain
492 portable among Linux systems. For further details on the names
493 accepted and the names warned about see User/Group Name Syntax[3].
494
495 When used in conjunction with DynamicUser= the user/group name
496 specified is dynamically allocated at the time the service is
497 started, and released at the time the service is stopped — unless
498 it is already allocated statically (see below). If DynamicUser= is
499 not used the specified user and group must have been created
500 statically in the user database no later than the moment the
501 service is started, for example using the sysusers.d(5) facility,
502 which is applied at boot or package install time. If the user does
503 not exist by then program invocation will fail.
504
505 If the User= setting is used the supplementary group list is
506 initialized from the specified user's default group list, as
507 defined in the system's user and group database. Additional groups
508 may be configured through the SupplementaryGroups= setting (see
509 below).
510
511 DynamicUser=
512 Takes a boolean parameter. If set, a UNIX user and group pair is
513 allocated dynamically when the unit is started, and released as
514 soon as it is stopped. The user and group will not be added to
515 /etc/passwd or /etc/group, but are managed transiently during
516 runtime. The nss-systemd(8) glibc NSS module provides integration
517 of these dynamic users/groups into the system's user and group
518 databases. The user and group name to use may be configured via
519 User= and Group= (see above). If these options are not used and
520 dynamic user/group allocation is enabled for a unit, the name of
521 the dynamic user/group is implicitly derived from the unit name. If
522 the unit name without the type suffix qualifies as valid user name
523 it is used directly, otherwise a name incorporating a hash of it is
524 used. If a statically allocated user or group of the configured
525 name already exists, it is used and no dynamic user/group is
526 allocated. Note that if User= is specified and the static group
527 with the name exists, then it is required that the static user with
528 the name already exists. Similarly, if Group= is specified and the
529 static user with the name exists, then it is required that the
530 static group with the name already exists. Dynamic users/groups are
531 allocated from the UID/GID range 61184...65519. It is recommended
532 to avoid this range for regular system or login users. At any point
533 in time each UID/GID from this range is only assigned to zero or
534 one dynamically allocated users/groups in use. However, UID/GIDs
535 are recycled after a unit is terminated. Care should be taken that
536 any processes running as part of a unit for which dynamic
537 users/groups are enabled do not leave files or directories owned by
538 these users/groups around, as a different unit might get the same
539 UID/GID assigned later on, and thus gain access to these files or
540 directories. If DynamicUser= is enabled, RemoveIPC= and PrivateTmp=
541 are implied (and cannot be turned off). This ensures that the
542 lifetime of IPC objects and temporary files created by the executed
543 processes is bound to the runtime of the service, and hence the
544 lifetime of the dynamic user/group. Since /tmp/ and /var/tmp/ are
545 usually the only world-writable directories on a system this
546 ensures that a unit making use of dynamic user/group allocation
547 cannot leave files around after unit termination. Furthermore
548 NoNewPrivileges= and RestrictSUIDSGID= are implicitly enabled (and
549 cannot be disabled), to ensure that processes invoked cannot take
550 benefit or create SUID/SGID files or directories. Moreover
551 ProtectSystem=strict and ProtectHome=read-only are implied, thus
552 prohibiting the service to write to arbitrary file system
553 locations. In order to allow the service to write to certain
554 directories, they have to be allow-listed using ReadWritePaths=,
555 but care must be taken so that UID/GID recycling doesn't create
556 security issues involving files created by the service. Use
557 RuntimeDirectory= (see below) in order to assign a writable runtime
558 directory to a service, owned by the dynamic user/group and removed
559 automatically when the unit is terminated. Use StateDirectory=,
560 CacheDirectory= and LogsDirectory= in order to assign a set of
561 writable directories for specific purposes to the service in a way
562 that they are protected from vulnerabilities due to UID reuse (see
563 below). If this option is enabled, care should be taken that the
564 unit's processes do not get access to directories outside of these
565 explicitly configured and managed ones. Specifically, do not use
566 BindPaths= and be careful with AF_UNIX file descriptor passing for
567 directory file descriptors, as this would permit processes to
568 create files or directories owned by the dynamic user/group that
569 are not subject to the lifecycle and access guarantees of the
570 service. Defaults to off.
571
572 SupplementaryGroups=
573 Sets the supplementary Unix groups the processes are executed as.
574 This takes a space-separated list of group names or IDs. This
575 option may be specified more than once, in which case all listed
576 groups are set as supplementary groups. When the empty string is
577 assigned, the list of supplementary groups is reset, and all
578 assignments prior to this one will have no effect. In any way, this
579 option does not override, but extends the list of supplementary
580 groups configured in the system group database for the user. This
581 does not affect commands prefixed with "+".
582
583 PAMName=
584 Sets the PAM service name to set up a session as. If set, the
585 executed process will be registered as a PAM session under the
586 specified service name. This is only useful in conjunction with the
587 User= setting, and is otherwise ignored. If not set, no PAM session
588 will be opened for the executed processes. See pam(8) for details.
589
590 Note that for each unit making use of this option a PAM session
591 handler process will be maintained as part of the unit and stays
592 around as long as the unit is active, to ensure that appropriate
593 actions can be taken when the unit and hence the PAM session
594 terminates. This process is named "(sd-pam)" and is an immediate
595 child process of the unit's main process.
596
597 Note that when this option is used for a unit it is very likely
598 (depending on PAM configuration) that the main unit process will be
599 migrated to its own session scope unit when it is activated. This
600 process will hence be associated with two units: the unit it was
601 originally started from (and for which PAMName= was configured),
602 and the session scope unit. Any child processes of that process
603 will however be associated with the session scope unit only. This
604 has implications when used in combination with NotifyAccess=all, as
605 these child processes will not be able to affect changes in the
606 original unit through notification messages. These messages will be
607 considered belonging to the session scope unit and not the original
608 unit. It is hence not recommended to use PAMName= in combination
609 with NotifyAccess=all.
610
612 These options are only available for system services, or for services
613 running in per-user instances of the service manager when PrivateUsers=
614 is enabled.
615
616 CapabilityBoundingSet=
617 Controls which capabilities to include in the capability bounding
618 set for the executed process. See capabilities(7) for details.
619 Takes a whitespace-separated list of capability names, e.g.
620 CAP_SYS_ADMIN, CAP_DAC_OVERRIDE, CAP_SYS_PTRACE. Capabilities
621 listed will be included in the bounding set, all others are
622 removed. If the list of capabilities is prefixed with "~", all but
623 the listed capabilities will be included, the effect of the
624 assignment inverted. Note that this option also affects the
625 respective capabilities in the effective, permitted and inheritable
626 capability sets. If this option is not used, the capability
627 bounding set is not modified on process execution, hence no limits
628 on the capabilities of the process are enforced. This option may
629 appear more than once, in which case the bounding sets are merged
630 by OR, or by AND if the lines are prefixed with "~" (see below). If
631 the empty string is assigned to this option, the bounding set is
632 reset to the empty capability set, and all prior settings have no
633 effect. If set to "~" (without any further argument), the bounding
634 set is reset to the full set of available capabilities, also
635 undoing any previous settings. This does not affect commands
636 prefixed with "+".
637
638 Use systemd-analyze(1)'s capability command to retrieve a list of
639 capabilities defined on the local system.
640
641 Example: if a unit has the following,
642
643 CapabilityBoundingSet=CAP_A CAP_B
644 CapabilityBoundingSet=CAP_B CAP_C
645
646 then CAP_A, CAP_B, and CAP_C are set. If the second line is
647 prefixed with "~", e.g.,
648
649 CapabilityBoundingSet=CAP_A CAP_B
650 CapabilityBoundingSet=~CAP_B CAP_C
651
652 then, only CAP_A is set.
653
654 AmbientCapabilities=
655 Controls which capabilities to include in the ambient capability
656 set for the executed process. Takes a whitespace-separated list of
657 capability names, e.g. CAP_SYS_ADMIN, CAP_DAC_OVERRIDE,
658 CAP_SYS_PTRACE. This option may appear more than once in which case
659 the ambient capability sets are merged (see the above examples in
660 CapabilityBoundingSet=). If the list of capabilities is prefixed
661 with "~", all but the listed capabilities will be included, the
662 effect of the assignment inverted. If the empty string is assigned
663 to this option, the ambient capability set is reset to the empty
664 capability set, and all prior settings have no effect. If set to
665 "~" (without any further argument), the ambient capability set is
666 reset to the full set of available capabilities, also undoing any
667 previous settings. Note that adding capabilities to ambient
668 capability set adds them to the process's inherited capability set.
669
670 Ambient capability sets are useful if you want to execute a process
671 as a non-privileged user but still want to give it some
672 capabilities. Note that in this case option keep-caps is
673 automatically added to SecureBits= to retain the capabilities over
674 the user change. AmbientCapabilities= does not affect commands
675 prefixed with "+".
676
678 NoNewPrivileges=
679 Takes a boolean argument. If true, ensures that the service process
680 and all its children can never gain new privileges through execve()
681 (e.g. via setuid or setgid bits, or filesystem capabilities). This
682 is the simplest and most effective way to ensure that a process and
683 its children can never elevate privileges again. Defaults to false,
684 but certain settings override this and ignore the value of this
685 setting. This is the case when DynamicUser=, LockPersonality=,
686 MemoryDenyWriteExecute=, PrivateDevices=, ProtectClock=,
687 ProtectHostname=, ProtectKernelLogs=, ProtectKernelModules=,
688 ProtectKernelTunables=, RestrictAddressFamilies=,
689 RestrictNamespaces=, RestrictRealtime=, RestrictSUIDSGID=,
690 SystemCallArchitectures=, SystemCallFilter=, or SystemCallLog= are
691 specified. Note that even if this setting is overridden by them,
692 systemctl show shows the original value of this setting. In case
693 the service will be run in a new mount namespace anyway and SELinux
694 is disabled, all file systems are mounted with MS_NOSUID flag. Also
695 see No New Privileges Flag[4].
696
697 SecureBits=
698 Controls the secure bits set for the executed process. Takes a
699 space-separated combination of options from the following list:
700 keep-caps, keep-caps-locked, no-setuid-fixup,
701 no-setuid-fixup-locked, noroot, and noroot-locked. This option may
702 appear more than once, in which case the secure bits are ORed. If
703 the empty string is assigned to this option, the bits are reset to
704 0. This does not affect commands prefixed with "+". See
705 capabilities(7) for details.
706
708 These options are only available for system services and are not
709 supported for services running in per-user instances of the service
710 manager.
711
712 SELinuxContext=
713 Set the SELinux security context of the executed process. If set,
714 this will override the automated domain transition. However, the
715 policy still needs to authorize the transition. This directive is
716 ignored if SELinux is disabled. If prefixed by "-", failing to set
717 the SELinux security context will be ignored, but it's still
718 possible that the subsequent execve() may fail if the policy
719 doesn't allow the transition for the non-overridden context. This
720 does not affect commands prefixed with "+". See setexeccon(3) for
721 details.
722
723 AppArmorProfile=
724 Takes a profile name as argument. The process executed by the unit
725 will switch to this profile when started. Profiles must already be
726 loaded in the kernel, or the unit will fail. If prefixed by "-",
727 all errors will be ignored. This setting has no effect if AppArmor
728 is not enabled. This setting does not affect commands prefixed with
729 "+".
730
731 SmackProcessLabel=
732 Takes a SMACK64 security label as argument. The process executed by
733 the unit will be started under this label and SMACK will decide
734 whether the process is allowed to run or not, based on it. The
735 process will continue to run under the label specified here unless
736 the executable has its own SMACK64EXEC label, in which case the
737 process will transition to run under that label. When not
738 specified, the label that systemd is running under is used. This
739 directive is ignored if SMACK is disabled.
740
741 The value may be prefixed by "-", in which case all errors will be
742 ignored. An empty value may be specified to unset previous
743 assignments. This does not affect commands prefixed with "+".
744
746 LimitCPU=, LimitFSIZE=, LimitDATA=, LimitSTACK=, LimitCORE=, LimitRSS=,
747 LimitNOFILE=, LimitAS=, LimitNPROC=, LimitMEMLOCK=, LimitLOCKS=,
748 LimitSIGPENDING=, LimitMSGQUEUE=, LimitNICE=, LimitRTPRIO=,
749 LimitRTTIME=
750 Set soft and hard limits on various resources for executed
751 processes. See setrlimit(2) for details on the process resource
752 limit concept. Process resource limits may be specified in two
753 formats: either as single value to set a specific soft and hard
754 limit to the same value, or as colon-separated pair soft:hard to
755 set both limits individually (e.g. "LimitAS=4G:16G"). Use the
756 string infinity to configure no limit on a specific resource. The
757 multiplicative suffixes K, M, G, T, P and E (to the base 1024) may
758 be used for resource limits measured in bytes (e.g.
759 "LimitAS=16G"). For the limits referring to time values, the usual
760 time units ms, s, min, h and so on may be used (see systemd.time(7)
761 for details). Note that if no time unit is specified for LimitCPU=
762 the default unit of seconds is implied, while for LimitRTTIME= the
763 default unit of microseconds is implied. Also, note that the
764 effective granularity of the limits might influence their
765 enforcement. For example, time limits specified for LimitCPU= will
766 be rounded up implicitly to multiples of 1s. For LimitNICE= the
767 value may be specified in two syntaxes: if prefixed with "+" or
768 "-", the value is understood as regular Linux nice value in the
769 range -20...19. If not prefixed like this the value is understood
770 as raw resource limit parameter in the range 0...40 (with 0 being
771 equivalent to 1).
772
773 Note that most process resource limits configured with these
774 options are per-process, and processes may fork in order to acquire
775 a new set of resources that are accounted independently of the
776 original process, and may thus escape limits set. Also note that
777 LimitRSS= is not implemented on Linux, and setting it has no
778 effect. Often it is advisable to prefer the resource controls
779 listed in systemd.resource-control(5) over these per-process
780 limits, as they apply to services as a whole, may be altered
781 dynamically at runtime, and are generally more expressive. For
782 example, MemoryMax= is a more powerful (and working) replacement
783 for LimitRSS=.
784
785 Note that LimitNPROC= will limit the number of processes from one
786 (real) UID and not the number of processes started (forked) by the
787 service. Therefore the limit is cumulative for all processes
788 running under the same UID. Please also note that the LimitNPROC=
789 will not be enforced if the service is running as root (and not
790 dropping privileges). Due to these limitations, TasksMax= (see
791 systemd.resource-control(5)) is typically a better choice than
792 LimitNPROC=.
793
794 Resource limits not configured explicitly for a unit default to the
795 value configured in the various DefaultLimitCPU=,
796 DefaultLimitFSIZE=, ... options available in systemd-
797 system.conf(5), and – if not configured there – the kernel or
798 per-user defaults, as defined by the OS (the latter only for user
799 services, see below).
800
801 For system units these resource limits may be chosen freely. When
802 these settings are configured in a user service (i.e. a service run
803 by the per-user instance of the service manager) they cannot be
804 used to raise the limits above those set for the user manager
805 itself when it was first invoked, as the user's service manager
806 generally lacks the privileges to do so. In user context these
807 configuration options are hence only useful to lower the limits
808 passed in or to raise the soft limit to the maximum of the hard
809 limit as configured for the user. To raise the user's limits
810 further, the available configuration mechanisms differ between
811 operating systems, but typically require privileges. In most cases
812 it is possible to configure higher per-user resource limits via PAM
813 or by setting limits on the system service encapsulating the user's
814 service manager, i.e. the user's instance of user@.service. After
815 making such changes, make sure to restart the user's service
816 manager.
817
818 Table 1. Resource limit directives, their equivalent ulimit shell
819 commands and the unit used
820 ┌─────────────────┬────────────┬──────────────────┬───────────────────┐
821 │Directive │ ulimit │ Unit │ Notes │
822 │ │ equivalent │ │ │
823 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
824 │LimitCPU= │ ulimit -t │ Seconds │ - │
825 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
826 │LimitFSIZE= │ ulimit -f │ Bytes │ - │
827 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
828 │LimitDATA= │ ulimit -d │ Bytes │ Don't use. This │
829 │ │ │ │ limits the │
830 │ │ │ │ allowed address │
831 │ │ │ │ range, not │
832 │ │ │ │ memory use! │
833 │ │ │ │ Defaults to │
834 │ │ │ │ unlimited and │
835 │ │ │ │ should not be │
836 │ │ │ │ lowered. To │
837 │ │ │ │ limit memory │
838 │ │ │ │ use, see │
839 │ │ │ │ MemoryMax= in │
840 │ │ │ │ systemd.resource- │
841 │ │ │ │ control(5). │
842 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
843 │LimitSTACK= │ ulimit -s │ Bytes │ - │
844 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
845 │LimitCORE= │ ulimit -c │ Bytes │ - │
846 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
847 │LimitRSS= │ ulimit -m │ Bytes │ Don't use. No │
848 │ │ │ │ effect on Linux. │
849 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
850 │LimitNOFILE= │ ulimit -n │ Number of File │ Don't use. Be │
851 │ │ │ Descriptors │ careful when │
852 │ │ │ │ raising the soft │
853 │ │ │ │ limit above 1024, │
854 │ │ │ │ since select() │
855 │ │ │ │ cannot function │
856 │ │ │ │ with file │
857 │ │ │ │ descriptors above │
858 │ │ │ │ 1023 on Linux. │
859 │ │ │ │ Nowadays, the │
860 │ │ │ │ hard limit │
861 │ │ │ │ defaults to │
862 │ │ │ │ 524288, a very │
863 │ │ │ │ high value │
864 │ │ │ │ compared to │
865 │ │ │ │ historical │
866 │ │ │ │ defaults. │
867 │ │ │ │ Typically │
868 │ │ │ │ applications │
869 │ │ │ │ should increase │
870 │ │ │ │ their soft limit │
871 │ │ │ │ to the hard limit │
872 │ │ │ │ on their own, if │
873 │ │ │ │ they are OK with │
874 │ │ │ │ working with file │
875 │ │ │ │ descriptors above │
876 │ │ │ │ 1023, i.e. do not │
877 │ │ │ │ use select(). │
878 │ │ │ │ Note that file │
879 │ │ │ │ descriptors are │
880 │ │ │ │ nowadays │
881 │ │ │ │ accounted like │
882 │ │ │ │ any other form of │
883 │ │ │ │ memory, thus │
884 │ │ │ │ there should not │
885 │ │ │ │ be any need to │
886 │ │ │ │ lower the hard │
887 │ │ │ │ limit. Use │
888 │ │ │ │ MemoryMax= to │
889 │ │ │ │ control overall │
890 │ │ │ │ service memory │
891 │ │ │ │ use, including │
892 │ │ │ │ file descriptor │
893 │ │ │ │ memory. │
894 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
895 │LimitAS= │ ulimit -v │ Bytes │ Don't use. This │
896 │ │ │ │ limits the │
897 │ │ │ │ allowed address │
898 │ │ │ │ range, not memory │
899 │ │ │ │ use! Defaults to │
900 │ │ │ │ unlimited and │
901 │ │ │ │ should not be │
902 │ │ │ │ lowered. To limit │
903 │ │ │ │ memory use, see │
904 │ │ │ │ MemoryMax= in │
905 │ │ │ │ systemd.resource- │
906 │ │ │ │ control(5). │
907 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
908 │LimitNPROC= │ ulimit -u │ Number of │ This limit is │
909 │ │ │ Processes │ enforced based on │
910 │ │ │ │ the number of │
911 │ │ │ │ processes │
912 │ │ │ │ belonging to the │
913 │ │ │ │ user. Typically │
914 │ │ │ │ it's better to │
915 │ │ │ │ track processes │
916 │ │ │ │ per service, i.e. │
917 │ │ │ │ use TasksMax=, │
918 │ │ │ │ see │
919 │ │ │ │ systemd.resource- │
920 │ │ │ │ control(5). │
921 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
922 │LimitMEMLOCK= │ ulimit -l │ Bytes │ - │
923 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
924 │LimitLOCKS= │ ulimit -x │ Number of Locks │ - │
925 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
926 │LimitSIGPENDING= │ ulimit -i │ Number of Queued │ - │
927 │ │ │ Signals │ │
928 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
929 │LimitMSGQUEUE= │ ulimit -q │ Bytes │ - │
930 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
931 │LimitNICE= │ ulimit -e │ Nice Level │ - │
932 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
933 │LimitRTPRIO= │ ulimit -r │ Realtime │ - │
934 │ │ │ Priority │ │
935 ├─────────────────┼────────────┼──────────────────┼───────────────────┤
936 │LimitRTTIME= │ ulimit -R │ Microseconds │ - │
937 └─────────────────┴────────────┴──────────────────┴───────────────────┘
938
939 UMask=
940 Controls the file mode creation mask. Takes an access mode in octal
941 notation. See umask(2) for details. Defaults to 0022 for system
942 units. For user units the default value is inherited from the
943 per-user service manager (whose default is in turn inherited from
944 the system service manager, and thus typically also is 0022 —
945 unless overridden by a PAM module). In order to change the per-user
946 mask for all user services, consider setting the UMask= setting of
947 the user's user@.service system service instance. The per-user
948 umask may also be set via the umask field of a user's JSON User
949 Record[5] (for users managed by systemd-homed.service(8) this field
950 may be controlled via homectl --umask=). It may also be set via a
951 PAM module, such as pam_umask(8).
952
953 CoredumpFilter=
954 Controls which types of memory mappings will be saved if the
955 process dumps core (using the /proc/pid/coredump_filter file).
956 Takes a whitespace-separated combination of mapping type names or
957 numbers (with the default base 16). Mapping type names are
958 private-anonymous, shared-anonymous, private-file-backed,
959 shared-file-backed, elf-headers, private-huge, shared-huge,
960 private-dax, shared-dax, and the special values all (all types) and
961 default (the kernel default of "private-anonymous shared-anonymous
962 elf-headers private-huge"). See core(5) for the meaning of the
963 mapping types. When specified multiple times, all specified masks
964 are ORed. When not set, or if the empty value is assigned, the
965 inherited value is not changed.
966
967 Example 2. Add DAX pages to the dump filter
968
969 CoredumpFilter=default private-dax shared-dax
970
971 KeyringMode=
972 Controls how the kernel session keyring is set up for the service
973 (see session-keyring(7) for details on the session keyring). Takes
974 one of inherit, private, shared. If set to inherit no special
975 keyring setup is done, and the kernel's default behaviour is
976 applied. If private is used a new session keyring is allocated when
977 a service process is invoked, and it is not linked up with any user
978 keyring. This is the recommended setting for system services, as
979 this ensures that multiple services running under the same system
980 user ID (in particular the root user) do not share their key
981 material among each other. If shared is used a new session keyring
982 is allocated as for private, but the user keyring of the user
983 configured with User= is linked into it, so that keys assigned to
984 the user may be requested by the unit's processes. In this modes
985 multiple units running processes under the same user ID may share
986 key material. Unless inherit is selected the unique invocation ID
987 for the unit (see below) is added as a protected key by the name
988 "invocation_id" to the newly created session keyring. Defaults to
989 private for services of the system service manager and to inherit
990 for non-service units and for services of the user service manager.
991
992 OOMScoreAdjust=
993 Sets the adjustment value for the Linux kernel's Out-Of-Memory
994 (OOM) killer score for executed processes. Takes an integer between
995 -1000 (to disable OOM killing of processes of this unit) and 1000
996 (to make killing of processes of this unit under memory pressure
997 very likely). See proc.txt[6] for details. If not specified
998 defaults to the OOM score adjustment level of the service manager
999 itself, which is normally at 0.
1000
1001 Use the OOMPolicy= setting of service units to configure how the
1002 service manager shall react to the kernel OOM killer or
1003 systemd-oomd terminating a process of the service. See
1004 systemd.service(5) for details.
1005
1006 TimerSlackNSec=
1007 Sets the timer slack in nanoseconds for the executed processes. The
1008 timer slack controls the accuracy of wake-ups triggered by timers.
1009 See prctl(2) for more information. Note that in contrast to most
1010 other time span definitions this parameter takes an integer value
1011 in nano-seconds if no unit is specified. The usual time units are
1012 understood too.
1013
1014 Personality=
1015 Controls which kernel architecture uname(2) shall report, when
1016 invoked by unit processes. Takes one of the architecture
1017 identifiers x86, x86-64, ppc, ppc-le, ppc64, ppc64-le, s390 or
1018 s390x. Which personality architectures are supported depends on the
1019 system architecture. Usually the 64bit versions of the various
1020 system architectures support their immediate 32bit personality
1021 architecture counterpart, but no others. For example, x86-64
1022 systems support the x86-64 and x86 personalities but no others. The
1023 personality feature is useful when running 32-bit services on a
1024 64-bit host system. If not specified, the personality is left
1025 unmodified and thus reflects the personality of the host system's
1026 kernel.
1027
1028 IgnoreSIGPIPE=
1029 Takes a boolean argument. If true, causes SIGPIPE to be ignored in
1030 the executed process. Defaults to true because SIGPIPE generally is
1031 useful only in shell pipelines.
1032
1034 Nice=
1035 Sets the default nice level (scheduling priority) for executed
1036 processes. Takes an integer between -20 (highest priority) and 19
1037 (lowest priority). In case of resource contention, smaller values
1038 mean more resources will be made available to the unit's processes,
1039 larger values mean less resources will be made available. See
1040 setpriority(2) for details.
1041
1042 CPUSchedulingPolicy=
1043 Sets the CPU scheduling policy for executed processes. Takes one of
1044 other, batch, idle, fifo or rr. See sched_setscheduler(2) for
1045 details.
1046
1047 CPUSchedulingPriority=
1048 Sets the CPU scheduling priority for executed processes. The
1049 available priority range depends on the selected CPU scheduling
1050 policy (see above). For real-time scheduling policies an integer
1051 between 1 (lowest priority) and 99 (highest priority) can be used.
1052 In case of CPU resource contention, smaller values mean less CPU
1053 time is made available to the service, larger values mean more. See
1054 sched_setscheduler(2) for details.
1055
1056 CPUSchedulingResetOnFork=
1057 Takes a boolean argument. If true, elevated CPU scheduling
1058 priorities and policies will be reset when the executed processes
1059 call fork(2), and can hence not leak into child processes. See
1060 sched_setscheduler(2) for details. Defaults to false.
1061
1062 CPUAffinity=
1063 Controls the CPU affinity of the executed processes. Takes a list
1064 of CPU indices or ranges separated by either whitespace or commas.
1065 Alternatively, takes a special "numa" value in which case systemd
1066 automatically derives allowed CPU range based on the value of
1067 NUMAMask= option. CPU ranges are specified by the lower and upper
1068 CPU indices separated by a dash. This option may be specified more
1069 than once, in which case the specified CPU affinity masks are
1070 merged. If the empty string is assigned, the mask is reset, all
1071 assignments prior to this will have no effect. See
1072 sched_setaffinity(2) for details.
1073
1074 NUMAPolicy=
1075 Controls the NUMA memory policy of the executed processes. Takes a
1076 policy type, one of: default, preferred, bind, interleave and
1077 local. A list of NUMA nodes that should be associated with the
1078 policy must be specified in NUMAMask=. For more details on each
1079 policy please see, set_mempolicy(2). For overall overview of NUMA
1080 support in Linux see, numa(7).
1081
1082 NUMAMask=
1083 Controls the NUMA node list which will be applied alongside with
1084 selected NUMA policy. Takes a list of NUMA nodes and has the same
1085 syntax as a list of CPUs for CPUAffinity= option or special "all"
1086 value which will include all available NUMA nodes in the mask. Note
1087 that the list of NUMA nodes is not required for default and local
1088 policies and for preferred policy we expect a single NUMA node.
1089
1090 IOSchedulingClass=
1091 Sets the I/O scheduling class for executed processes. Takes one of
1092 the strings realtime, best-effort or idle. The kernel's default
1093 scheduling class is best-effort at a priority of 4. If the empty
1094 string is assigned to this option, all prior assignments to both
1095 IOSchedulingClass= and IOSchedulingPriority= have no effect. See
1096 ioprio_set(2) for details.
1097
1098 IOSchedulingPriority=
1099 Sets the I/O scheduling priority for executed processes. Takes an
1100 integer between 0 (highest priority) and 7 (lowest priority). In
1101 case of I/O contention, smaller values mean more I/O bandwidth is
1102 made available to the unit's processes, larger values mean less
1103 bandwidth. The available priorities depend on the selected I/O
1104 scheduling class (see above). If the empty string is assigned to
1105 this option, all prior assignments to both IOSchedulingClass= and
1106 IOSchedulingPriority= have no effect. For the kernel's default
1107 scheduling class (best-effort) this defaults to 4. See
1108 ioprio_set(2) for details.
1109
1111 The following sandboxing options are an effective way to limit the
1112 exposure of the system towards the unit's processes. It is recommended
1113 to turn on as many of these options for each unit as is possible
1114 without negatively affecting the process' ability to operate. Note that
1115 many of these sandboxing features are gracefully turned off on systems
1116 where the underlying security mechanism is not available. For example,
1117 ProtectSystem= has no effect if the kernel is built without file system
1118 namespacing or if the service manager runs in a container manager that
1119 makes file system namespacing unavailable to its payload. Similar,
1120 RestrictRealtime= has no effect on systems that lack support for
1121 SECCOMP system call filtering, or in containers where support for this
1122 is turned off.
1123
1124 Also note that some sandboxing functionality is generally not available
1125 in user services (i.e. services run by the per-user service manager).
1126 Specifically, the various settings requiring file system namespacing
1127 support (such as ProtectSystem=) are not available, as the underlying
1128 kernel functionality is only accessible to privileged processes.
1129 However, most namespacing settings, that will not work on their own in
1130 user services, will work when used in conjunction with
1131 PrivateUsers=true.
1132
1133 ProtectSystem=
1134 Takes a boolean argument or the special values "full" or "strict".
1135 If true, mounts the /usr/ and the boot loader directories (/boot
1136 and /efi) read-only for processes invoked by this unit. If set to
1137 "full", the /etc/ directory is mounted read-only, too. If set to
1138 "strict" the entire file system hierarchy is mounted read-only,
1139 except for the API file system subtrees /dev/, /proc/ and /sys/
1140 (protect these directories using PrivateDevices=,
1141 ProtectKernelTunables=, ProtectControlGroups=). This setting
1142 ensures that any modification of the vendor-supplied operating
1143 system (and optionally its configuration, and local mounts) is
1144 prohibited for the service. It is recommended to enable this
1145 setting for all long-running services, unless they are involved
1146 with system updates or need to modify the operating system in other
1147 ways. If this option is used, ReadWritePaths= may be used to
1148 exclude specific directories from being made read-only. This
1149 setting is implied if DynamicUser= is set. This setting cannot
1150 ensure protection in all cases. In general it has the same
1151 limitations as ReadOnlyPaths=, see below. Defaults to off.
1152
1153 ProtectHome=
1154 Takes a boolean argument or the special values "read-only" or
1155 "tmpfs". If true, the directories /home/, /root, and /run/user are
1156 made inaccessible and empty for processes invoked by this unit. If
1157 set to "read-only", the three directories are made read-only
1158 instead. If set to "tmpfs", temporary file systems are mounted on
1159 the three directories in read-only mode. The value "tmpfs" is
1160 useful to hide home directories not relevant to the processes
1161 invoked by the unit, while still allowing necessary directories to
1162 be made visible when listed in BindPaths= or BindReadOnlyPaths=.
1163
1164 Setting this to "yes" is mostly equivalent to set the three
1165 directories in InaccessiblePaths=. Similarly, "read-only" is mostly
1166 equivalent to ReadOnlyPaths=, and "tmpfs" is mostly equivalent to
1167 TemporaryFileSystem= with ":ro".
1168
1169 It is recommended to enable this setting for all long-running
1170 services (in particular network-facing ones), to ensure they cannot
1171 get access to private user data, unless the services actually
1172 require access to the user's private data. This setting is implied
1173 if DynamicUser= is set. This setting cannot ensure protection in
1174 all cases. In general it has the same limitations as
1175 ReadOnlyPaths=, see below.
1176
1177 This option is only available for system services, or for services
1178 running in per-user instances of the service manager when
1179 PrivateUsers= is enabled.
1180
1181 RuntimeDirectory=, StateDirectory=, CacheDirectory=, LogsDirectory=,
1182 ConfigurationDirectory=
1183 These options take a whitespace-separated list of directory names.
1184 The specified directory names must be relative, and may not include
1185 "..". If set, when the unit is started, one or more directories by
1186 the specified names will be created (including their parents) below
1187 the locations defined in the following table. Also, the
1188 corresponding environment variable will be defined with the full
1189 paths of the directories. If multiple directories are set, then in
1190 the environment variable the paths are concatenated with colon
1191 (":").
1192
1193 Table 2. Automatic directory creation and environment variables
1194 ┌────────────────────────┬────────────────┬───────────────────────┬──────────────────────────┐
1195 │Directory │ Below path for │ Below path for │ Environment │
1196 │ │ system units │ user units │ variable set │
1197 ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
1198 │RuntimeDirectory= │ /run/ │ $XDG_RUNTIME_DIR │ $RUNTIME_DIRECTORY │
1199 ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
1200 │StateDirectory= │ /var/lib/ │ $XDG_CONFIG_HOME │ $STATE_DIRECTORY │
1201 ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
1202 │CacheDirectory= │ /var/cache/ │ $XDG_CACHE_HOME │ $CACHE_DIRECTORY │
1203 ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
1204 │LogsDirectory= │ /var/log/ │ $XDG_CONFIG_HOME/log/ │ $LOGS_DIRECTORY │
1205 ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
1206 │ConfigurationDirectory= │ /etc/ │ $XDG_CONFIG_HOME │ $CONFIGURATION_DIRECTORY │
1207 └────────────────────────┴────────────────┴───────────────────────┴──────────────────────────┘
1208 In case of RuntimeDirectory= the innermost subdirectories are
1209 removed when the unit is stopped. It is possible to preserve the
1210 specified directories in this case if RuntimeDirectoryPreserve= is
1211 configured to restart or yes (see below). The directories specified
1212 with StateDirectory=, CacheDirectory=, LogsDirectory=,
1213 ConfigurationDirectory= are not removed when the unit is stopped.
1214
1215 Except in case of ConfigurationDirectory=, the innermost specified
1216 directories will be owned by the user and group specified in User=
1217 and Group=. If the specified directories already exist and their
1218 owning user or group do not match the configured ones, all files
1219 and directories below the specified directories as well as the
1220 directories themselves will have their file ownership recursively
1221 changed to match what is configured. As an optimization, if the
1222 specified directories are already owned by the right user and
1223 group, files and directories below of them are left as-is, even if
1224 they do not match what is requested. The innermost specified
1225 directories will have their access mode adjusted to the what is
1226 specified in RuntimeDirectoryMode=, StateDirectoryMode=,
1227 CacheDirectoryMode=, LogsDirectoryMode= and
1228 ConfigurationDirectoryMode=.
1229
1230 These options imply BindPaths= for the specified paths. When
1231 combined with RootDirectory= or RootImage= these paths always
1232 reside on the host and are mounted from there into the unit's file
1233 system namespace.
1234
1235 If DynamicUser= is used, the logic for CacheDirectory=,
1236 LogsDirectory= and StateDirectory= is slightly altered: the
1237 directories are created below /var/cache/private, /var/log/private
1238 and /var/lib/private, respectively, which are host directories made
1239 inaccessible to unprivileged users, which ensures that access to
1240 these directories cannot be gained through dynamic user ID
1241 recycling. Symbolic links are created to hide this difference in
1242 behaviour. Both from perspective of the host and from inside the
1243 unit, the relevant directories hence always appear directly below
1244 /var/cache, /var/log and /var/lib.
1245
1246 Use RuntimeDirectory= to manage one or more runtime directories for
1247 the unit and bind their lifetime to the daemon runtime. This is
1248 particularly useful for unprivileged daemons that cannot create
1249 runtime directories in /run/ due to lack of privileges, and to make
1250 sure the runtime directory is cleaned up automatically after use.
1251 For runtime directories that require more complex or different
1252 configuration or lifetime guarantees, please consider using
1253 tmpfiles.d(5).
1254
1255 RuntimeDirectory=, StateDirectory=, CacheDirectory= and
1256 LogsDirectory= optionally support a second parameter, separated by
1257 ":". The second parameter will be interpreted as a destination path
1258 that will be created as a symlink to the directory. The symlinks
1259 will be created after any BindPaths= or TemporaryFileSystem=
1260 options have been set up, to make ephemeral symlinking possible.
1261 The same source can have multiple symlinks, by using the same first
1262 parameter, but a different second parameter.
1263
1264 The directories defined by these options are always created under
1265 the standard paths used by systemd (/var/, /run/, /etc/, ...). If
1266 the service needs directories in a different location, a different
1267 mechanism has to be used to create them.
1268
1269 tmpfiles.d(5) provides functionality that overlaps with these
1270 options. Using these options is recommended, because the lifetime
1271 of the directories is tied directly to the lifetime of the unit,
1272 and it is not necessary to ensure that the tmpfiles.d configuration
1273 is executed before the unit is started.
1274
1275 To remove any of the directories created by these settings, use the
1276 systemctl clean ... command on the relevant units, see
1277 systemctl(1) for details.
1278
1279 Example: if a system service unit has the following,
1280
1281 RuntimeDirectory=foo/bar baz
1282
1283 the service manager creates /run/foo (if it does not exist),
1284 /run/foo/bar, and /run/baz. The directories /run/foo/bar and
1285 /run/baz except /run/foo are owned by the user and group specified
1286 in User= and Group=, and removed when the service is stopped.
1287
1288 Example: if a system service unit has the following,
1289
1290 RuntimeDirectory=foo/bar
1291 StateDirectory=aaa/bbb ccc
1292
1293 then the environment variable "RUNTIME_DIRECTORY" is set with
1294 "/run/foo/bar", and "STATE_DIRECTORY" is set with
1295 "/var/lib/aaa/bbb:/var/lib/ccc".
1296
1297 Example: if a system service unit has the following,
1298
1299 RuntimeDirectory=foo:bar foo:baz
1300
1301 the service manager creates /run/foo (if it does not exist), and
1302 /run/bar plus /run/baz as symlinks to /run/foo.
1303
1304 RuntimeDirectoryMode=, StateDirectoryMode=, CacheDirectoryMode=,
1305 LogsDirectoryMode=, ConfigurationDirectoryMode=
1306 Specifies the access mode of the directories specified in
1307 RuntimeDirectory=, StateDirectory=, CacheDirectory=,
1308 LogsDirectory=, or ConfigurationDirectory=, respectively, as an
1309 octal number. Defaults to 0755. See "Permissions" in
1310 path_resolution(7) for a discussion of the meaning of permission
1311 bits.
1312
1313 RuntimeDirectoryPreserve=
1314 Takes a boolean argument or restart. If set to no (the default),
1315 the directories specified in RuntimeDirectory= are always removed
1316 when the service stops. If set to restart the directories are
1317 preserved when the service is both automatically and manually
1318 restarted. Here, the automatic restart means the operation
1319 specified in Restart=, and manual restart means the one triggered
1320 by systemctl restart foo.service. If set to yes, then the
1321 directories are not removed when the service is stopped. Note that
1322 since the runtime directory /run/ is a mount point of "tmpfs", then
1323 for system services the directories specified in RuntimeDirectory=
1324 are removed when the system is rebooted.
1325
1326 TimeoutCleanSec=
1327 Configures a timeout on the clean-up operation requested through
1328 systemctl clean ..., see systemctl(1) for details. Takes the usual
1329 time values and defaults to infinity, i.e. by default no timeout is
1330 applied. If a timeout is configured the clean operation will be
1331 aborted forcibly when the timeout is reached, potentially leaving
1332 resources on disk.
1333
1334 ReadWritePaths=, ReadOnlyPaths=, InaccessiblePaths=, ExecPaths=,
1335 NoExecPaths=
1336 Sets up a new file system namespace for executed processes. These
1337 options may be used to limit access a process has to the file
1338 system. Each setting takes a space-separated list of paths relative
1339 to the host's root directory (i.e. the system running the service
1340 manager). Note that if paths contain symlinks, they are resolved
1341 relative to the root directory set with RootDirectory=/RootImage=.
1342
1343 Paths listed in ReadWritePaths= are accessible from within the
1344 namespace with the same access modes as from outside of it. Paths
1345 listed in ReadOnlyPaths= are accessible for reading only, writing
1346 will be refused even if the usual file access controls would permit
1347 this. Nest ReadWritePaths= inside of ReadOnlyPaths= in order to
1348 provide writable subdirectories within read-only directories. Use
1349 ReadWritePaths= in order to allow-list specific paths for write
1350 access if ProtectSystem=strict is used.
1351
1352 Paths listed in InaccessiblePaths= will be made inaccessible for
1353 processes inside the namespace along with everything below them in
1354 the file system hierarchy. This may be more restrictive than
1355 desired, because it is not possible to nest ReadWritePaths=,
1356 ReadOnlyPaths=, BindPaths=, or BindReadOnlyPaths= inside it. For a
1357 more flexible option, see TemporaryFileSystem=.
1358
1359 Content in paths listed in NoExecPaths= are not executable even if
1360 the usual file access controls would permit this. Nest ExecPaths=
1361 inside of NoExecPaths= in order to provide executable content
1362 within non-executable directories.
1363
1364 Non-directory paths may be specified as well. These options may be
1365 specified more than once, in which case all paths listed will have
1366 limited access from within the namespace. If the empty string is
1367 assigned to this option, the specific list is reset, and all prior
1368 assignments have no effect.
1369
1370 Paths in ReadWritePaths=, ReadOnlyPaths=, InaccessiblePaths=,
1371 ExecPaths= and NoExecPaths= may be prefixed with "-", in which case
1372 they will be ignored when they do not exist. If prefixed with "+"
1373 the paths are taken relative to the root directory of the unit, as
1374 configured with RootDirectory=/RootImage=, instead of relative to
1375 the root directory of the host (see above). When combining "-" and
1376 "+" on the same path make sure to specify "-" first, and "+"
1377 second.
1378
1379 Note that these settings will disconnect propagation of mounts from
1380 the unit's processes to the host. This means that this setting may
1381 not be used for services which shall be able to install mount
1382 points in the main mount namespace. For ReadWritePaths= and
1383 ReadOnlyPaths= propagation in the other direction is not affected,
1384 i.e. mounts created on the host generally appear in the unit
1385 processes' namespace, and mounts removed on the host also disappear
1386 there too. In particular, note that mount propagation from host to
1387 unit will result in unmodified mounts to be created in the unit's
1388 namespace, i.e. writable mounts appearing on the host will be
1389 writable in the unit's namespace too, even when propagated below a
1390 path marked with ReadOnlyPaths=! Restricting access with these
1391 options hence does not extend to submounts of a directory that are
1392 created later on. This means the lock-down offered by that setting
1393 is not complete, and does not offer full protection.
1394
1395 Note that the effect of these settings may be undone by privileged
1396 processes. In order to set up an effective sandboxed environment
1397 for a unit it is thus recommended to combine these settings with
1398 either CapabilityBoundingSet=~CAP_SYS_ADMIN or
1399 SystemCallFilter=~@mount.
1400
1401 Simple allow-list example using these directives:
1402
1403 [Service]
1404 ReadOnlyPaths=/
1405 ReadWritePaths=/var /run
1406 InaccessiblePaths=-/lost+found
1407 NoExecPaths=/
1408 ExecPaths=/usr/sbin/my_daemon /usr/lib /usr/lib64
1409
1410 These options are only available for system services, or for
1411 services running in per-user instances of the service manager when
1412 PrivateUsers= is enabled.
1413
1414 TemporaryFileSystem=
1415 Takes a space-separated list of mount points for temporary file
1416 systems (tmpfs). If set, a new file system namespace is set up for
1417 executed processes, and a temporary file system is mounted on each
1418 mount point. This option may be specified more than once, in which
1419 case temporary file systems are mounted on all listed mount points.
1420 If the empty string is assigned to this option, the list is reset,
1421 and all prior assignments have no effect. Each mount point may
1422 optionally be suffixed with a colon (":") and mount options such as
1423 "size=10%" or "ro". By default, each temporary file system is
1424 mounted with "nodev,strictatime,mode=0755". These can be disabled
1425 by explicitly specifying the corresponding mount options, e.g.,
1426 "dev" or "nostrictatime".
1427
1428 This is useful to hide files or directories not relevant to the
1429 processes invoked by the unit, while necessary files or directories
1430 can be still accessed by combining with BindPaths= or
1431 BindReadOnlyPaths=:
1432
1433 Example: if a unit has the following,
1434
1435 TemporaryFileSystem=/var:ro
1436 BindReadOnlyPaths=/var/lib/systemd
1437
1438 then the invoked processes by the unit cannot see any files or
1439 directories under /var/ except for /var/lib/systemd or its
1440 contents.
1441
1442 This option is only available for system services, or for services
1443 running in per-user instances of the service manager when
1444 PrivateUsers= is enabled.
1445
1446 PrivateTmp=
1447 Takes a boolean argument. If true, sets up a new file system
1448 namespace for the executed processes and mounts private /tmp/ and
1449 /var/tmp/ directories inside it that are not shared by processes
1450 outside of the namespace. This is useful to secure access to
1451 temporary files of the process, but makes sharing between processes
1452 via /tmp/ or /var/tmp/ impossible. If true, all temporary files
1453 created by a service in these directories will be removed after the
1454 service is stopped. Defaults to false. It is possible to run two or
1455 more units within the same private /tmp/ and /var/tmp/ namespace by
1456 using the JoinsNamespaceOf= directive, see systemd.unit(5) for
1457 details. This setting is implied if DynamicUser= is set. For this
1458 setting the same restrictions regarding mount propagation and
1459 privileges apply as for ReadOnlyPaths= and related calls, see
1460 above. Enabling this setting has the side effect of adding
1461 Requires= and After= dependencies on all mount units necessary to
1462 access /tmp/ and /var/tmp/. Moreover an implicitly After= ordering
1463 on systemd-tmpfiles-setup.service(8) is added.
1464
1465 Note that the implementation of this setting might be impossible
1466 (for example if mount namespaces are not available), and the unit
1467 should be written in a way that does not solely rely on this
1468 setting for security.
1469
1470 This option is only available for system services, or for services
1471 running in per-user instances of the service manager when
1472 PrivateUsers= is enabled.
1473
1474 PrivateDevices=
1475 Takes a boolean argument. If true, sets up a new /dev/ mount for
1476 the executed processes and only adds API pseudo devices such as
1477 /dev/null, /dev/zero or /dev/random (as well as the pseudo TTY
1478 subsystem) to it, but no physical devices such as /dev/sda, system
1479 memory /dev/mem, system ports /dev/port and others. This is useful
1480 to turn off physical device access by the executed process.
1481 Defaults to false.
1482
1483 Enabling this option will install a system call filter to block
1484 low-level I/O system calls that are grouped in the @raw-io set,
1485 remove CAP_MKNOD and CAP_SYS_RAWIO from the capability bounding set
1486 for the unit, and set DevicePolicy=closed (see systemd.resource-
1487 control(5) for details). Note that using this setting will
1488 disconnect propagation of mounts from the service to the host
1489 (propagation in the opposite direction continues to work). This
1490 means that this setting may not be used for services which shall be
1491 able to install mount points in the main mount namespace. The new
1492 /dev/ will be mounted read-only and 'noexec'. The latter may break
1493 old programs which try to set up executable memory by using mmap(2)
1494 of /dev/zero instead of using MAP_ANON. For this setting the same
1495 restrictions regarding mount propagation and privileges apply as
1496 for ReadOnlyPaths= and related calls, see above. If turned on and
1497 if running in user mode, or in system mode, but without the
1498 CAP_SYS_ADMIN capability (e.g. setting User=), NoNewPrivileges=yes
1499 is implied.
1500
1501 Note that the implementation of this setting might be impossible
1502 (for example if mount namespaces are not available), and the unit
1503 should be written in a way that does not solely rely on this
1504 setting for security.
1505
1506 This option is only available for system services, or for services
1507 running in per-user instances of the service manager when
1508 PrivateUsers= is enabled.
1509
1510 When access to some but not all devices must be possible, the
1511 DeviceAllow= setting might be used instead. See systemd.resource-
1512 control(5).
1513
1514 PrivateNetwork=
1515 Takes a boolean argument. If true, sets up a new network namespace
1516 for the executed processes and configures only the loopback network
1517 device "lo" inside it. No other network devices will be available
1518 to the executed process. This is useful to turn off network access
1519 by the executed process. Defaults to false. It is possible to run
1520 two or more units within the same private network namespace by
1521 using the JoinsNamespaceOf= directive, see systemd.unit(5) for
1522 details. Note that this option will disconnect all socket families
1523 from the host, including AF_NETLINK and AF_UNIX. Effectively, for
1524 AF_NETLINK this means that device configuration events received
1525 from systemd-udevd.service(8) are not delivered to the unit's
1526 processes. And for AF_UNIX this has the effect that AF_UNIX sockets
1527 in the abstract socket namespace of the host will become
1528 unavailable to the unit's processes (however, those located in the
1529 file system will continue to be accessible).
1530
1531 Note that the implementation of this setting might be impossible
1532 (for example if network namespaces are not available), and the unit
1533 should be written in a way that does not solely rely on this
1534 setting for security.
1535
1536 When this option is used on a socket unit any sockets bound on
1537 behalf of this unit will be bound within a private network
1538 namespace. This may be combined with JoinsNamespaceOf= to listen on
1539 sockets inside of network namespaces of other services.
1540
1541 This option is only available for system services, or for services
1542 running in per-user instances of the service manager when
1543 PrivateUsers= is enabled.
1544
1545 NetworkNamespacePath=
1546 Takes an absolute file system path refererring to a Linux network
1547 namespace pseudo-file (i.e. a file like /proc/$PID/ns/net or a bind
1548 mount or symlink to one). When set the invoked processes are added
1549 to the network namespace referenced by that path. The path has to
1550 point to a valid namespace file at the moment the processes are
1551 forked off. If this option is used PrivateNetwork= has no effect.
1552 If this option is used together with JoinsNamespaceOf= then it only
1553 has an effect if this unit is started before any of the listed
1554 units that have PrivateNetwork= or NetworkNamespacePath=
1555 configured, as otherwise the network namespace of those units is
1556 reused.
1557
1558 When this option is used on a socket unit any sockets bound on
1559 behalf of this unit will be bound within the specified network
1560 namespace.
1561
1562 This option is only available for system services, or for services
1563 running in per-user instances of the service manager when
1564 PrivateUsers= is enabled.
1565
1566 PrivateIPC=
1567 Takes a boolean argument. If true, sets up a new IPC namespace for
1568 the executed processes. Each IPC namespace has its own set of
1569 System V IPC identifiers and its own POSIX message queue file
1570 system. This is useful to avoid name clash of IPC identifiers.
1571 Defaults to false. It is possible to run two or more units within
1572 the same private IPC namespace by using the JoinsNamespaceOf=
1573 directive, see systemd.unit(5) for details.
1574
1575 Note that IPC namespacing does not have an effect on AF_UNIX
1576 sockets, which are the most common form of IPC used on Linux.
1577 Instead, AF_UNIX sockets in the file system are subject to mount
1578 namespacing, and those in the abstract namespace are subject to
1579 network namespacing. IPC namespacing only has an effect on SysV IPC
1580 (which is mostly legacy) as well as POSIX message queues (for which
1581 AF_UNIX/SOCK_SEQPACKET sockets are typically a better replacement).
1582 IPC namespacing also has no effect on POSIX shared memory (which is
1583 subject to mount namespacing) either. See ipc_namespaces(7) for the
1584 details.
1585
1586 Note that the implementation of this setting might be impossible
1587 (for example if IPC namespaces are not available), and the unit
1588 should be written in a way that does not solely rely on this
1589 setting for security.
1590
1591 This option is only available for system services, or for services
1592 running in per-user instances of the service manager when
1593 PrivateUsers= is enabled.
1594
1595 IPCNamespacePath=
1596 Takes an absolute file system path refererring to a Linux IPC
1597 namespace pseudo-file (i.e. a file like /proc/$PID/ns/ipc or a bind
1598 mount or symlink to one). When set the invoked processes are added
1599 to the network namespace referenced by that path. The path has to
1600 point to a valid namespace file at the moment the processes are
1601 forked off. If this option is used PrivateIPC= has no effect. If
1602 this option is used together with JoinsNamespaceOf= then it only
1603 has an effect if this unit is started before any of the listed
1604 units that have PrivateIPC= or IPCNamespacePath= configured, as
1605 otherwise the network namespace of those units is reused.
1606
1607 This option is only available for system services, or for services
1608 running in per-user instances of the service manager when
1609 PrivateUsers= is enabled.
1610
1611 PrivateUsers=
1612 Takes a boolean argument. If true, sets up a new user namespace for
1613 the executed processes and configures a minimal user and group
1614 mapping, that maps the "root" user and group as well as the unit's
1615 own user and group to themselves and everything else to the
1616 "nobody" user and group. This is useful to securely detach the user
1617 and group databases used by the unit from the rest of the system,
1618 and thus to create an effective sandbox environment. All files,
1619 directories, processes, IPC objects and other resources owned by
1620 users/groups not equaling "root" or the unit's own will stay
1621 visible from within the unit but appear owned by the "nobody" user
1622 and group. If this mode is enabled, all unit processes are run
1623 without privileges in the host user namespace (regardless if the
1624 unit's own user/group is "root" or not). Specifically this means
1625 that the process will have zero process capabilities on the host's
1626 user namespace, but full capabilities within the service's user
1627 namespace. Settings such as CapabilityBoundingSet= will affect only
1628 the latter, and there's no way to acquire additional capabilities
1629 in the host's user namespace. Defaults to off.
1630
1631 When this setting is set up by a per-user instance of the service
1632 manager, the mapping of the "root" user and group to itself is
1633 omitted (unless the user manager is root). Additionally, in the
1634 per-user instance manager case, the user namespace will be set up
1635 before most other namespaces. This means that combining
1636 PrivateUsers=true with other namespaces will enable use of features
1637 not normally supported by the per-user instances of the service
1638 manager.
1639
1640 This setting is particularly useful in conjunction with
1641 RootDirectory=/RootImage=, as the need to synchronize the user and
1642 group databases in the root directory and on the host is reduced,
1643 as the only users and groups who need to be matched are "root",
1644 "nobody" and the unit's own user and group.
1645
1646 Note that the implementation of this setting might be impossible
1647 (for example if user namespaces are not available), and the unit
1648 should be written in a way that does not solely rely on this
1649 setting for security.
1650
1651 ProtectHostname=
1652 Takes a boolean argument. When set, sets up a new UTS namespace for
1653 the executed processes. In addition, changing hostname or
1654 domainname is prevented. Defaults to off.
1655
1656 Note that the implementation of this setting might be impossible
1657 (for example if UTS namespaces are not available), and the unit
1658 should be written in a way that does not solely rely on this
1659 setting for security.
1660
1661 Note that when this option is enabled for a service hostname
1662 changes no longer propagate from the system into the service, it is
1663 hence not suitable for services that need to take notice of system
1664 hostname changes dynamically.
1665
1666 If this setting is on, but the unit doesn't have the CAP_SYS_ADMIN
1667 capability (e.g. services for which User= is set),
1668 NoNewPrivileges=yes is implied.
1669
1670 This option is only available for system services, or for services
1671 running in per-user instances of the service manager when
1672 PrivateUsers= is enabled.
1673
1674 ProtectClock=
1675 Takes a boolean argument. If set, writes to the hardware clock or
1676 system clock will be denied. It is recommended to turn this on for
1677 most services that do not need modify the clock. Defaults to off.
1678 Enabling this option removes CAP_SYS_TIME and CAP_WAKE_ALARM from
1679 the capability bounding set for this unit, installs a system call
1680 filter to block calls that can set the clock, and
1681 DeviceAllow=char-rtc r is implied. This ensures /dev/rtc0,
1682 /dev/rtc1, etc. are made read-only to the service. See
1683 systemd.resource-control(5) for the details about DeviceAllow=. If
1684 this setting is on, but the unit doesn't have the CAP_SYS_ADMIN
1685 capability (e.g. services for which User= is set),
1686 NoNewPrivileges=yes is implied.
1687
1688 This option is only available for system services, or for services
1689 running in per-user instances of the service manager when
1690 PrivateUsers= is enabled.
1691
1692 ProtectKernelTunables=
1693 Takes a boolean argument. If true, kernel variables accessible
1694 through /proc/sys/, /sys/, /proc/sysrq-trigger,
1695 /proc/latency_stats, /proc/acpi, /proc/timer_stats, /proc/fs and
1696 /proc/irq will be made read-only to all processes of the unit.
1697 Usually, tunable kernel variables should be initialized only at
1698 boot-time, for example with the sysctl.d(5) mechanism. Few services
1699 need to write to these at runtime; it is hence recommended to turn
1700 this on for most services. For this setting the same restrictions
1701 regarding mount propagation and privileges apply as for
1702 ReadOnlyPaths= and related calls, see above. Defaults to off. If
1703 this setting is on, but the unit doesn't have the CAP_SYS_ADMIN
1704 capability (e.g. services for which User= is set),
1705 NoNewPrivileges=yes is implied. Note that this option does not
1706 prevent indirect changes to kernel tunables effected by IPC calls
1707 to other processes. However, InaccessiblePaths= may be used to make
1708 relevant IPC file system objects inaccessible. If
1709 ProtectKernelTunables= is set, MountAPIVFS=yes is implied.
1710
1711 This option is only available for system services, or for services
1712 running in per-user instances of the service manager when
1713 PrivateUsers= is enabled.
1714
1715 ProtectKernelModules=
1716 Takes a boolean argument. If true, explicit module loading will be
1717 denied. This allows module load and unload operations to be turned
1718 off on modular kernels. It is recommended to turn this on for most
1719 services that do not need special file systems or extra kernel
1720 modules to work. Defaults to off. Enabling this option removes
1721 CAP_SYS_MODULE from the capability bounding set for the unit, and
1722 installs a system call filter to block module system calls, also
1723 /usr/lib/modules is made inaccessible. For this setting the same
1724 restrictions regarding mount propagation and privileges apply as
1725 for ReadOnlyPaths= and related calls, see above. Note that limited
1726 automatic module loading due to user configuration or kernel
1727 mapping tables might still happen as side effect of requested user
1728 operations, both privileged and unprivileged. To disable module
1729 auto-load feature please see sysctl.d(5) kernel.modules_disabled
1730 mechanism and /proc/sys/kernel/modules_disabled documentation. If
1731 this setting is on, but the unit doesn't have the CAP_SYS_ADMIN
1732 capability (e.g. services for which User= is set),
1733 NoNewPrivileges=yes is implied.
1734
1735 This option is only available for system services, or for services
1736 running in per-user instances of the service manager when
1737 PrivateUsers= is enabled.
1738
1739 ProtectKernelLogs=
1740 Takes a boolean argument. If true, access to the kernel log ring
1741 buffer will be denied. It is recommended to turn this on for most
1742 services that do not need to read from or write to the kernel log
1743 ring buffer. Enabling this option removes CAP_SYSLOG from the
1744 capability bounding set for this unit, and installs a system call
1745 filter to block the syslog(2) system call (not to be confused with
1746 the libc API syslog(3) for userspace logging). The kernel exposes
1747 its log buffer to userspace via /dev/kmsg and /proc/kmsg. If
1748 enabled, these are made inaccessible to all the processes in the
1749 unit. If this setting is on, but the unit doesn't have the
1750 CAP_SYS_ADMIN capability (e.g. services for which User= is set),
1751 NoNewPrivileges=yes is implied.
1752
1753 This option is only available for system services, or for services
1754 running in per-user instances of the service manager when
1755 PrivateUsers= is enabled.
1756
1757 ProtectControlGroups=
1758 Takes a boolean argument. If true, the Linux Control Groups
1759 (cgroups(7)) hierarchies accessible through /sys/fs/cgroup/ will be
1760 made read-only to all processes of the unit. Except for container
1761 managers no services should require write access to the control
1762 groups hierarchies; it is hence recommended to turn this on for
1763 most services. For this setting the same restrictions regarding
1764 mount propagation and privileges apply as for ReadOnlyPaths= and
1765 related calls, see above. Defaults to off. If ProtectControlGroups=
1766 is set, MountAPIVFS=yes is implied.
1767
1768 This option is only available for system services and is not
1769 supported for services running in per-user instances of the service
1770 manager.
1771
1772 RestrictAddressFamilies=
1773 Restricts the set of socket address families accessible to the
1774 processes of this unit. Takes "none", or a space-separated list of
1775 address family names to allow-list, such as AF_UNIX, AF_INET or
1776 AF_INET6. When "none" is specified, then all address families will
1777 be denied. When prefixed with "~" the listed address families will
1778 be applied as deny list, otherwise as allow list. Note that this
1779 restricts access to the socket(2) system call only. Sockets passed
1780 into the process by other means (for example, by using socket
1781 activation with socket units, see systemd.socket(5)) are
1782 unaffected. Also, sockets created with socketpair() (which creates
1783 connected AF_UNIX sockets only) are unaffected. Note that this
1784 option has no effect on 32-bit x86, s390, s390x, mips, mips-le,
1785 ppc, ppc-le, ppc64, ppc64-le and is ignored (but works correctly on
1786 other ABIs, including x86-64). Note that on systems supporting
1787 multiple ABIs (such as x86/x86-64) it is recommended to turn off
1788 alternative ABIs for services, so that they cannot be used to
1789 circumvent the restrictions of this option. Specifically, it is
1790 recommended to combine this option with
1791 SystemCallArchitectures=native or similar. If running in user mode,
1792 or in system mode, but without the CAP_SYS_ADMIN capability (e.g.
1793 setting User=), NoNewPrivileges=yes is implied. By default, no
1794 restrictions apply, all address families are accessible to
1795 processes. If assigned the empty string, any previous address
1796 family restriction changes are undone. This setting does not affect
1797 commands prefixed with "+".
1798
1799 Use this option to limit exposure of processes to remote access, in
1800 particular via exotic and sensitive network protocols, such as
1801 AF_PACKET. Note that in most cases, the local AF_UNIX address
1802 family should be included in the configured allow list as it is
1803 frequently used for local communication, including for syslog(2)
1804 logging.
1805
1806 RestrictFileSystems=
1807 Restricts the set of filesystems processes of this unit can open
1808 files on. Takes a space-separated list of filesystem names. Any
1809 filesystem listed is made accessible to the unit's processes,
1810 access to filesystem types not listed is prohibited
1811 (allow-listing). If the first character of the list is "~", the
1812 effect is inverted: access to the filesystems listed is prohibited
1813 (deny-listing). If the empty string is assigned, access to
1814 filesystems is not restricted.
1815
1816 If you specify both types of this option (i.e. allow-listing and
1817 deny-listing), the first encountered will take precedence and will
1818 dictate the default action (allow access to the filesystem or deny
1819 it). Then the next occurrences of this option will add or delete
1820 the listed filesystems from the set of the restricted filesystems,
1821 depending on its type and the default action.
1822
1823 Example: if a unit has the following,
1824
1825 RestrictFileSystems=ext4 tmpfs
1826 RestrictFileSystems=ext2 ext4
1827
1828 then access to ext4, tmpfs, and ext2 is allowed and access to other
1829 filesystems is denied.
1830
1831 Example: if a unit has the following,
1832
1833 RestrictFileSystems=ext4 tmpfs
1834 RestrictFileSystems=~ext4
1835
1836 then only access tmpfs is allowed.
1837
1838 Example: if a unit has the following,
1839
1840 RestrictFileSystems=~ext4 tmpfs
1841 RestrictFileSystems=ext4
1842
1843 then only access to tmpfs is denied.
1844
1845 As the number of possible filesystems is large, predefined sets of
1846 filesystems are provided. A set starts with "@" character, followed
1847 by name of the set.
1848
1849 Table 3. Currently predefined filesystem sets
1850 ┌──────────────────┬────────────────────────────┐
1851 │Set │ Description │
1852 ├──────────────────┼────────────────────────────┤
1853 │@basic-api │ Basic filesystem API. │
1854 ├──────────────────┼────────────────────────────┤
1855 │@auxiliary-api │ Auxiliary filesystem API. │
1856 ├──────────────────┼────────────────────────────┤
1857 │@common-block │ Common block device │
1858 │ │ filesystems. │
1859 ├──────────────────┼────────────────────────────┤
1860 │@historical-block │ Historical block device │
1861 │ │ filesystems. │
1862 ├──────────────────┼────────────────────────────┤
1863 │@network │ Well-known network │
1864 │ │ filesystems. │
1865 ├──────────────────┼────────────────────────────┤
1866 │@privileged-api │ Privileged filesystem API. │
1867 ├──────────────────┼────────────────────────────┤
1868 │@temporary │ Temporary filesystems: │
1869 │ │ tmpfs, ramfs. │
1870 ├──────────────────┼────────────────────────────┤
1871 │@known │ All known filesystems │
1872 │ │ defined by the kernel. │
1873 │ │ This list is defined │
1874 │ │ statically in systemd │
1875 │ │ based on a kernel version │
1876 │ │ that was available when │
1877 │ │ this systemd version was │
1878 │ │ released. It will become │
1879 │ │ progressively more │
1880 │ │ out-of-date as the kernel │
1881 │ │ is updated. │
1882 └──────────────────┴────────────────────────────┘
1883 Use systemd-analyze(1)'s filesystems command to retrieve a list of
1884 filesystems defined on the local system.
1885
1886 Note that this setting might not be supported on some systems (for
1887 example if the LSM eBPF hook is not enabled in the underlying
1888 kernel or if not using the unified control group hierarchy). In
1889 that case this setting has no effect.
1890
1891 RestrictNamespaces=
1892 Restricts access to Linux namespace functionality for the processes
1893 of this unit. For details about Linux namespaces, see
1894 namespaces(7). Either takes a boolean argument, or a
1895 space-separated list of namespace type identifiers. If false (the
1896 default), no restrictions on namespace creation and switching are
1897 made. If true, access to any kind of namespacing is prohibited.
1898 Otherwise, a space-separated list of namespace type identifiers
1899 must be specified, consisting of any combination of: cgroup, ipc,
1900 net, mnt, pid, user and uts. Any namespace type listed is made
1901 accessible to the unit's processes, access to namespace types not
1902 listed is prohibited (allow-listing). By prepending the list with a
1903 single tilde character ("~") the effect may be inverted: only the
1904 listed namespace types will be made inaccessible, all unlisted ones
1905 are permitted (deny-listing). If the empty string is assigned, the
1906 default namespace restrictions are applied, which is equivalent to
1907 false. This option may appear more than once, in which case the
1908 namespace types are merged by OR, or by AND if the lines are
1909 prefixed with "~" (see examples below). Internally, this setting
1910 limits access to the unshare(2), clone(2) and setns(2) system
1911 calls, taking the specified flags parameters into account. Note
1912 that — if this option is used — in addition to restricting creation
1913 and switching of the specified types of namespaces (or all of them,
1914 if true) access to the setns() system call with a zero flags
1915 parameter is prohibited. This setting is only supported on x86,
1916 x86-64, mips, mips-le, mips64, mips64-le, mips64-n32,
1917 mips64-le-n32, ppc64, ppc64-le, s390 and s390x, and enforces no
1918 restrictions on other architectures. If running in user mode, or in
1919 system mode, but without the CAP_SYS_ADMIN capability (e.g. setting
1920 User=), NoNewPrivileges=yes is implied.
1921
1922 Example: if a unit has the following,
1923
1924 RestrictNamespaces=cgroup ipc
1925 RestrictNamespaces=cgroup net
1926
1927 then cgroup, ipc, and net are set. If the second line is prefixed
1928 with "~", e.g.,
1929
1930 RestrictNamespaces=cgroup ipc
1931 RestrictNamespaces=~cgroup net
1932
1933 then, only ipc is set.
1934
1935 LockPersonality=
1936 Takes a boolean argument. If set, locks down the personality(2)
1937 system call so that the kernel execution domain may not be changed
1938 from the default or the personality selected with Personality=
1939 directive. This may be useful to improve security, because odd
1940 personality emulations may be poorly tested and source of
1941 vulnerabilities. If running in user mode, or in system mode, but
1942 without the CAP_SYS_ADMIN capability (e.g. setting User=),
1943 NoNewPrivileges=yes is implied.
1944
1945 MemoryDenyWriteExecute=
1946 Takes a boolean argument. If set, attempts to create memory
1947 mappings that are writable and executable at the same time, or to
1948 change existing memory mappings to become executable, or mapping
1949 shared memory segments as executable are prohibited. Specifically,
1950 a system call filter is added that rejects mmap(2) system calls
1951 with both PROT_EXEC and PROT_WRITE set, mprotect(2) or
1952 pkey_mprotect(2) system calls with PROT_EXEC set and shmat(2)
1953 system calls with SHM_EXEC set. Note that this option is
1954 incompatible with programs and libraries that generate program code
1955 dynamically at runtime, including JIT execution engines, executable
1956 stacks, and code "trampoline" feature of various C compilers. This
1957 option improves service security, as it makes harder for software
1958 exploits to change running code dynamically. However, the
1959 protection can be circumvented, if the service can write to a
1960 filesystem, which is not mounted with noexec (such as /dev/shm), or
1961 it can use memfd_create(). This can be prevented by making such
1962 file systems inaccessible to the service (e.g.
1963 InaccessiblePaths=/dev/shm) and installing further system call
1964 filters (SystemCallFilter=~memfd_create). Note that this feature is
1965 fully available on x86-64, and partially on x86. Specifically, the
1966 shmat() protection is not available on x86. Note that on systems
1967 supporting multiple ABIs (such as x86/x86-64) it is recommended to
1968 turn off alternative ABIs for services, so that they cannot be used
1969 to circumvent the restrictions of this option. Specifically, it is
1970 recommended to combine this option with
1971 SystemCallArchitectures=native or similar. If running in user mode,
1972 or in system mode, but without the CAP_SYS_ADMIN capability (e.g.
1973 setting User=), NoNewPrivileges=yes is implied.
1974
1975 RestrictRealtime=
1976 Takes a boolean argument. If set, any attempts to enable realtime
1977 scheduling in a process of the unit are refused. This restricts
1978 access to realtime task scheduling policies such as SCHED_FIFO,
1979 SCHED_RR or SCHED_DEADLINE. See sched(7) for details about these
1980 scheduling policies. If running in user mode, or in system mode,
1981 but without the CAP_SYS_ADMIN capability (e.g. setting User=),
1982 NoNewPrivileges=yes is implied. Realtime scheduling policies may be
1983 used to monopolize CPU time for longer periods of time, and may
1984 hence be used to lock up or otherwise trigger Denial-of-Service
1985 situations on the system. It is hence recommended to restrict
1986 access to realtime scheduling to the few programs that actually
1987 require them. Defaults to off.
1988
1989 RestrictSUIDSGID=
1990 Takes a boolean argument. If set, any attempts to set the
1991 set-user-ID (SUID) or set-group-ID (SGID) bits on files or
1992 directories will be denied (for details on these bits see
1993 inode(7)). If running in user mode, or in system mode, but without
1994 the CAP_SYS_ADMIN capability (e.g. setting User=),
1995 NoNewPrivileges=yes is implied. As the SUID/SGID bits are
1996 mechanisms to elevate privileges, and allows users to acquire the
1997 identity of other users, it is recommended to restrict creation of
1998 SUID/SGID files to the few programs that actually require them.
1999 Note that this restricts marking of any type of file system object
2000 with these bits, including both regular files and directories
2001 (where the SGID is a different meaning than for files, see
2002 documentation). This option is implied if DynamicUser= is enabled.
2003 Defaults to off.
2004
2005 RemoveIPC=
2006 Takes a boolean parameter. If set, all System V and POSIX IPC
2007 objects owned by the user and group the processes of this unit are
2008 run as are removed when the unit is stopped. This setting only has
2009 an effect if at least one of User=, Group= and DynamicUser= are
2010 used. It has no effect on IPC objects owned by the root user.
2011 Specifically, this removes System V semaphores, as well as System V
2012 and POSIX shared memory segments and message queues. If multiple
2013 units use the same user or group the IPC objects are removed when
2014 the last of these units is stopped. This setting is implied if
2015 DynamicUser= is set.
2016
2017 This option is only available for system services and is not
2018 supported for services running in per-user instances of the service
2019 manager.
2020
2021 PrivateMounts=
2022 Takes a boolean parameter. If set, the processes of this unit will
2023 be run in their own private file system (mount) namespace with all
2024 mount propagation from the processes towards the host's main file
2025 system namespace turned off. This means any file system mount
2026 points established or removed by the unit's processes will be
2027 private to them and not be visible to the host. However, file
2028 system mount points established or removed on the host will be
2029 propagated to the unit's processes. See mount_namespaces(7) for
2030 details on file system namespaces. Defaults to off.
2031
2032 When turned on, this executes three operations for each invoked
2033 process: a new CLONE_NEWNS namespace is created, after which all
2034 existing mounts are remounted to MS_SLAVE to disable propagation
2035 from the unit's processes to the host (but leaving propagation in
2036 the opposite direction in effect). Finally, the mounts are
2037 remounted again to the propagation mode configured with
2038 MountFlags=, see below.
2039
2040 File system namespaces are set up individually for each process
2041 forked off by the service manager. Mounts established in the
2042 namespace of the process created by ExecStartPre= will hence be
2043 cleaned up automatically as soon as that process exits and will not
2044 be available to subsequent processes forked off for ExecStart= (and
2045 similar applies to the various other commands configured for
2046 units). Similarly, JoinsNamespaceOf= does not permit sharing kernel
2047 mount namespaces between units, it only enables sharing of the
2048 /tmp/ and /var/tmp/ directories.
2049
2050 Other file system namespace unit settings — PrivateMounts=,
2051 PrivateTmp=, PrivateDevices=, ProtectSystem=, ProtectHome=,
2052 ReadOnlyPaths=, InaccessiblePaths=, ReadWritePaths=, ... — also
2053 enable file system namespacing in a fashion equivalent to this
2054 option. Hence it is primarily useful to explicitly request this
2055 behaviour if none of the other settings are used.
2056
2057 This option is only available for system services, or for services
2058 running in per-user instances of the service manager when
2059 PrivateUsers= is enabled.
2060
2061 MountFlags=
2062 Takes a mount propagation setting: shared, slave or private, which
2063 controls whether file system mount points in the file system
2064 namespaces set up for this unit's processes will receive or
2065 propagate mounts and unmounts from other file system namespaces.
2066 See mount(2) for details on mount propagation, and the three
2067 propagation flags in particular.
2068
2069 This setting only controls the final propagation setting in effect
2070 on all mount points of the file system namespace created for each
2071 process of this unit. Other file system namespacing unit settings
2072 (see the discussion in PrivateMounts= above) will implicitly
2073 disable mount and unmount propagation from the unit's processes
2074 towards the host by changing the propagation setting of all mount
2075 points in the unit's file system namespace to slave first. Setting
2076 this option to shared does not reestablish propagation in that
2077 case.
2078
2079 If not set – but file system namespaces are enabled through another
2080 file system namespace unit setting – shared mount propagation is
2081 used, but — as mentioned — as slave is applied first, propagation
2082 from the unit's processes to the host is still turned off.
2083
2084 It is not recommended to use private mount propagation for units,
2085 as this means temporary mounts (such as removable media) of the
2086 host will stay mounted and thus indefinitely busy in forked off
2087 processes, as unmount propagation events won't be received by the
2088 file system namespace of the unit.
2089
2090 Usually, it is best to leave this setting unmodified, and use
2091 higher level file system namespacing options instead, in particular
2092 PrivateMounts=, see above.
2093
2094 This option is only available for system services, or for services
2095 running in per-user instances of the service manager when
2096 PrivateUsers= is enabled.
2097
2099 SystemCallFilter=
2100 Takes a space-separated list of system call names. If this setting
2101 is used, all system calls executed by the unit processes except for
2102 the listed ones will result in immediate process termination with
2103 the SIGSYS signal (allow-listing). (See SystemCallErrorNumber=
2104 below for changing the default action). If the first character of
2105 the list is "~", the effect is inverted: only the listed system
2106 calls will result in immediate process termination (deny-listing).
2107 Deny-listed system calls and system call groups may optionally be
2108 suffixed with a colon (":") and "errno" error number (between 0 and
2109 4095) or errno name such as EPERM, EACCES or EUCLEAN (see errno(3)
2110 for a full list). This value will be returned when a deny-listed
2111 system call is triggered, instead of terminating the processes
2112 immediately. Special setting "kill" can be used to explicitly
2113 specify killing. This value takes precedence over the one given in
2114 SystemCallErrorNumber=, see below. If running in user mode, or in
2115 system mode, but without the CAP_SYS_ADMIN capability (e.g. setting
2116 User=), NoNewPrivileges=yes is implied. This feature makes use of
2117 the Secure Computing Mode 2 interfaces of the kernel ('seccomp
2118 filtering') and is useful for enforcing a minimal sandboxing
2119 environment. Note that the execve(), exit(), exit_group(),
2120 getrlimit(), rt_sigreturn(), sigreturn() system calls and the
2121 system calls for querying time and sleeping are implicitly
2122 allow-listed and do not need to be listed explicitly. This option
2123 may be specified more than once, in which case the filter masks are
2124 merged. If the empty string is assigned, the filter is reset, all
2125 prior assignments will have no effect. This does not affect
2126 commands prefixed with "+".
2127
2128 Note that on systems supporting multiple ABIs (such as x86/x86-64)
2129 it is recommended to turn off alternative ABIs for services, so
2130 that they cannot be used to circumvent the restrictions of this
2131 option. Specifically, it is recommended to combine this option with
2132 SystemCallArchitectures=native or similar.
2133
2134 Note that strict system call filters may impact execution and error
2135 handling code paths of the service invocation. Specifically, access
2136 to the execve() system call is required for the execution of the
2137 service binary — if it is blocked service invocation will
2138 necessarily fail. Also, if execution of the service binary fails
2139 for some reason (for example: missing service executable), the
2140 error handling logic might require access to an additional set of
2141 system calls in order to process and log this failure correctly. It
2142 might be necessary to temporarily disable system call filters in
2143 order to simplify debugging of such failures.
2144
2145 If you specify both types of this option (i.e. allow-listing and
2146 deny-listing), the first encountered will take precedence and will
2147 dictate the default action (termination or approval of a system
2148 call). Then the next occurrences of this option will add or delete
2149 the listed system calls from the set of the filtered system calls,
2150 depending of its type and the default action. (For example, if you
2151 have started with an allow list rule for read() and write(), and
2152 right after it add a deny list rule for write(), then write() will
2153 be removed from the set.)
2154
2155 As the number of possible system calls is large, predefined sets of
2156 system calls are provided. A set starts with "@" character,
2157 followed by name of the set.
2158
2159 Table 4. Currently predefined system call sets
2160 ┌────────────────┬────────────────────────────┐
2161 │Set │ Description │
2162 ├────────────────┼────────────────────────────┤
2163 │@aio │ Asynchronous I/O │
2164 │ │ (io_setup(2), │
2165 │ │ io_submit(2), and related │
2166 │ │ calls) │
2167 ├────────────────┼────────────────────────────┤
2168 │@basic-io │ System calls for basic │
2169 │ │ I/O: reading, writing, │
2170 │ │ seeking, file descriptor │
2171 │ │ duplication and closing │
2172 │ │ (read(2), write(2), and │
2173 │ │ related calls) │
2174 ├────────────────┼────────────────────────────┤
2175 │@chown │ Changing file ownership │
2176 │ │ (chown(2), fchownat(2), │
2177 │ │ and related calls) │
2178 ├────────────────┼────────────────────────────┤
2179 │@clock │ System calls for changing │
2180 │ │ the system clock │
2181 │ │ (adjtimex(2), │
2182 │ │ settimeofday(2), and │
2183 │ │ related calls) │
2184 ├────────────────┼────────────────────────────┤
2185 │@cpu-emulation │ System calls for CPU │
2186 │ │ emulation functionality │
2187 │ │ (vm86(2) and related │
2188 │ │ calls) │
2189 ├────────────────┼────────────────────────────┤
2190 │@debug │ Debugging, performance │
2191 │ │ monitoring and tracing │
2192 │ │ functionality (ptrace(2), │
2193 │ │ perf_event_open(2) and │
2194 │ │ related calls) │
2195 ├────────────────┼────────────────────────────┤
2196 │@file-system │ File system operations: │
2197 │ │ opening, creating files │
2198 │ │ and directories for read │
2199 │ │ and write, renaming and │
2200 │ │ removing them, reading │
2201 │ │ file properties, or │
2202 │ │ creating hard and symbolic │
2203 │ │ links │
2204 ├────────────────┼────────────────────────────┤
2205 │@io-event │ Event loop system calls │
2206 │ │ (poll(2), select(2), │
2207 │ │ epoll(7), eventfd(2) and │
2208 │ │ related calls) │
2209 ├────────────────┼────────────────────────────┤
2210 │@ipc │ Pipes, SysV IPC, POSIX │
2211 │ │ Message Queues and other │
2212 │ │ IPC (mq_overview(7), │
2213 │ │ svipc(7)) │
2214 ├────────────────┼────────────────────────────┤
2215 │@keyring │ Kernel keyring access │
2216 │ │ (keyctl(2) and related │
2217 │ │ calls) │
2218 ├────────────────┼────────────────────────────┤
2219 │@memlock │ Locking of memory in RAM │
2220 │ │ (mlock(2), mlockall(2) and │
2221 │ │ related calls) │
2222 ├────────────────┼────────────────────────────┤
2223 │@module │ Loading and unloading of │
2224 │ │ kernel modules │
2225 │ │ (init_module(2), │
2226 │ │ delete_module(2) and │
2227 │ │ related calls) │
2228 ├────────────────┼────────────────────────────┤
2229 │@mount │ Mounting and unmounting of │
2230 │ │ file systems (mount(2), │
2231 │ │ chroot(2), and related │
2232 │ │ calls) │
2233 ├────────────────┼────────────────────────────┤
2234 │@network-io │ Socket I/O (including │
2235 │ │ local AF_UNIX): socket(7), │
2236 │ │ unix(7) │
2237 ├────────────────┼────────────────────────────┤
2238 │@obsolete │ Unusual, obsolete or │
2239 │ │ unimplemented │
2240 │ │ (create_module(2), │
2241 │ │ gtty(2), ...) │
2242 ├────────────────┼────────────────────────────┤
2243 │@privileged │ All system calls which │
2244 │ │ need super-user │
2245 │ │ capabilities │
2246 │ │ (capabilities(7)) │
2247 ├────────────────┼────────────────────────────┤
2248 │@process │ Process control, │
2249 │ │ execution, namespacing │
2250 │ │ operations (clone(2), │
2251 │ │ kill(2), namespaces(7), │
2252 │ │ ...) │
2253 ├────────────────┼────────────────────────────┤
2254 │@raw-io │ Raw I/O port access │
2255 │ │ (ioperm(2), iopl(2), │
2256 │ │ pciconfig_read(), ...) │
2257 ├────────────────┼────────────────────────────┤
2258 │@reboot │ System calls for rebooting │
2259 │ │ and reboot preparation │
2260 │ │ (reboot(2), kexec(), ...) │
2261 ├────────────────┼────────────────────────────┤
2262 │@resources │ System calls for changing │
2263 │ │ resource limits, memory │
2264 │ │ and scheduling parameters │
2265 │ │ (setrlimit(2), │
2266 │ │ setpriority(2), ...) │
2267 ├────────────────┼────────────────────────────┤
2268 │@setuid │ System calls for changing │
2269 │ │ user ID and group ID │
2270 │ │ credentials, (setuid(2), │
2271 │ │ setgid(2), setresuid(2), │
2272 │ │ ...) │
2273 ├────────────────┼────────────────────────────┤
2274 │@signal │ System calls for │
2275 │ │ manipulating and handling │
2276 │ │ process signals │
2277 │ │ (signal(2), │
2278 │ │ sigprocmask(2), ...) │
2279 ├────────────────┼────────────────────────────┤
2280 │@swap │ System calls for │
2281 │ │ enabling/disabling swap │
2282 │ │ devices (swapon(2), │
2283 │ │ swapoff(2)) │
2284 ├────────────────┼────────────────────────────┤
2285 │@sync │ Synchronizing files and │
2286 │ │ memory to disk (fsync(2), │
2287 │ │ msync(2), and related │
2288 │ │ calls) │
2289 ├────────────────┼────────────────────────────┤
2290 │@system-service │ A reasonable set of system │
2291 │ │ calls used by common │
2292 │ │ system services, excluding │
2293 │ │ any special purpose calls. │
2294 │ │ This is the recommended │
2295 │ │ starting point for │
2296 │ │ allow-listing system calls │
2297 │ │ for system services, as it │
2298 │ │ contains what is typically │
2299 │ │ needed by system services, │
2300 │ │ but excludes overly │
2301 │ │ specific interfaces. For │
2302 │ │ example, the following │
2303 │ │ APIs are excluded: │
2304 │ │ "@clock", "@mount", │
2305 │ │ "@swap", "@reboot". │
2306 ├────────────────┼────────────────────────────┤
2307 │@timer │ System calls for │
2308 │ │ scheduling operations by │
2309 │ │ time (alarm(2), │
2310 │ │ timer_create(2), ...) │
2311 ├────────────────┼────────────────────────────┤
2312 │@known │ All system calls defined │
2313 │ │ by the kernel. This list │
2314 │ │ is defined statically in │
2315 │ │ systemd based on a kernel │
2316 │ │ version that was available │
2317 │ │ when this systemd version │
2318 │ │ was released. It will │
2319 │ │ become progressively more │
2320 │ │ out-of-date as the kernel │
2321 │ │ is updated. │
2322 └────────────────┴────────────────────────────┘
2323 Note, that as new system calls are added to the kernel, additional
2324 system calls might be added to the groups above. Contents of the
2325 sets may also change between systemd versions. In addition, the
2326 list of system calls depends on the kernel version and architecture
2327 for which systemd was compiled. Use systemd-analyze syscall-filter
2328 to list the actual list of system calls in each filter.
2329
2330 Generally, allow-listing system calls (rather than deny-listing) is
2331 the safer mode of operation. It is recommended to enforce system
2332 call allow lists for all long-running system services.
2333 Specifically, the following lines are a relatively safe basic
2334 choice for the majority of system services:
2335
2336 [Service]
2337 SystemCallFilter=@system-service
2338 SystemCallErrorNumber=EPERM
2339
2340 Note that various kernel system calls are defined redundantly:
2341 there are multiple system calls for executing the same operation.
2342 For example, the pidfd_send_signal() system call may be used to
2343 execute operations similar to what can be done with the older
2344 kill() system call, hence blocking the latter without the former
2345 only provides weak protection. Since new system calls are added
2346 regularly to the kernel as development progresses, keeping system
2347 call deny lists comprehensive requires constant work. It is thus
2348 recommended to use allow-listing instead, which offers the benefit
2349 that new system calls are by default implicitly blocked until the
2350 allow list is updated.
2351
2352 Also note that a number of system calls are required to be
2353 accessible for the dynamic linker to work. The dynamic linker is
2354 required for running most regular programs (specifically: all
2355 dynamic ELF binaries, which is how most distributions build
2356 packaged programs). This means that blocking these system calls
2357 (which include open(), openat() or mmap()) will make most programs
2358 typically shipped with generic distributions unusable.
2359
2360 It is recommended to combine the file system namespacing related
2361 options with SystemCallFilter=~@mount, in order to prohibit the
2362 unit's processes to undo the mappings. Specifically these are the
2363 options PrivateTmp=, PrivateDevices=, ProtectSystem=, ProtectHome=,
2364 ProtectKernelTunables=, ProtectControlGroups=, ProtectKernelLogs=,
2365 ProtectClock=, ReadOnlyPaths=, InaccessiblePaths= and
2366 ReadWritePaths=.
2367
2368 SystemCallErrorNumber=
2369 Takes an "errno" error number (between 1 and 4095) or errno name
2370 such as EPERM, EACCES or EUCLEAN, to return when the system call
2371 filter configured with SystemCallFilter= is triggered, instead of
2372 terminating the process immediately. See errno(3) for a full list
2373 of error codes. When this setting is not used, or when the empty
2374 string or the special setting "kill" is assigned, the process will
2375 be terminated immediately when the filter is triggered.
2376
2377 SystemCallArchitectures=
2378 Takes a space-separated list of architecture identifiers to include
2379 in the system call filter. The known architecture identifiers are
2380 the same as for ConditionArchitecture= described in
2381 systemd.unit(5), as well as x32, mips64-n32, mips64-le-n32, and the
2382 special identifier native. The special identifier native implicitly
2383 maps to the native architecture of the system (or more precisely:
2384 to the architecture the system manager is compiled for). If running
2385 in user mode, or in system mode, but without the CAP_SYS_ADMIN
2386 capability (e.g. setting User=), NoNewPrivileges=yes is implied. By
2387 default, this option is set to the empty list, i.e. no filtering is
2388 applied.
2389
2390 If this setting is used, processes of this unit will only be
2391 permitted to call native system calls, and system calls of the
2392 specified architectures. For the purposes of this option, the x32
2393 architecture is treated as including x86-64 system calls. However,
2394 this setting still fulfills its purpose, as explained below, on
2395 x32.
2396
2397 System call filtering is not equally effective on all
2398 architectures. For example, on x86 filtering of network
2399 socket-related calls is not possible, due to ABI limitations — a
2400 limitation that x86-64 does not have, however. On systems
2401 supporting multiple ABIs at the same time — such as x86/x86-64 — it
2402 is hence recommended to limit the set of permitted system call
2403 architectures so that secondary ABIs may not be used to circumvent
2404 the restrictions applied to the native ABI of the system. In
2405 particular, setting SystemCallArchitectures=native is a good choice
2406 for disabling non-native ABIs.
2407
2408 System call architectures may also be restricted system-wide via
2409 the SystemCallArchitectures= option in the global configuration.
2410 See systemd-system.conf(5) for details.
2411
2412 SystemCallLog=
2413 Takes a space-separated list of system call names. If this setting
2414 is used, all system calls executed by the unit processes for the
2415 listed ones will be logged. If the first character of the list is
2416 "~", the effect is inverted: all system calls except the listed
2417 system calls will be logged. If running in user mode, or in system
2418 mode, but without the CAP_SYS_ADMIN capability (e.g. setting
2419 User=), NoNewPrivileges=yes is implied. This feature makes use of
2420 the Secure Computing Mode 2 interfaces of the kernel ('seccomp
2421 filtering') and is useful for auditing or setting up a minimal
2422 sandboxing environment. This option may be specified more than
2423 once, in which case the filter masks are merged. If the empty
2424 string is assigned, the filter is reset, all prior assignments will
2425 have no effect. This does not affect commands prefixed with "+".
2426
2428 Environment=
2429 Sets environment variables for executed processes. Each line is
2430 unquoted using the rules described in "Quoting" section in
2431 systemd.syntax(7) and becomes a list of variable assignments. If
2432 you need to assign a value containing spaces or the equals sign to
2433 a variable, put quotes around the whole assignment. Variable
2434 expansion is not performed inside the strings and the "$" character
2435 has no special meaning. Specifier expansion is performed, see the
2436 "Specifiers" section in systemd.unit(5).
2437
2438 This option may be specified more than once, in which case all
2439 listed variables will be set. If the same variable is listed twice,
2440 the later setting will override the earlier setting. If the empty
2441 string is assigned to this option, the list of environment
2442 variables is reset, all prior assignments have no effect.
2443
2444 The names of the variables can contain ASCII letters, digits, and
2445 the underscore character. Variable names cannot be empty or start
2446 with a digit. In variable values, most characters are allowed, but
2447 non-printable characters are currently rejected.
2448
2449 Example:
2450
2451 Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"
2452
2453 gives three variables "VAR1", "VAR2", "VAR3" with the values "word1
2454 word2", "word3", "$word 5 6".
2455
2456 See environ(7) for details about environment variables.
2457
2458 Note that environment variables are not suitable for passing
2459 secrets (such as passwords, key material, ...) to service
2460 processes. Environment variables set for a unit are exposed to
2461 unprivileged clients via D-Bus IPC, and generally not understood as
2462 being data that requires protection. Moreover, environment
2463 variables are propagated down the process tree, including across
2464 security boundaries (such as setuid/setgid executables), and hence
2465 might leak to processes that should not have access to the secret
2466 data. Use LoadCredential=, LoadCredentialEncrypted= or
2467 SetCredentialEncrypted= (see below) to pass data to unit processes
2468 securely.
2469
2470 EnvironmentFile=
2471 Similar to Environment= but reads the environment variables from a
2472 text file. The text file should contain newline-separated variable
2473 assignments. Empty lines, lines without an "=" separator, or lines
2474 starting with ";" or "#" will be ignored, which may be used for
2475 commenting. The file must be UTF-8 encoded. Valid characters are
2476 unicode scalar values[7] other than noncharacters[8], U+0000 NUL,
2477 and U+FEFF byte order mark[9]. Control codes other than NUL are
2478 allowed.
2479
2480 In the file, an unquoted value after the "=" is parsed with the
2481 same backslash-escape rules as unquoted text[10] in a POSIX shell,
2482 but unlike in a shell, interior whitespace is preserved and quotes
2483 after the first non-whitespace character are preserved. Leading and
2484 trailing whitespace (space, tab, carriage return) is discarded, but
2485 interior whitespace within the line is preserved verbatim. A line
2486 ending with a backslash will be continued to the following one,
2487 with the newline itself discarded. A backslash "\" followed by any
2488 character other than newline will preserve the following character,
2489 so that "\\" will become the value "\".
2490
2491 In the file, a "'"-quoted value after the "=" can span multiple
2492 lines and contain any character verbatim other than single quote,
2493 like single-quoted text[11] in a POSIX shell. No backslash-escape
2494 sequences are recognized. Leading and trailing whitespace outside
2495 of the single quotes is discarded.
2496
2497 In the file, a """-quoted value after the "=" can span multiple
2498 lines, and the same escape sequences are recognized as in
2499 double-quoted text[12] of a POSIX shell. Backslash ("\") followed
2500 by any of ""\`$" will preserve that character. A backslash followed
2501 by newline is a line continuation, and the newline itself is
2502 discarded. A backslash followed by any other character is ignored;
2503 both the backslash and the following character are preserved
2504 verbatim. Leading and trailing whitespace outside of the double
2505 quotes is discarded.
2506
2507 The argument passed should be an absolute filename or wildcard
2508 expression, optionally prefixed with "-", which indicates that if
2509 the file does not exist, it will not be read and no error or
2510 warning message is logged. This option may be specified more than
2511 once in which case all specified files are read. If the empty
2512 string is assigned to this option, the list of file to read is
2513 reset, all prior assignments have no effect.
2514
2515 The files listed with this directive will be read shortly before
2516 the process is executed (more specifically, after all processes
2517 from a previous unit state terminated. This means you can generate
2518 these files in one unit state, and read it with this option in the
2519 next. The files are read from the file system of the service
2520 manager, before any file system changes like bind mounts take
2521 place).
2522
2523 Settings from these files override settings made with Environment=.
2524 If the same variable is set twice from these files, the files will
2525 be read in the order they are specified and the later setting will
2526 override the earlier setting.
2527
2528 PassEnvironment=
2529 Pass environment variables set for the system service manager to
2530 executed processes. Takes a space-separated list of variable names.
2531 This option may be specified more than once, in which case all
2532 listed variables will be passed. If the empty string is assigned to
2533 this option, the list of environment variables to pass is reset,
2534 all prior assignments have no effect. Variables specified that are
2535 not set for the system manager will not be passed and will be
2536 silently ignored. Note that this option is only relevant for the
2537 system service manager, as system services by default do not
2538 automatically inherit any environment variables set for the service
2539 manager itself. However, in case of the user service manager all
2540 environment variables are passed to the executed processes anyway,
2541 hence this option is without effect for the user service manager.
2542
2543 Variables set for invoked processes due to this setting are subject
2544 to being overridden by those configured with Environment= or
2545 EnvironmentFile=.
2546
2547 Example:
2548
2549 PassEnvironment=VAR1 VAR2 VAR3
2550
2551 passes three variables "VAR1", "VAR2", "VAR3" with the values set
2552 for those variables in PID1.
2553
2554 See environ(7) for details about environment variables.
2555
2556 UnsetEnvironment=
2557 Explicitly unset environment variable assignments that would
2558 normally be passed from the service manager to invoked processes of
2559 this unit. Takes a space-separated list of variable names or
2560 variable assignments. This option may be specified more than once,
2561 in which case all listed variables/assignments will be unset. If
2562 the empty string is assigned to this option, the list of
2563 environment variables/assignments to unset is reset. If a variable
2564 assignment is specified (that is: a variable name, followed by "=",
2565 followed by its value), then any environment variable matching this
2566 precise assignment is removed. If a variable name is specified
2567 (that is a variable name without any following "=" or value), then
2568 any assignment matching the variable name, regardless of its value
2569 is removed. Note that the effect of UnsetEnvironment= is applied as
2570 final step when the environment list passed to executed processes
2571 is compiled. That means it may undo assignments from any
2572 configuration source, including assignments made through
2573 Environment= or EnvironmentFile=, inherited from the system
2574 manager's global set of environment variables, inherited via
2575 PassEnvironment=, set by the service manager itself (such as
2576 $NOTIFY_SOCKET and such), or set by a PAM module (in case PAMName=
2577 is used).
2578
2579 See "Environment Variables in Spawned Processes" below for a
2580 description of how those settings combine to form the inherited
2581 environment. See environ(7) for general information about
2582 environment variables.
2583
2585 StandardInput=
2586 Controls where file descriptor 0 (STDIN) of the executed processes
2587 is connected to. Takes one of null, tty, tty-force, tty-fail, data,
2588 file:path, socket or fd:name.
2589
2590 If null is selected, standard input will be connected to /dev/null,
2591 i.e. all read attempts by the process will result in immediate EOF.
2592
2593 If tty is selected, standard input is connected to a TTY (as
2594 configured by TTYPath=, see below) and the executed process becomes
2595 the controlling process of the terminal. If the terminal is already
2596 being controlled by another process, the executed process waits
2597 until the current controlling process releases the terminal.
2598
2599 tty-force is similar to tty, but the executed process is forcefully
2600 and immediately made the controlling process of the terminal,
2601 potentially removing previous controlling processes from the
2602 terminal.
2603
2604 tty-fail is similar to tty, but if the terminal already has a
2605 controlling process start-up of the executed process fails.
2606
2607 The data option may be used to configure arbitrary textual or
2608 binary data to pass via standard input to the executed process. The
2609 data to pass is configured via
2610 StandardInputText=/StandardInputData= (see below). Note that the
2611 actual file descriptor type passed (memory file, regular file, UNIX
2612 pipe, ...) might depend on the kernel and available privileges. In
2613 any case, the file descriptor is read-only, and when read returns
2614 the specified data followed by EOF.
2615
2616 The file:path option may be used to connect a specific file system
2617 object to standard input. An absolute path following the ":"
2618 character is expected, which may refer to a regular file, a FIFO or
2619 special file. If an AF_UNIX socket in the file system is specified,
2620 a stream socket is connected to it. The latter is useful for
2621 connecting standard input of processes to arbitrary system
2622 services.
2623
2624 The socket option is valid in socket-activated services only, and
2625 requires the relevant socket unit file (see systemd.socket(5) for
2626 details) to have Accept=yes set, or to specify a single socket
2627 only. If this option is set, standard input will be connected to
2628 the socket the service was activated from, which is primarily
2629 useful for compatibility with daemons designed for use with the
2630 traditional inetd(8) socket activation daemon.
2631
2632 The fd:name option connects standard input to a specific, named
2633 file descriptor provided by a socket unit. The name may be
2634 specified as part of this option, following a ":" character (e.g.
2635 "fd:foobar"). If no name is specified, the name "stdin" is implied
2636 (i.e. "fd" is equivalent to "fd:stdin"). At least one socket unit
2637 defining the specified name must be provided via the Sockets=
2638 option, and the file descriptor name may differ from the name of
2639 its containing socket unit. If multiple matches are found, the
2640 first one will be used. See FileDescriptorName= in
2641 systemd.socket(5) for more details about named file descriptors and
2642 their ordering.
2643
2644 This setting defaults to null, unless
2645 StandardInputText=/StandardInputData= are set, in which case it
2646 defaults to data.
2647
2648 StandardOutput=
2649 Controls where file descriptor 1 (stdout) of the executed processes
2650 is connected to. Takes one of inherit, null, tty, journal, kmsg,
2651 journal+console, kmsg+console, file:path, append:path,
2652 truncate:path, socket or fd:name.
2653
2654 inherit duplicates the file descriptor of standard input for
2655 standard output.
2656
2657 null connects standard output to /dev/null, i.e. everything written
2658 to it will be lost.
2659
2660 tty connects standard output to a tty (as configured via TTYPath=,
2661 see below). If the TTY is used for output only, the executed
2662 process will not become the controlling process of the terminal,
2663 and will not fail or wait for other processes to release the
2664 terminal.
2665
2666 journal connects standard output with the journal, which is
2667 accessible via journalctl(1). Note that everything that is written
2668 to kmsg (see below) is implicitly stored in the journal as well,
2669 the specific option listed below is hence a superset of this one.
2670 (Also note that any external, additional syslog daemons receive
2671 their log data from the journal, too, hence this is the option to
2672 use when logging shall be processed with such a daemon.)
2673
2674 kmsg connects standard output with the kernel log buffer which is
2675 accessible via dmesg(1), in addition to the journal. The journal
2676 daemon might be configured to send all logs to kmsg anyway, in
2677 which case this option is no different from journal.
2678
2679 journal+console and kmsg+console work in a similar way as the two
2680 options above but copy the output to the system console as well.
2681
2682 The file:path option may be used to connect a specific file system
2683 object to standard output. The semantics are similar to the same
2684 option of StandardInput=, see above. If path refers to a regular
2685 file on the filesystem, it is opened (created if it doesn't exist
2686 yet) for writing at the beginning of the file, but without
2687 truncating it. If standard input and output are directed to the
2688 same file path, it is opened only once — for reading as well as
2689 writing — and duplicated. This is particularly useful when the
2690 specified path refers to an AF_UNIX socket in the file system, as
2691 in that case only a single stream connection is created for both
2692 input and output.
2693
2694 append:path is similar to file:path above, but it opens the file in
2695 append mode.
2696
2697 truncate:path is similar to file:path above, but it truncates the
2698 file when opening it. For units with multiple command lines, e.g.
2699 Type=oneshot services with multiple ExecStart=, or services with
2700 ExecCondition=, ExecStartPre= or ExecStartPost=, the output file is
2701 reopened and therefore re-truncated for each command line. If the
2702 output file is truncated while another process still has the file
2703 open, e.g. by an ExecReload= running concurrently with an
2704 ExecStart=, and the other process continues writing to the file
2705 without adjusting its offset, then the space between the file
2706 pointers of the two processes may be filled with NUL bytes,
2707 producing a sparse file. Thus, truncate:path is typically only
2708 useful for units where only one process runs at a time, such as
2709 services with a single ExecStart= and no ExecStartPost=,
2710 ExecReload=, ExecStop= or similar.
2711
2712 socket connects standard output to a socket acquired via socket
2713 activation. The semantics are similar to the same option of
2714 StandardInput=, see above.
2715
2716 The fd:name option connects standard output to a specific, named
2717 file descriptor provided by a socket unit. A name may be specified
2718 as part of this option, following a ":" character (e.g.
2719 "fd:foobar"). If no name is specified, the name "stdout" is implied
2720 (i.e. "fd" is equivalent to "fd:stdout"). At least one socket unit
2721 defining the specified name must be provided via the Sockets=
2722 option, and the file descriptor name may differ from the name of
2723 its containing socket unit. If multiple matches are found, the
2724 first one will be used. See FileDescriptorName= in
2725 systemd.socket(5) for more details about named descriptors and
2726 their ordering.
2727
2728 If the standard output (or error output, see below) of a unit is
2729 connected to the journal or the kernel log buffer, the unit will
2730 implicitly gain a dependency of type After= on
2731 systemd-journald.socket (also see the "Implicit Dependencies"
2732 section above). Also note that in this case stdout (or stderr, see
2733 below) will be an AF_UNIX stream socket, and not a pipe or FIFO
2734 that can be re-opened. This means when executing shell scripts the
2735 construct echo "hello" > /dev/stderr for writing text to stderr
2736 will not work. To mitigate this use the construct echo "hello" >&2
2737 instead, which is mostly equivalent and avoids this pitfall.
2738
2739 If StandardInput= is set to one of tty, tty-force, tty-fail,
2740 socket, or fd:name, this setting defaults to inherit.
2741
2742 In other cases, this setting defaults to the value set with
2743 DefaultStandardOutput= in systemd-system.conf(5), which defaults to
2744 journal. Note that setting this parameter might result in
2745 additional dependencies to be added to the unit (see above).
2746
2747 StandardError=
2748 Controls where file descriptor 2 (stderr) of the executed processes
2749 is connected to. The available options are identical to those of
2750 StandardOutput=, with some exceptions: if set to inherit the file
2751 descriptor used for standard output is duplicated for standard
2752 error, while fd:name will use a default file descriptor name of
2753 "stderr".
2754
2755 This setting defaults to the value set with DefaultStandardError=
2756 in systemd-system.conf(5), which defaults to inherit. Note that
2757 setting this parameter might result in additional dependencies to
2758 be added to the unit (see above).
2759
2760 StandardInputText=, StandardInputData=
2761 Configures arbitrary textual or binary data to pass via file
2762 descriptor 0 (STDIN) to the executed processes. These settings have
2763 no effect unless StandardInput= is set to data (which is the
2764 default if StandardInput= is not set otherwise, but
2765 StandardInputText=/StandardInputData= is). Use this option to embed
2766 process input data directly in the unit file.
2767
2768 StandardInputText= accepts arbitrary textual data. C-style escapes
2769 for special characters as well as the usual "%"-specifiers are
2770 resolved. Each time this setting is used the specified text is
2771 appended to the per-unit data buffer, followed by a newline
2772 character (thus every use appends a new line to the end of the
2773 buffer). Note that leading and trailing whitespace of lines
2774 configured with this option is removed. If an empty line is
2775 specified the buffer is cleared (hence, in order to insert an empty
2776 line, add an additional "\n" to the end or beginning of a line).
2777
2778 StandardInputData= accepts arbitrary binary data, encoded in
2779 Base64[13]. No escape sequences or specifiers are resolved. Any
2780 whitespace in the encoded version is ignored during decoding.
2781
2782 Note that StandardInputText= and StandardInputData= operate on the
2783 same data buffer, and may be mixed in order to configure both
2784 binary and textual data for the same input stream. The textual or
2785 binary data is joined strictly in the order the settings appear in
2786 the unit file. Assigning an empty string to either will reset the
2787 data buffer.
2788
2789 Please keep in mind that in order to maintain readability long unit
2790 file settings may be split into multiple lines, by suffixing each
2791 line (except for the last) with a "\" character (see
2792 systemd.unit(5) for details). This is particularly useful for large
2793 data configured with these two options. Example:
2794
2795 ...
2796 StandardInput=data
2797 StandardInputData=V2XigLJyZSBubyBzdHJhbmdlcnMgdG8gbG92ZQpZb3Uga25vdyB0aGUgcnVsZXMgYW5kIHNvIGRv \
2798 IEkKQSBmdWxsIGNvbW1pdG1lbnQncyB3aGF0IEnigLJtIHRoaW5raW5nIG9mCllvdSB3b3VsZG4n \
2799 dCBnZXQgdGhpcyBmcm9tIGFueSBvdGhlciBndXkKSSBqdXN0IHdhbm5hIHRlbGwgeW91IGhvdyBJ \
2800 J20gZmVlbGluZwpHb3R0YSBtYWtlIHlvdSB1bmRlcnN0YW5kCgpOZXZlciBnb25uYSBnaXZlIHlv \
2801 dSB1cApOZXZlciBnb25uYSBsZXQgeW91IGRvd24KTmV2ZXIgZ29ubmEgcnVuIGFyb3VuZCBhbmQg \
2802 ZGVzZXJ0IHlvdQpOZXZlciBnb25uYSBtYWtlIHlvdSBjcnkKTmV2ZXIgZ29ubmEgc2F5IGdvb2Ri \
2803 eWUKTmV2ZXIgZ29ubmEgdGVsbCBhIGxpZSBhbmQgaHVydCB5b3UK
2804 ...
2805
2806 LogLevelMax=
2807 Configures filtering by log level of log messages generated by this
2808 unit. Takes a syslog log level, one of emerg (lowest log level,
2809 only highest priority messages), alert, crit, err, warning, notice,
2810 info, debug (highest log level, also lowest priority messages). See
2811 syslog(3) for details. By default no filtering is applied (i.e. the
2812 default maximum log level is debug). Use this option to configure
2813 the logging system to drop log messages of a specific service above
2814 the specified level. For example, set LogLevelMax=info in order to
2815 turn off debug logging of a particularly chatty unit. Note that the
2816 configured level is applied to any log messages written by any of
2817 the processes belonging to this unit, as well as any log messages
2818 written by the system manager process (PID 1) in reference to this
2819 unit, sent via any supported logging protocol. The filtering is
2820 applied early in the logging pipeline, before any kind of further
2821 processing is done. Moreover, messages which pass through this
2822 filter successfully might still be dropped by filters applied at a
2823 later stage in the logging subsystem. For example, MaxLevelStore=
2824 configured in journald.conf(5) might prohibit messages of higher
2825 log levels to be stored on disk, even though the per-unit
2826 LogLevelMax= permitted it to be processed.
2827
2828 LogExtraFields=
2829 Configures additional log metadata fields to include in all log
2830 records generated by processes associated with this unit. This
2831 setting takes one or more journal field assignments in the format
2832 "FIELD=VALUE" separated by whitespace. See systemd.journal-
2833 fields(7) for details on the journal field concept. Even though the
2834 underlying journal implementation permits binary field values, this
2835 setting accepts only valid UTF-8 values. To include space
2836 characters in a journal field value, enclose the assignment in
2837 double quotes ("). The usual specifiers are expanded in all
2838 assignments (see below). Note that this setting is not only useful
2839 for attaching additional metadata to log records of a unit, but
2840 given that all fields and values are indexed may also be used to
2841 implement cross-unit log record matching. Assign an empty string to
2842 reset the list.
2843
2844 LogRateLimitIntervalSec=, LogRateLimitBurst=
2845 Configures the rate limiting that is applied to messages generated
2846 by this unit. If, in the time interval defined by
2847 LogRateLimitIntervalSec=, more messages than specified in
2848 LogRateLimitBurst= are logged by a service, all further messages
2849 within the interval are dropped until the interval is over. A
2850 message about the number of dropped messages is generated. The time
2851 specification for LogRateLimitIntervalSec= may be specified in the
2852 following units: "s", "min", "h", "ms", "us" (see systemd.time(7)
2853 for details). The default settings are set by RateLimitIntervalSec=
2854 and RateLimitBurst= configured in journald.conf(5).
2855
2856 LogNamespace=
2857 Run the unit's processes in the specified journal namespace.
2858 Expects a short user-defined string identifying the namespace. If
2859 not used the processes of the service are run in the default
2860 journal namespace, i.e. their log stream is collected and processed
2861 by systemd-journald.service. If this option is used any log data
2862 generated by processes of this unit (regardless if via the
2863 syslog(), journal native logging or stdout/stderr logging) is
2864 collected and processed by an instance of the
2865 systemd-journald@.service template unit, which manages the
2866 specified namespace. The log data is stored in a data store
2867 independent from the default log namespace's data store. See
2868 systemd-journald.service(8) for details about journal namespaces.
2869
2870 Internally, journal namespaces are implemented through Linux mount
2871 namespacing and over-mounting the directory that contains the
2872 relevant AF_UNIX sockets used for logging in the unit's mount
2873 namespace. Since mount namespaces are used this setting disconnects
2874 propagation of mounts from the unit's processes to the host,
2875 similar to how ReadOnlyPaths= and similar settings (see above)
2876 work. Journal namespaces may hence not be used for services that
2877 need to establish mount points on the host.
2878
2879 When this option is used the unit will automatically gain ordering
2880 and requirement dependencies on the two socket units associated
2881 with the systemd-journald@.service instance so that they are
2882 automatically established prior to the unit starting up. Note that
2883 when this option is used log output of this service does not appear
2884 in the regular journalctl(1) output, unless the --namespace= option
2885 is used.
2886
2887 This option is only available for system services and is not
2888 supported for services running in per-user instances of the service
2889 manager.
2890
2891 SyslogIdentifier=
2892 Sets the process name ("syslog tag") to prefix log lines sent to
2893 the logging system or the kernel log buffer with. If not set,
2894 defaults to the process name of the executed process. This option
2895 is only useful when StandardOutput= or StandardError= are set to
2896 journal or kmsg (or to the same settings in combination with
2897 +console) and only applies to log messages written to stdout or
2898 stderr.
2899
2900 SyslogFacility=
2901 Sets the syslog facility identifier to use when logging. One of
2902 kern, user, mail, daemon, auth, syslog, lpr, news, uucp, cron,
2903 authpriv, ftp, local0, local1, local2, local3, local4, local5,
2904 local6 or local7. See syslog(3) for details. This option is only
2905 useful when StandardOutput= or StandardError= are set to journal or
2906 kmsg (or to the same settings in combination with +console), and
2907 only applies to log messages written to stdout or stderr. Defaults
2908 to daemon.
2909
2910 SyslogLevel=
2911 The default syslog log level to use when logging to the logging
2912 system or the kernel log buffer. One of emerg, alert, crit, err,
2913 warning, notice, info, debug. See syslog(3) for details. This
2914 option is only useful when StandardOutput= or StandardError= are
2915 set to journal or kmsg (or to the same settings in combination with
2916 +console), and only applies to log messages written to stdout or
2917 stderr. Note that individual lines output by executed processes may
2918 be prefixed with a different log level which can be used to
2919 override the default log level specified here. The interpretation
2920 of these prefixes may be disabled with SyslogLevelPrefix=, see
2921 below. For details, see sd-daemon(3). Defaults to info.
2922
2923 SyslogLevelPrefix=
2924 Takes a boolean argument. If true and StandardOutput= or
2925 StandardError= are set to journal or kmsg (or to the same settings
2926 in combination with +console), log lines written by the executed
2927 process that are prefixed with a log level will be processed with
2928 this log level set but the prefix removed. If set to false, the
2929 interpretation of these prefixes is disabled and the logged lines
2930 are passed on as-is. This only applies to log messages written to
2931 stdout or stderr. For details about this prefixing see sd-
2932 daemon(3). Defaults to true.
2933
2934 TTYPath=
2935 Sets the terminal device node to use if standard input, output, or
2936 error are connected to a TTY (see above). Defaults to /dev/console.
2937
2938 TTYReset=
2939 Reset the terminal device specified with TTYPath= before and after
2940 execution. Defaults to "no".
2941
2942 TTYVHangup=
2943 Disconnect all clients which have opened the terminal device
2944 specified with TTYPath= before and after execution. Defaults to
2945 "no".
2946
2947 TTYRows=, TTYColumns=
2948 Configure the size of the TTY specified with TTYPath=. If unset or
2949 set to the empty string, the kernel default is used.
2950
2951 TTYVTDisallocate=
2952 If the terminal device specified with TTYPath= is a virtual console
2953 terminal, try to deallocate the TTY before and after execution.
2954 This ensures that the screen and scrollback buffer is cleared.
2955 Defaults to "no".
2956
2958 LoadCredential=ID[:PATH], LoadCredentialEncrypted=ID[:PATH]
2959 Pass a credential to the unit. Credentials are limited-size binary
2960 or textual objects that may be passed to unit processes. They are
2961 primarily used for passing cryptographic keys (both public and
2962 private) or certificates, user account information or identity
2963 information from host to services. The data is accessible from the
2964 unit's processes via the file system, at a read-only location that
2965 (if possible and permitted) is backed by non-swappable memory. The
2966 data is only accessible to the user associated with the unit, via
2967 the User=/DynamicUser= settings (as well as the superuser). When
2968 available, the location of credentials is exported as the
2969 $CREDENTIALS_DIRECTORY environment variable to the unit's
2970 processes.
2971
2972 The LoadCredential= setting takes a textual ID to use as name for a
2973 credential plus a file system path, separated by a colon. The ID
2974 must be a short ASCII string suitable as filename in the
2975 filesystem, and may be chosen freely by the user. If the specified
2976 path is absolute it is opened as regular file and the credential
2977 data is read from it. If the absolute path refers to an AF_UNIX
2978 stream socket in the file system a connection is made to it (only
2979 once at unit start-up) and the credential data read from the
2980 connection, providing an easy IPC integration point for dynamically
2981 transferring credentials from other services.
2982
2983 If the specified path is not absolute and itself qualifies as valid
2984 credential identifier it is attempted to find a credential that the
2985 service manager itself received under the specified name — which
2986 may be used to propagate credentials from an invoking environment
2987 (e.g. a container manager that invoked the service manager) into a
2988 service. If no matching system credential is found, the directories
2989 /etc/credstore/, /run/credstore/ and /usr/lib/credstore/ are
2990 searched for files under the credential's name — which hence are
2991 recommended locations for credential data on disk. If
2992 LoadCredentialEncrypted= is used /run/credstore.encrypted/,
2993 /etc/credstore.encrypted/, and /usr/lib/credstore.encrypted/ are
2994 searched as well.
2995
2996 If the file system path is omitted it is chosen identical to the
2997 credential name, i.e. this is a terse way to declare credentials to
2998 inherit from the service manager into a service. This option may be
2999 used multiple times, each time defining an additional credential to
3000 pass to the unit.
3001
3002 If an absolute path referring to a directory is specified, every
3003 file in that directory (recursively) will be loaded as a separate
3004 credential. The ID for each credential will be the provided ID
3005 suffixed with "_$FILENAME" (e.g., "Key_file1"). When loading from a
3006 directory, symlinks will be ignored.
3007
3008 The contents of the file/socket may be arbitrary binary or textual
3009 data, including newline characters and NUL bytes.
3010
3011 The LoadCredentialEncrypted= setting is identical to
3012 LoadCredential=, except that the credential data is decrypted and
3013 authenticated before being passed on to the executed processes.
3014 Specifically, the referenced path should refer to a file or socket
3015 with an encrypted credential, as implemented by systemd-creds(1).
3016 This credential is loaded, decrypted, authenticated and then passed
3017 to the application in plaintext form, in the same way a regular
3018 credential specified via LoadCredential= would be. A credential
3019 configured this way may be symmetrically encrypted/authenticated
3020 with a secret key derived from the system's TPM2 security chip, or
3021 with a secret key stored in /var/lib/systemd/credentials.secret, or
3022 with both. Using encrypted and authenticated credentials improves
3023 security as credentials are not stored in plaintext and only
3024 authenticated and decrypted into plaintext the moment a service
3025 requiring them is started. Moreover, credentials may be bound to
3026 the local hardware and installations, so that they cannot easily be
3027 analyzed offline, or be generated externally.
3028
3029 The credential files/IPC sockets must be accessible to the service
3030 manager, but don't have to be directly accessible to the unit's
3031 processes: the credential data is read and copied into separate,
3032 read-only copies for the unit that are accessible to appropriately
3033 privileged processes. This is particularly useful in combination
3034 with DynamicUser= as this way privileged data can be made available
3035 to processes running under a dynamic UID (i.e. not a previously
3036 known one) without having to open up access to all users.
3037
3038 In order to reference the path a credential may be read from within
3039 a ExecStart= command line use "${CREDENTIALS_DIRECTORY}/mycred",
3040 e.g. "ExecStart=cat ${CREDENTIALS_DIRECTORY}/mycred". In order to
3041 reference the path a credential may be read from within a
3042 Environment= line use "%d/mycred", e.g.
3043 "Environment=MYCREDPATH=%d/mycred".
3044
3045 Currently, an accumulated credential size limit of 1 MB per unit is
3046 enforced.
3047
3048 The service manager itself may receive system credentials that can
3049 be propagated to services from a hosting container manager or VM
3050 hypervisor. See the Container Interface[14] documentation for
3051 details about the former. For the latter, use the qemu "fw_cfg"
3052 node "opt/io.systemd.credentials/". Example qemu switch: "-fw_cfg
3053 name=opt/io.systemd.credentials/mycred,string=supersecret". They
3054 may also be specified on the kernel command line using the
3055 "systemd.set_credential=" switch (see systemd(1)) and from the UEFI
3056 firmware environment via systemd-stub(7).
3057
3058 If referencing an AF_UNIX stream socket to connect to, the
3059 connection will originate from an abstract namespace socket, that
3060 includes information about the unit and the credential ID in its
3061 socket name. Use getpeername(2) to query this information. The
3062 returned socket name is formatted as NUL RANDOM "/unit/" UNIT "/"
3063 ID, i.e. a NUL byte (as required for abstract namespace socket
3064 names), followed by a random string (consisting of alphadecimal
3065 characters), followed by the literal string "/unit/", followed by
3066 the requesting unit name, followed by the literal character "/",
3067 followed by the textual credential ID requested. Example:
3068 "\0adf9d86b6eda275e/unit/foobar.service/credx" in case the
3069 credential "credx" is requested for a unit "foobar.service". This
3070 functionality is useful for using a single listening socket to
3071 serve credentials to multiple consumers.
3072
3073 For further information see System and Service Credentials[15]
3074 documentation.
3075
3076 SetCredential=ID:VALUE, SetCredentialEncrypted=ID:VALUE
3077 The SetCredential= setting is similar to LoadCredential= but
3078 accepts a literal value to use as data for the credential, instead
3079 of a file system path to read the data from. Do not use this option
3080 for data that is supposed to be secret, as it is accessible to
3081 unprivileged processes via IPC. It's only safe to use this for user
3082 IDs, public key material and similar non-sensitive data. For
3083 everything else use LoadCredential=. In order to embed binary data
3084 into the credential data use C-style escaping (i.e. "\n" to embed
3085 a newline, or "\x00" to embed a NUL byte).
3086
3087 The SetCredentialEncrypted= setting is identical to SetCredential=
3088 but expects an encrypted credential in literal form as value. This
3089 allows embedding confidential credentials securely directly in unit
3090 files. Use systemd-creds(1)' -p switch to generate suitable
3091 SetCredentialEncrypted= lines directly from plaintext credentials.
3092 For further details see LoadCredentialEncrypted= above.
3093
3094 If a credential of the same ID is listed in both LoadCredential=
3095 and SetCredential=, the latter will act as default if the former
3096 cannot be retrieved. In this case not being able to retrieve the
3097 credential from the path specified in LoadCredential= is not
3098 considered fatal.
3099
3101 UtmpIdentifier=
3102 Takes a four character identifier string for an utmp(5) and wtmp
3103 entry for this service. This should only be set for services such
3104 as getty implementations (such as agetty(8)) where utmp/wtmp
3105 entries must be created and cleared before and after execution, or
3106 for services that shall be executed as if they were run by a getty
3107 process (see below). If the configured string is longer than four
3108 characters, it is truncated and the terminal four characters are
3109 used. This setting interprets %I style string replacements. This
3110 setting is unset by default, i.e. no utmp/wtmp entries are created
3111 or cleaned up for this service.
3112
3113 UtmpMode=
3114 Takes one of "init", "login" or "user". If UtmpIdentifier= is set,
3115 controls which type of utmp(5)/wtmp entries for this service are
3116 generated. This setting has no effect unless UtmpIdentifier= is set
3117 too. If "init" is set, only an INIT_PROCESS entry is generated and
3118 the invoked process must implement a getty-compatible utmp/wtmp
3119 logic. If "login" is set, first an INIT_PROCESS entry, followed by
3120 a LOGIN_PROCESS entry is generated. In this case, the invoked
3121 process must implement a login(1)-compatible utmp/wtmp logic. If
3122 "user" is set, first an INIT_PROCESS entry, then a LOGIN_PROCESS
3123 entry and finally a USER_PROCESS entry is generated. In this case,
3124 the invoked process may be any process that is suitable to be run
3125 as session leader. Defaults to "init".
3126
3128 Processes started by the service manager are executed with an
3129 environment variable block assembled from multiple sources. Processes
3130 started by the system service manager generally do not inherit
3131 environment variables set for the service manager itself (but this may
3132 be altered via PassEnvironment=), but processes started by the user
3133 service manager instances generally do inherit all environment
3134 variables set for the service manager itself.
3135
3136 For each invoked process the list of environment variables set is
3137 compiled from the following sources:
3138
3139 • Variables globally configured for the service manager, using the
3140 DefaultEnvironment= setting in systemd-system.conf(5), the kernel
3141 command line option systemd.setenv= understood by systemd(1), or
3142 via systemctl(1) set-environment verb.
3143
3144 • Variables defined by the service manager itself (see the list
3145 below).
3146
3147 • Variables set in the service manager's own environment variable
3148 block (subject to PassEnvironment= for the system service manager).
3149
3150 • Variables set via Environment= in the unit file.
3151
3152 • Variables read from files specified via EnvironmentFile= in the
3153 unit file.
3154
3155 • Variables set by any PAM modules in case PAMName= is in effect,
3156 cf. pam_env(8).
3157
3158 If the same environment variable is set by multiple of these sources,
3159 the later source — according to the order of the list above — wins.
3160 Note that as the final step all variables listed in UnsetEnvironment=
3161 are removed from the compiled environment variable list, immediately
3162 before it is passed to the executed process.
3163
3164 The general philosophy is to expose a small curated list of environment
3165 variables to processes. Services started by the system manager (PID 1)
3166 will be started, without additional service-specific configuration,
3167 with just a few environment variables. The user manager inherits
3168 environment variables as any other system service, but in addition may
3169 receive additional environment variables from PAM, and, typically,
3170 additional imported variables when the user starts a graphical session.
3171 It is recommended to keep the environment blocks in both the system and
3172 user managers lean. Importing all variables inherited by the graphical
3173 session or by one of the user shells is strongly discouraged.
3174
3175 Hint: systemd-run -P env and systemd-run --user -P env print the
3176 effective system and user service environment blocks.
3177
3178 Environment Variables Set or Propagated by the Service Manager
3179 The following environment variables are propagated by the service
3180 manager or generated internally for each invoked process:
3181
3182 $PATH
3183 Colon-separated list of directories to use when launching
3184 executables. systemd uses a fixed value of
3185 "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" in the system
3186 manager. When compiled for systems with "unmerged /usr/" (/bin is
3187 not a symlink to /usr/bin), ":/sbin:/bin" is appended. In case of
3188 the user manager, a different path may be configured by the
3189 distribution. It is recommended to not rely on the order of
3190 entries, and have only one program with a given name in $PATH.
3191
3192 $LANG
3193 Locale. Can be set in locale.conf(5) or on the kernel command line
3194 (see systemd(1) and kernel-command-line(7)).
3195
3196 $USER, $LOGNAME, $HOME, $SHELL
3197 User name (twice), home directory, and the login shell. The
3198 variables are set for the units that have User= set, which includes
3199 user systemd instances. See passwd(5).
3200
3201 $INVOCATION_ID
3202 Contains a randomized, unique 128bit ID identifying each runtime
3203 cycle of the unit, formatted as 32 character hexadecimal string. A
3204 new ID is assigned each time the unit changes from an inactive
3205 state into an activating or active state, and may be used to
3206 identify this specific runtime cycle, in particular in data stored
3207 offline, such as the journal. The same ID is passed to all
3208 processes run as part of the unit.
3209
3210 $XDG_RUNTIME_DIR
3211 The directory to use for runtime objects (such as IPC objects) and
3212 volatile state. Set for all services run by the user systemd
3213 instance, as well as any system services that use PAMName= with a
3214 PAM stack that includes pam_systemd. See below and pam_systemd(8)
3215 for more information.
3216
3217 $RUNTIME_DIRECTORY, $STATE_DIRECTORY, $CACHE_DIRECTORY,
3218 $LOGS_DIRECTORY, $CONFIGURATION_DIRECTORY
3219 Absolute paths to the directories defined with RuntimeDirectory=,
3220 StateDirectory=, CacheDirectory=, LogsDirectory=, and
3221 ConfigurationDirectory= when those settings are used.
3222
3223 $CREDENTIALS_DIRECTORY
3224 An absolute path to the per-unit directory with credentials
3225 configured via LoadCredential=/SetCredential=. The directory is
3226 marked read-only and is placed in unswappable memory (if supported
3227 and permitted), and is only accessible to the UID associated with
3228 the unit via User= or DynamicUser= (and the superuser).
3229
3230 $MAINPID
3231 The PID of the unit's main process if it is known. This is only set
3232 for control processes as invoked by ExecReload= and similar.
3233
3234 $MANAGERPID
3235 The PID of the user systemd instance, set for processes spawned by
3236 it.
3237
3238 $LISTEN_FDS, $LISTEN_PID, $LISTEN_FDNAMES
3239 Information about file descriptors passed to a service for socket
3240 activation. See sd_listen_fds(3).
3241
3242 $NOTIFY_SOCKET
3243 The socket sd_notify() talks to. See sd_notify(3).
3244
3245 $WATCHDOG_PID, $WATCHDOG_USEC
3246 Information about watchdog keep-alive notifications. See
3247 sd_watchdog_enabled(3).
3248
3249 $SYSTEMD_EXEC_PID
3250 The PID of the unit process (e.g. process invoked by ExecStart=).
3251 The child process can use this information to determine whether the
3252 process is directly invoked by the service manager or indirectly as
3253 a child of another process by comparing this value with the current
3254 PID (as similar to the scheme used in sd_listen_fds(3) with
3255 $LISTEN_PID and $LISTEN_FDS).
3256
3257 $TERM
3258 Terminal type, set only for units connected to a terminal
3259 (StandardInput=tty, StandardOutput=tty, or StandardError=tty). See
3260 termcap(5).
3261
3262 $LOG_NAMESPACE
3263 Contains the name of the selected logging namespace when the
3264 LogNamespace= service setting is used.
3265
3266 $JOURNAL_STREAM
3267 If the standard output or standard error output of the executed
3268 processes are connected to the journal (for example, by setting
3269 StandardError=journal) $JOURNAL_STREAM contains the device and
3270 inode numbers of the connection file descriptor, formatted in
3271 decimal, separated by a colon (":"). This permits invoked processes
3272 to safely detect whether their standard output or standard error
3273 output are connected to the journal. The device and inode numbers
3274 of the file descriptors should be compared with the values set in
3275 the environment variable to determine whether the process output is
3276 still connected to the journal. Note that it is generally not
3277 sufficient to only check whether $JOURNAL_STREAM is set at all as
3278 services might invoke external processes replacing their standard
3279 output or standard error output, without unsetting the environment
3280 variable.
3281
3282 If both standard output and standard error of the executed
3283 processes are connected to the journal via a stream socket, this
3284 environment variable will contain information about the standard
3285 error stream, as that's usually the preferred destination for log
3286 data. (Note that typically the same stream is used for both
3287 standard output and standard error, hence very likely the
3288 environment variable contains device and inode information matching
3289 both stream file descriptors.)
3290
3291 This environment variable is primarily useful to allow services to
3292 optionally upgrade their used log protocol to the native journal
3293 protocol (using sd_journal_print(3) and other functions) if their
3294 standard output or standard error output is connected to the
3295 journal anyway, thus enabling delivery of structured metadata along
3296 with logged messages.
3297
3298 $SERVICE_RESULT
3299 Only used for the service unit type. This environment variable is
3300 passed to all ExecStop= and ExecStopPost= processes, and encodes
3301 the service "result". Currently, the following values are defined:
3302
3303 Table 5. Defined $SERVICE_RESULT values
3304 ┌──────────────────┬────────────────────────────┐
3305 │Value │ Meaning │
3306 ├──────────────────┼────────────────────────────┤
3307 │"success" │ The service ran │
3308 │ │ successfully and exited │
3309 │ │ cleanly. │
3310 ├──────────────────┼────────────────────────────┤
3311 │"protocol" │ A protocol violation │
3312 │ │ occurred: the service did │
3313 │ │ not take the steps │
3314 │ │ required by its unit │
3315 │ │ configuration │
3316 │ │ (specifically what is │
3317 │ │ configured in its Type= │
3318 │ │ setting). │
3319 ├──────────────────┼────────────────────────────┤
3320 │"timeout" │ One of the steps timed │
3321 │ │ out. │
3322 ├──────────────────┼────────────────────────────┤
3323 │"exit-code" │ Service process exited │
3324 │ │ with a non-zero exit code; │
3325 │ │ see $EXIT_CODE below for │
3326 │ │ the actual exit code │
3327 │ │ returned. │
3328 ├──────────────────┼────────────────────────────┤
3329 │"signal" │ A service process was │
3330 │ │ terminated abnormally by a │
3331 │ │ signal, without dumping │
3332 │ │ core. See $EXIT_CODE below │
3333 │ │ for the actual signal │
3334 │ │ causing the termination. │
3335 ├──────────────────┼────────────────────────────┤
3336 │"core-dump" │ A service process │
3337 │ │ terminated abnormally with │
3338 │ │ a signal and dumped core. │
3339 │ │ See $EXIT_CODE below for │
3340 │ │ the signal causing the │
3341 │ │ termination. │
3342 ├──────────────────┼────────────────────────────┤
3343 │"watchdog" │ Watchdog keep-alive ping │
3344 │ │ was enabled for the │
3345 │ │ service, but the deadline │
3346 │ │ was missed. │
3347 ├──────────────────┼────────────────────────────┤
3348 │"start-limit-hit" │ A start limit was defined │
3349 │ │ for the unit and it was │
3350 │ │ hit, causing the unit to │
3351 │ │ fail to start. See │
3352 │ │ systemd.unit(5)'s │
3353 │ │ StartLimitIntervalSec= and │
3354 │ │ StartLimitBurst= for │
3355 │ │ details. │
3356 ├──────────────────┼────────────────────────────┤
3357 │"resources" │ A catch-all condition in │
3358 │ │ case a system operation │
3359 │ │ failed. │
3360 └──────────────────┴────────────────────────────┘
3361 This environment variable is useful to monitor failure or
3362 successful termination of a service. Even though this variable is
3363 available in both ExecStop= and ExecStopPost=, it is usually a
3364 better choice to place monitoring tools in the latter, as the
3365 former is only invoked for services that managed to start up
3366 correctly, and the latter covers both services that failed during
3367 their start-up and those which failed during their runtime.
3368
3369 $EXIT_CODE, $EXIT_STATUS
3370 Only defined for the service unit type. These environment variables
3371 are passed to all ExecStop=, ExecStopPost= processes and contain
3372 exit status/code information of the main process of the service.
3373 For the precise definition of the exit code and status, see
3374 wait(2). $EXIT_CODE is one of "exited", "killed", "dumped".
3375 $EXIT_STATUS contains the numeric exit code formatted as string if
3376 $EXIT_CODE is "exited", and the signal name in all other cases.
3377 Note that these environment variables are only set if the service
3378 manager succeeded to start and identify the main process of the
3379 service.
3380
3381 Table 6. Summary of possible service result variable values
3382 ┌──────────────────┬──────────────────┬─────────────────────┐
3383 │$SERVICE_RESULT │ $EXIT_CODE │ $EXIT_STATUS │
3384 ├──────────────────┼──────────────────┼─────────────────────┤
3385 │"success" │ "killed" │ "HUP", "INT", │
3386 │ │ │ "TERM", "PIPE" │
3387 │ ├──────────────────┼─────────────────────┤
3388 │ │ "exited" │ "0" │
3389 ├──────────────────┼──────────────────┼─────────────────────┤
3390 │"protocol" │ not set │ not set │
3391 │ ├──────────────────┼─────────────────────┤
3392 │ │ "exited" │ "0" │
3393 ├──────────────────┼──────────────────┼─────────────────────┤
3394 │"timeout" │ "killed" │ "TERM", "KILL" │
3395 │ ├──────────────────┼─────────────────────┤
3396 │ │ "exited" │ "0", "1", "2", "3", │
3397 │ │ │ ..., "255" │
3398 ├──────────────────┼──────────────────┼─────────────────────┤
3399 │"exit-code" │ "exited" │ "1", "2", "3", ..., │
3400 │ │ │ "255" │
3401 ├──────────────────┼──────────────────┼─────────────────────┤
3402 │"signal" │ "killed" │ "HUP", "INT", │
3403 │ │ │ "KILL", ... │
3404 ├──────────────────┼──────────────────┼─────────────────────┤
3405 │"core-dump" │ "dumped" │ "ABRT", "SEGV", │
3406 │ │ │ "QUIT", ... │
3407 ├──────────────────┼──────────────────┼─────────────────────┤
3408 │"watchdog" │ "dumped" │ "ABRT" │
3409 │ ├──────────────────┼─────────────────────┤
3410 │ │ "killed" │ "TERM", "KILL" │
3411 │ ├──────────────────┼─────────────────────┤
3412 │ │ "exited" │ "0", "1", "2", "3", │
3413 │ │ │ ..., "255" │
3414 ├──────────────────┼──────────────────┼─────────────────────┤
3415 │"exec-condition" │ "exited" │ "1", "2", "3", "4", │
3416 │ │ │ ..., "254" │
3417 ├──────────────────┼──────────────────┼─────────────────────┤
3418 │"oom-kill" │ "killed" │ "TERM", "KILL" │
3419 ├──────────────────┼──────────────────┼─────────────────────┤
3420 │"start-limit-hit" │ not set │ not set │
3421 ├──────────────────┼──────────────────┼─────────────────────┤
3422 │"resources" │ any of the above │ any of the above │
3423 ├──────────────────┴──────────────────┴─────────────────────┤
3424 │Note: the process may be also terminated by a signal not │
3425 │sent by systemd. In particular the process may send an │
3426 │arbitrary signal to itself in a handler for any of the │
3427 │non-maskable signals. Nevertheless, in the "timeout" and │
3428 │"watchdog" rows above only the signals that systemd sends │
3429 │have been included. Moreover, using SuccessExitStatus= │
3430 │additional exit statuses may be declared to indicate clean │
3431 │termination, which is not reflected by this table. │
3432 └───────────────────────────────────────────────────────────┘
3433
3434 $MONITOR_SERVICE_RESULT, $MONITOR_EXIT_CODE, $MONITOR_EXIT_STATUS,
3435 $MONITOR_INVOCATION_ID, $MONITOR_UNIT
3436 Only defined for the service unit type. Those environment variables
3437 are passed to all ExecStart= and ExecStartPre= processes which run
3438 in services triggered by OnFailure= or OnSuccess= dependencies.
3439
3440 Variables $MONITOR_SERVICE_RESULT, $MONITOR_EXIT_CODE and
3441 $MONITOR_EXIT_STATUS take the same values as for ExecStop= and
3442 ExecStopPost= processes. Variables $MONITOR_INVOCATION_ID and
3443 $MONITOR_UNIT are set to the invocation id and unit name of the
3444 service which triggered the dependency.
3445
3446 Note that when multiple services trigger the same unit, those
3447 variables will be not be passed. Consider using a template handler
3448 unit for that case instead: "OnFailure=handler@%n.service" for
3449 non-templated units, or "OnFailure=handler@%p-%i.service" for
3450 templated units.
3451
3452 $PIDFILE
3453 The path to the configured PID file, in case the process is forked
3454 off on behalf of a service that uses the PIDFile= setting, see
3455 systemd.service(5) for details. Service code may use this
3456 environment variable to automatically generate a PID file at the
3457 location configured in the unit file. This field is set to an
3458 absolute path in the file system.
3459
3460 For system services, when PAMName= is enabled and pam_systemd is part
3461 of the selected PAM stack, additional environment variables defined by
3462 systemd may be set for services. Specifically, these are $XDG_SEAT,
3463 $XDG_VTNR, see pam_systemd(8) for details.
3464
3466 When invoking a unit process the service manager possibly fails to
3467 apply the execution parameters configured with the settings above. In
3468 that case the already created service process will exit with a non-zero
3469 exit code before the configured command line is executed. (Or in other
3470 words, the child process possibly exits with these error codes, after
3471 having been created by the fork(2) system call, but before the matching
3472 execve(2) system call is called.) Specifically, exit codes defined by
3473 the C library, by the LSB specification and by the systemd service
3474 manager itself are used.
3475
3476 The following basic service exit codes are defined by the C library.
3477
3478 Table 7. Basic C library exit codes
3479 ┌──────────┬───────────────┬────────────────────┐
3480 │Exit Code │ Symbolic Name │ Description │
3481 ├──────────┼───────────────┼────────────────────┤
3482 │0 │ EXIT_SUCCESS │ Generic success │
3483 │ │ │ code. │
3484 ├──────────┼───────────────┼────────────────────┤
3485 │1 │ EXIT_FAILURE │ Generic failure or │
3486 │ │ │ unspecified error. │
3487 └──────────┴───────────────┴────────────────────┘
3488
3489 The following service exit codes are defined by the LSB
3490 specification[16].
3491
3492 Table 8. LSB service exit codes
3493 ┌──────────┬──────────────────────┬────────────────────┐
3494 │Exit Code │ Symbolic Name │ Description │
3495 ├──────────┼──────────────────────┼────────────────────┤
3496 │2 │ EXIT_INVALIDARGUMENT │ Invalid or excess │
3497 │ │ │ arguments. │
3498 ├──────────┼──────────────────────┼────────────────────┤
3499 │3 │ EXIT_NOTIMPLEMENTED │ Unimplemented │
3500 │ │ │ feature. │
3501 ├──────────┼──────────────────────┼────────────────────┤
3502 │4 │ EXIT_NOPERMISSION │ The user has │
3503 │ │ │ insufficient │
3504 │ │ │ privileges. │
3505 ├──────────┼──────────────────────┼────────────────────┤
3506 │5 │ EXIT_NOTINSTALLED │ The program is not │
3507 │ │ │ installed. │
3508 ├──────────┼──────────────────────┼────────────────────┤
3509 │6 │ EXIT_NOTCONFIGURED │ The program is not │
3510 │ │ │ configured. │
3511 ├──────────┼──────────────────────┼────────────────────┤
3512 │7 │ EXIT_NOTRUNNING │ The program is not │
3513 │ │ │ running. │
3514 └──────────┴──────────────────────┴────────────────────┘
3515
3516 The LSB specification suggests that error codes 200 and above are
3517 reserved for implementations. Some of them are used by the service
3518 manager to indicate problems during process invocation:
3519
3520 Table 9. systemd-specific exit codes
3521 ┌──────────┬──────────────────────────────┬─────────────────────────────────────────────┐
3522 │Exit Code │ Symbolic Name │ Description │
3523 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3524 │200 │ EXIT_CHDIR │ Changing to the │
3525 │ │ │ requested working │
3526 │ │ │ directory failed. │
3527 │ │ │ See │
3528 │ │ │ WorkingDirectory= │
3529 │ │ │ above. │
3530 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3531 │201 │ EXIT_NICE │ Failed to set up │
3532 │ │ │ process scheduling │
3533 │ │ │ priority (nice │
3534 │ │ │ level). See Nice= │
3535 │ │ │ above. │
3536 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3537 │202 │ EXIT_FDS │ Failed to close │
3538 │ │ │ unwanted file │
3539 │ │ │ descriptors, or to │
3540 │ │ │ adjust passed file │
3541 │ │ │ descriptors. │
3542 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3543 │203 │ EXIT_EXEC │ The actual process │
3544 │ │ │ execution failed │
3545 │ │ │ (specifically, the │
3546 │ │ │ execve(2) system │
3547 │ │ │ call). Most likely │
3548 │ │ │ this is caused by a │
3549 │ │ │ missing or │
3550 │ │ │ non-accessible │
3551 │ │ │ executable file. │
3552 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3553 │204 │ EXIT_MEMORY │ Failed to perform │
3554 │ │ │ an action due to │
3555 │ │ │ memory shortage. │
3556 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3557 │205 │ EXIT_LIMITS │ Failed to adjust │
3558 │ │ │ resource limits. │
3559 │ │ │ See LimitCPU= and │
3560 │ │ │ related settings │
3561 │ │ │ above. │
3562 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3563 │206 │ EXIT_OOM_ADJUST │ Failed to adjust │
3564 │ │ │ the OOM setting. │
3565 │ │ │ See OOMScoreAdjust= │
3566 │ │ │ above. │
3567 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3568 │207 │ EXIT_SIGNAL_MASK │ Failed to set │
3569 │ │ │ process signal │
3570 │ │ │ mask. │
3571 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3572 │208 │ EXIT_STDIN │ Failed to set up │
3573 │ │ │ standard input. See │
3574 │ │ │ StandardInput= │
3575 │ │ │ above. │
3576 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3577 │209 │ EXIT_STDOUT │ Failed to set up │
3578 │ │ │ standard output. │
3579 │ │ │ See StandardOutput= │
3580 │ │ │ above. │
3581 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3582 │210 │ EXIT_CHROOT │ Failed to change │
3583 │ │ │ root directory │
3584 │ │ │ (chroot(2)). See │
3585 │ │ │ RootDirectory=/RootImage= │
3586 │ │ │ above. │
3587 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3588 │211 │ EXIT_IOPRIO │ Failed to set up IO │
3589 │ │ │ scheduling priority. See │
3590 │ │ │ IOSchedulingClass=/IOSchedulingPriority= │
3591 │ │ │ above. │
3592 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3593 │212 │ EXIT_TIMERSLACK │ Failed to set up timer slack. See │
3594 │ │ │ TimerSlackNSec= above. │
3595 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3596 │213 │ EXIT_SECUREBITS │ Failed to set process secure bits. See │
3597 │ │ │ SecureBits= above. │
3598 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3599 │214 │ EXIT_SETSCHEDULER │ Failed to set up CPU scheduling. See │
3600 │ │ │ CPUSchedulingPolicy=/CPUSchedulingPriority= │
3601 │ │ │ above. │
3602 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3603 │215 │ EXIT_CPUAFFINITY │ Failed to set up CPU affinity. See │
3604 │ │ │ CPUAffinity= above. │
3605 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3606 │216 │ EXIT_GROUP │ Failed to determine or change group │
3607 │ │ │ credentials. See │
3608 │ │ │ Group=/SupplementaryGroups= above. │
3609 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3610 │217 │ EXIT_USER │ Failed to determine or change user │
3611 │ │ │ credentials, or to set up user namespacing. │
3612 │ │ │ See User=/PrivateUsers= above. │
3613 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3614 │218 │ EXIT_CAPABILITIES │ Failed to drop capabilities, or apply │
3615 │ │ │ ambient capabilities. See │
3616 │ │ │ CapabilityBoundingSet=/AmbientCapabilities= │
3617 │ │ │ above. │
3618 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3619 │219 │ EXIT_CGROUP │ Setting up the service control group │
3620 │ │ │ failed. │
3621 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3622 │220 │ EXIT_SETSID │ Failed to create new process session. │
3623 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3624 │221 │ EXIT_CONFIRM │ Execution has been cancelled by the user. │
3625 │ │ │ See the systemd.confirm_spawn= kernel │
3626 │ │ │ command line setting on kernel-command- │
3627 │ │ │ line(7) for details. │
3628 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3629 │222 │ EXIT_STDERR │ Failed to set up standard error output. See │
3630 │ │ │ StandardError= above. │
3631 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3632 │224 │ EXIT_PAM │ Failed to set up PAM session. See PAMName= │
3633 │ │ │ above. │
3634 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3635 │225 │ EXIT_NETWORK │ Failed to set up network namespacing. See │
3636 │ │ │ PrivateNetwork= above. │
3637 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3638 │226 │ EXIT_NAMESPACE │ Failed to set up mount, UTS, or IPC │
3639 │ │ │ namespacing. See ReadOnlyPaths=, │
3640 │ │ │ ProtectHostname=, PrivateIPC=, and related │
3641 │ │ │ settings above. │
3642 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3643 │227 │ EXIT_NO_NEW_PRIVILEGES │ Failed to disable new privileges. See │
3644 │ │ │ NoNewPrivileges=yes above. │
3645 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3646 │228 │ EXIT_SECCOMP │ Failed to apply system call filters. See │
3647 │ │ │ SystemCallFilter= and related settings │
3648 │ │ │ above. │
3649 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3650 │229 │ EXIT_SELINUX_CONTEXT │ Determining or changing SELinux context │
3651 │ │ │ failed. See SELinuxContext= above. │
3652 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3653 │230 │ EXIT_PERSONALITY │ Failed to set up an execution domain │
3654 │ │ │ (personality). See Personality= above. │
3655 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3656 │231 │ EXIT_APPARMOR_PROFILE │ Failed to prepare changing AppArmor │
3657 │ │ │ profile. See AppArmorProfile= above. │
3658 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3659 │232 │ EXIT_ADDRESS_FAMILIES │ Failed to restrict address families. See │
3660 │ │ │ RestrictAddressFamilies= above. │
3661 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3662 │233 │ EXIT_RUNTIME_DIRECTORY │ Setting up runtime directory failed. See │
3663 │ │ │ RuntimeDirectory= and related settings │
3664 │ │ │ above. │
3665 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3666 │235 │ EXIT_CHOWN │ Failed to adjust socket ownership. Used for │
3667 │ │ │ socket units only. │
3668 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3669 │236 │ EXIT_SMACK_PROCESS_LABEL │ Failed to set SMACK label. See │
3670 │ │ │ SmackProcessLabel= above. │
3671 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3672 │237 │ EXIT_KEYRING │ Failed to set up kernel keyring. │
3673 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3674 │238 │ EXIT_STATE_DIRECTORY │ Failed to set up unit's state directory. │
3675 │ │ │ See StateDirectory= above. │
3676 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3677 │239 │ EXIT_CACHE_DIRECTORY │ Failed to set up unit's cache directory. │
3678 │ │ │ See CacheDirectory= above. │
3679 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3680 │240 │ EXIT_LOGS_DIRECTORY │ Failed to set up unit's logging directory. │
3681 │ │ │ See LogsDirectory= above. │
3682 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3683 │241 │ EXIT_CONFIGURATION_DIRECTORY │ Failed to set up unit's configuration │
3684 │ │ │ directory. See ConfigurationDirectory= │
3685 │ │ │ above. │
3686 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3687 │242 │ EXIT_NUMA_POLICY │ Failed to set up unit's NUMA memory policy. │
3688 │ │ │ See NUMAPolicy= and NUMAMask= above. │
3689 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3690 │243 │ EXIT_CREDENTIALS │ Failed to set up unit's credentials. See │
3691 │ │ │ LoadCredential= and SetCredential= above. │
3692 ├──────────┼──────────────────────────────┼─────────────────────────────────────────────┤
3693 │245 │ EXIT_BPF │ Failed to apply BPF restrictions. See │
3694 │ │ │ RestrictFileSystems= above. │
3695 └──────────┴──────────────────────────────┴─────────────────────────────────────────────┘
3696
3697 Finally, the BSD operating systems define a set of exit codes,
3698 typically defined on Linux systems too:
3699
3700 Table 10. BSD exit codes
3701 ┌──────────┬────────────────┬─────────────────────┐
3702 │Exit Code │ Symbolic Name │ Description │
3703 ├──────────┼────────────────┼─────────────────────┤
3704 │64 │ EX_USAGE │ Command line usage │
3705 │ │ │ error │
3706 ├──────────┼────────────────┼─────────────────────┤
3707 │65 │ EX_DATAERR │ Data format error │
3708 ├──────────┼────────────────┼─────────────────────┤
3709 │66 │ EX_NOINPUT │ Cannot open input │
3710 ├──────────┼────────────────┼─────────────────────┤
3711 │67 │ EX_NOUSER │ Addressee unknown │
3712 ├──────────┼────────────────┼─────────────────────┤
3713 │68 │ EX_NOHOST │ Host name unknown │
3714 ├──────────┼────────────────┼─────────────────────┤
3715 │69 │ EX_UNAVAILABLE │ Service unavailable │
3716 ├──────────┼────────────────┼─────────────────────┤
3717 │70 │ EX_SOFTWARE │ internal software │
3718 │ │ │ error │
3719 ├──────────┼────────────────┼─────────────────────┤
3720 │71 │ EX_OSERR │ System error (e.g., │
3721 │ │ │ can't fork) │
3722 ├──────────┼────────────────┼─────────────────────┤
3723 │72 │ EX_OSFILE │ Critical OS file │
3724 │ │ │ missing │
3725 ├──────────┼────────────────┼─────────────────────┤
3726 │73 │ EX_CANTCREAT │ Can't create (user) │
3727 │ │ │ output file │
3728 ├──────────┼────────────────┼─────────────────────┤
3729 │74 │ EX_IOERR │ Input/output error │
3730 ├──────────┼────────────────┼─────────────────────┤
3731 │75 │ EX_TEMPFAIL │ Temporary failure; │
3732 │ │ │ user is invited to │
3733 │ │ │ retry │
3734 ├──────────┼────────────────┼─────────────────────┤
3735 │76 │ EX_PROTOCOL │ Remote error in │
3736 │ │ │ protocol │
3737 ├──────────┼────────────────┼─────────────────────┤
3738 │77 │ EX_NOPERM │ Permission denied │
3739 ├──────────┼────────────────┼─────────────────────┤
3740 │78 │ EX_CONFIG │ Configuration error │
3741 └──────────┴────────────────┴─────────────────────┘
3742
3744 Example 3. $MONITOR_* usage
3745
3746 A service myfailer.service which can trigger an OnFailure= dependency.
3747
3748 [Unit]
3749 Description=Service which can trigger an OnFailure= dependency
3750 OnFailure=myhandler.service
3751
3752 [Service]
3753 ExecStart=/bin/myprogram
3754
3755
3756 A service mysuccess.service which can trigger an OnSuccess= dependency.
3757
3758 [Unit]
3759 Description=Service which can trigger an OnSuccess= dependency
3760 OnSuccess=myhandler.service
3761
3762 [Service]
3763 ExecStart=/bin/mysecondprogram
3764
3765
3766 A service myhandler.service which can be triggered by any of the above
3767 services.
3768
3769 [Unit]
3770 Description=Acts on service failing or succeeding
3771
3772 [Service]
3773 ExecStart=/bin/bash -c "echo $MONITOR_SERVICE_RESULT $MONITOR_EXIT_CODE $MONITOR_EXIT_STATUS $MONITOR_INVOCATION_ID $MONITOR_UNIT"
3774
3775
3776 If myfailer.service were to run and exit in failure, then
3777 myhandler.service would be triggered and the monitor variables would be
3778 set as follows:
3779
3780 MONITOR_SERVICE_RESULT=exit-code
3781 MONITOR_EXIT_CODE=exited
3782 MONITOR_EXIT_STATUS=1
3783 MONITOR_INVOCATION_ID=cc8fdc149b2b4ca698d4f259f4054236
3784 MONITOR_UNIT=myfailer.service
3785
3786
3787 If mysuccess.service were to run and exit in success, then
3788 myhandler.service would be triggered and the monitor variables would be
3789 set as follows:
3790
3791 MONITOR_SERVICE_RESULT=success
3792 MONITOR_EXIT_CODE=exited
3793 MONITOR_EXIT_STATUS=0
3794 MONITOR_INVOCATION_ID=6ab9af147b8c4a3ebe36e7a5f8611697
3795 MONITOR_UNIT=mysuccess.service
3796
3797
3799 systemd(1), systemctl(1), systemd-analyze(1), journalctl(1), systemd-
3800 system.conf(5), systemd.unit(5), systemd.service(5), systemd.socket(5),
3801 systemd.swap(5), systemd.mount(5), systemd.kill(5), systemd.resource-
3802 control(5), systemd.time(7), systemd.directives(7), tmpfiles.d(5),
3803 exec(3), fork(2)
3804
3806 1. Discoverable Partitions Specification
3807 https://systemd.io/DISCOVERABLE_PARTITIONS
3808
3809 2. The /proc Filesystem
3810 https://www.kernel.org/doc/html/latest/filesystems/proc.html#mount-options
3811
3812 3. User/Group Name Syntax
3813 https://systemd.io/USER_NAMES
3814
3815 4. No New Privileges Flag
3816 https://www.kernel.org/doc/html/latest/userspace-api/no_new_privs.html
3817
3818 5. JSON User Record
3819 https://systemd.io/USER_RECORD
3820
3821 6. proc.txt
3822 https://www.kernel.org/doc/Documentation/filesystems/proc.txt
3823
3824 7. unicode scalar values
3825 https://www.unicode.org/glossary/#unicode_scalar_value
3826
3827 8. noncharacters
3828 https://www.unicode.org/glossary/#noncharacter
3829
3830 9. byte order mark
3831 https://www.unicode.org/glossary/#byte_order_mark
3832
3833 10. unquoted text
3834 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_01
3835
3836 11. single-quoted text
3837 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_02
3838
3839 12. double-quoted text
3840 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03
3841
3842 13. Base64
3843 https://tools.ietf.org/html/rfc2045#section-6.8
3844
3845 14. Container Interface
3846 https://systemd.io/CONTAINER_INTERFACE
3847
3848 15. System and Service Credentials
3849 https://systemd.io/CREDENTIALS
3850
3851 16. LSB specification
3852 https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
3853
3854
3855
3856systemd 251 SYSTEMD.EXEC(5)