1TMPFILES.D(5) tmpfiles.d TMPFILES.D(5)
2
3
4
6 tmpfiles.d - Configuration for creation, deletion and cleaning of
7 volatile and temporary files
8
10 /etc/tmpfiles.d/*.conf
11 /run/tmpfiles.d/*.conf
12 /usr/lib/tmpfiles.d/*.conf
13
14
15 ~/.config/user-tmpfiles.d/*.conf
16 $XDG_RUNTIME_DIR/user-tmpfiles.d/*.conf
17 ~/.local/share/user-tmpfiles.d/*.conf
18 ...
19 /usr/share/user-tmpfiles.d/*.conf
20
21
22
23 #Type Path Mode User Group Age Argument
24 f /file/to/create mode user group - content
25 f+ /file/to/create-or-truncate mode user group - content
26 w /file/to/write-to - - - - content
27 w+ /file/to/append-to - - - - content
28 d /directory/to/create-and-cleanup mode user group cleanup-age -
29 D /directory/to/create-and-remove mode user group cleanup-age -
30 e /directory/to/cleanup mode user group cleanup-age -
31 v /subvolume-or-directory/to/create mode user group - -
32 q /subvolume-or-directory/to/create mode user group - -
33 Q /subvolume-or-directory/to/create mode user group - -
34 p /fifo/to/create mode user group - -
35 p+ /fifo/to/[re]create mode user group - -
36 L /symlink/to/create - - - - symlink/target/path
37 L+ /symlink/to/[re]create - - - - symlink/target/path
38 c /dev/char-device-to-create mode user group - major:minor
39 c+ /dev/char-device-to-[re]create mode user group - major:minor
40 b /dev/block-device-to-create mode user group - major:minor
41 b+ /dev/block-device-to-[re]create mode user group - major:minor
42 C /target/to/create - - - - /source/to/copy
43 x /path-or-glob/to/ignore/recursively - - - - -
44 X /path-or-glob/to/ignore - - - - -
45 r /empty/dir/to/remove - - - - -
46 R /dir/to/remove/recursively - - - - -
47 z /path-or-glob/to/adjust/mode mode user group - -
48 Z /path-or-glob/to/adjust/mode/recursively mode user group - -
49 t /path-or-glob/to/set/xattrs - - - - xattrs
50 T /path-or-glob/to/set/xattrs/recursively - - - - xattrs
51 h /path-or-glob/to/set/attrs - - - - file attrs
52 H /path-or-glob/to/set/attrs/recursively - - - - file attrs
53 a /path-or-glob/to/set/acls - - - - POSIX ACLs
54 a+ /path-or-glob/to/append/acls - - - - POSIX ACLs
55 A /path-or-glob/to/set/acls/recursively - - - - POSIX ACLs
56 A+ /path-or-glob/to/append/acls/recursively - - - - POSIX ACLs
57
58
60 tmpfiles.d configuration files provide a generic mechanism to define
61 the creation of regular files, directories, pipes, and device nodes,
62 adjustments to their access mode, ownership, attributes, quota
63 assignments, and contents, and finally their time-based removal. It is
64 mostly commonly used for volatile and temporary files and directories
65 (such as those located under /run/, /tmp/, /var/tmp/, the API file
66 systems such as /sys/ or /proc/, as well as some other directories
67 below /var/).
68
69 systemd-tmpfiles uses this configuration to create volatile files and
70 directories during boot and to do periodic cleanup afterwards. See
71 systemd-tmpfiles(5) for the description of
72 systemd-tmpfiles-setup.service, systemd-tmpfiles-clean.service, and
73 associated units.
74
75 System daemons frequently require private runtime directories below
76 /run/ to store communication sockets and similar. For these, it is
77 better to use RuntimeDirectory= in their unit files (see
78 systemd.exec(5) for details), if the flexibility provided by tmpfiles.d
79 is not required. The advantages are that the configuration required by
80 the unit is centralized in one place, and that the lifetime of the
81 directory is tied to the lifetime of the service itself. Similarly,
82 StateDirectory=, CacheDirectory=, LogsDirectory=, and
83 ConfigurationDirectory= should be used to create directories under
84 /var/lib/, /var/cache/, /var/log/, and /etc/. tmpfiles.d should be
85 used for files whose lifetime is independent of any service or requires
86 more complicated configuration.
87
89 Each configuration file shall be named in the style of package.conf or
90 package-part.conf. The second variant should be used when it is
91 desirable to make it easy to override just this part of configuration.
92
93 Files in /etc/tmpfiles.d override files with the same name in
94 /usr/lib/tmpfiles.d and /run/tmpfiles.d. Files in /run/tmpfiles.d
95 override files with the same name in /usr/lib/tmpfiles.d. Packages
96 should install their configuration files in /usr/lib/tmpfiles.d. Files
97 in /etc/tmpfiles.d are reserved for the local administrator, who may
98 use this logic to override the configuration files installed by vendor
99 packages. All configuration files are sorted by their filename in
100 lexicographic order, regardless of which of the directories they reside
101 in. If multiple files specify the same path, the entry in the file with
102 the lexicographically earliest name will be applied (note that lines
103 suppressed due to the "!" are filtered before application, meaning
104 that if an early line carries the exclamation mark and is suppressed
105 because of that, a later line matching in path will be applied). All
106 other conflicting entries will be logged as errors. When two lines are
107 prefix path and suffix path of each other, then the prefix line is
108 always created first, the suffix later (and if removal applies to the
109 line, the order is reversed: the suffix is removed first, the prefix
110 later). Lines that take globs are applied after those accepting no
111 globs. If multiple operations shall be applied on the same file (such
112 as ACL, xattr, file attribute adjustments), these are always done in
113 the same fixed order. Except for those cases, the files/directories are
114 processed in the order they are listed.
115
116 If the administrator wants to disable a configuration file supplied by
117 the vendor, the recommended way is to place a symlink to /dev/null in
118 /etc/tmpfiles.d/ bearing the same filename.
119
121 The configuration format is one line per path, containing type, path,
122 mode, ownership, age, and argument fields. The lines are separated by
123 newlines, the fields by whitespace:
124
125 #Type Path Mode User Group Age Argument...
126 d /run/user 0755 root root 10d -
127 L /tmp/foobar - - - - /dev/null
128
129 Fields may contain C-style escapes. With the exception of the seventh
130 field (the "argument") all fields may be enclosed in quotes. Note that
131 any whitespace found in the line after the beginning of the argument
132 field will be considered part of the argument field. To begin the
133 argument field with a whitespace character, use C-style escapes (e.g.
134 "\x20").
135
136 Type
137 The type consists of a single letter and optionally an exclamation mark
138 ("!") minus sign ("-"), and/or equals sign ("=").
139
140 The following line types are understood:
141
142 f, f+
143 f will create a file if it does not exist yet. If the argument
144 parameter is given and the file did not exist yet, it will be
145 written to the file. f+ will create or truncate the file. If the
146 argument parameter is given, it will be written to the file. Does
147 not follow symlinks.
148
149 w, w+
150 Write the argument parameter to a file, if the file exists. If
151 suffixed with +, the line will be appended to the file. If your
152 configuration writes multiple lines to the same file, use w+. Lines
153 of this type accept shell-style globs in place of normal path
154 names. The argument parameter will be written without a trailing
155 newline. C-style backslash escapes are interpreted. Follows
156 symlinks.
157
158 d
159 Create a directory. The mode and ownership will be adjusted if
160 specified. Contents of this directory are subject to time based
161 cleanup if the age argument is specified.
162
163 D
164 Similar to d, but in addition the contents of the directory will be
165 removed when --remove is used.
166
167 e
168 Adjust the mode and ownership of existing directories and remove
169 their contents based on age. Lines of this type accept shell-style
170 globs in place of normal path names. Contents of the directories
171 are subject to time based cleanup if the age argument is specified.
172 If the age argument is "0", contents will be unconditionally
173 deleted every time systemd-tmpfiles --clean is run.
174
175 For this entry to be useful, at least one of the mode, user, group,
176 or age arguments must be specified, since otherwise this entry has
177 no effect. As an exception, an entry with no effect may be useful
178 when combined with !, see the examples.
179
180 v
181 Create a subvolume if the path does not exist yet, the file system
182 supports subvolumes (btrfs), and the system itself is installed
183 into a subvolume (specifically: the root directory / is itself a
184 subvolume). Otherwise, create a normal directory, in the same way
185 as d.
186
187 A subvolume created with this line type is not assigned to any
188 higher-level quota group. For that, use q or Q, which allow
189 creating simple quota group hierarchies, see below.
190
191 q
192 Create a subvolume or directory the same as v, but assign the
193 subvolume to the same higher-level quota groups as the parent. This
194 ensures that higher-level limits and accounting applied to the
195 parent subvolume also include the specified subvolume. On non-btrfs
196 file systems, this line type is identical to d.
197
198 If the subvolume already exists, no change to the quota hierarchy
199 is made, regardless of whether the subvolume is already attached to
200 a quota group or not. Also see Q below. See btrfs-qgroup(8) for
201 details about the btrfs quota group concept.
202
203 Q
204 Create the subvolume or directory the same as v, but assign the new
205 subvolume to a new leaf quota group. Instead of copying the
206 higher-level quota group assignments from the parent as is done
207 with q, the lowest quota group of the parent subvolume is
208 determined that is not the leaf quota group. Then, an
209 "intermediary" quota group is inserted that is one level below this
210 level, and shares the same ID part as the specified subvolume. If
211 no higher-level quota group exists for the parent subvolume, a new
212 quota group at level 255 sharing the same ID as the specified
213 subvolume is inserted instead. This new intermediary quota group is
214 then assigned to the parent subvolume's higher-level quota groups,
215 and the specified subvolume's leaf quota group is assigned to it.
216
217 Effectively, this has a similar effect as q, however introduces a
218 new higher-level quota group for the specified subvolume that may
219 be used to enforce limits and accounting to the specified subvolume
220 and children subvolume created within it. Thus, by creating
221 subvolumes only via q and Q, a concept of "subtree quotas" is
222 implemented. Each subvolume for which Q is set will get a "subtree"
223 quota group created, and all child subvolumes created within it
224 will be assigned to it. Each subvolume for which q is set will not
225 get such a "subtree" quota group, but it is ensured that they are
226 added to the same "subtree" quota group as their immediate parents.
227
228 It is recommended to use Q for subvolumes that typically contain
229 further subvolumes, and where it is desirable to have accounting
230 and quota limits on all child subvolumes together. Examples for Q
231 are typically /home/ or /var/lib/machines/. In contrast, q should
232 be used for subvolumes that either usually do not include further
233 subvolumes or where no accounting and quota limits are needed that
234 apply to all child subvolumes together. Examples for q are
235 typically /var/ or /var/tmp/.
236
237 As with q, Q has no effect on the quota group hierarchy if the
238 subvolume already exists, regardless of whether the subvolume
239 already belong to a quota group or not.
240
241 p, p+
242 Create a named pipe (FIFO) if it does not exist yet. If suffixed
243 with + and a file already exists where the pipe is to be created,
244 it will be removed and be replaced by the pipe.
245
246 L, L+
247 Create a symlink if it does not exist yet. If suffixed with + and a
248 file or directory already exists where the symlink is to be
249 created, it will be removed and be replaced by the symlink. If the
250 argument is omitted, symlinks to files with the same name residing
251 in the directory /usr/share/factory/ are created. Note that
252 permissions and ownership on symlinks are ignored.
253
254 c, c+
255 Create a character device node if it does not exist yet. If
256 suffixed with + and a file already exists where the device node is
257 to be created, it will be removed and be replaced by the device
258 node. It is recommended to suffix this entry with an exclamation
259 mark to only create static device nodes at boot, as udev will not
260 manage static device nodes that are created at runtime.
261
262 b, b+
263 Create a block device node if it does not exist yet. If suffixed
264 with + and a file already exists where the device node is to be
265 created, it will be removed and be replaced by the device node. It
266 is recommended to suffix this entry with an exclamation mark to
267 only create static device nodes at boot, as udev will not manage
268 static device nodes that are created at runtime.
269
270 C
271 Recursively copy a file or directory, if the destination files or
272 directories do not exist yet or the destination directory is empty.
273 Note that this command will not descend into subdirectories if the
274 destination directory already exists and is not empty. Instead, the
275 entire copy operation is skipped. If the argument is omitted, files
276 from the source directory /usr/share/factory/ with the same name
277 are copied. Does not follow symlinks.
278
279 x
280 Ignore a path during cleaning. Use this type to exclude paths from
281 clean-up as controlled with the Age parameter. Note that lines of
282 this type do not influence the effect of r or R lines. Lines of
283 this type accept shell-style globs in place of normal path names.
284
285 X
286 Ignore a path during cleaning. Use this type to exclude paths from
287 clean-up as controlled with the Age parameter. Unlike x, this
288 parameter will not exclude the content if path is a directory, but
289 only directory itself. Note that lines of this type do not
290 influence the effect of r or R lines. Lines of this type accept
291 shell-style globs in place of normal path names.
292
293 r
294 Remove a file or directory if it exists. This may not be used to
295 remove non-empty directories, use R for that. Lines of this type
296 accept shell-style globs in place of normal path names. Does not
297 follow symlinks.
298
299 R
300 Recursively remove a path and all its subdirectories (if it is a
301 directory). Lines of this type accept shell-style globs in place of
302 normal path names. Does not follow symlinks.
303
304 z
305 Adjust the access mode, user and group ownership, and restore the
306 SELinux security context of a file or directory, if it exists.
307 Lines of this type accept shell-style globs in place of normal path
308 names. Does not follow symlinks.
309
310 Z
311 Recursively set the access mode, user and group ownership, and
312 restore the SELinux security context of a file or directory if it
313 exists, as well as of its subdirectories and the files contained
314 therein (if applicable). Lines of this type accept shell-style
315 globs in place of normal path names. Does not follow symlinks.
316
317 t
318 Set extended attributes, see attr(5) for details. The argument
319 field should take one or more assignment expressions in the form
320 namespace.attribute=value, for examples see below. Lines of this
321 type accept shell-style globs in place of normal path names. This
322 can be useful for setting SMACK labels. Does not follow symlinks.
323
324 Please note that extended attributes settable with this line type
325 are a different concept from the Linux file attributes settable
326 with h/H, see below.
327
328 T
329 Same as t, but operates recursively.
330
331 h
332 Set Linux file/directory attributes. Lines of this type accept
333 shell-style globs in place of normal path names.
334
335 The format of the argument field is [+-=][aAcCdDeijPsStTu]. The
336 prefix + (the default one) causes the attribute(s) to be added; -
337 causes the attribute(s) to be removed; = causes the attributes to
338 be set exactly as the following letters. The letters
339 "aAcCdDeijPsStTu" select the new attributes for the files, see
340 chattr(1) for further information.
341
342 Passing only = as argument resets all the file attributes listed
343 above. It has to be pointed out that the = prefix limits itself to
344 the attributes corresponding to the letters listed here. All other
345 attributes will be left untouched. Does not follow symlinks.
346
347 Please note that the Linux file attributes settable with this line
348 type are a different concept from the extended attributes settable
349 with t/T, see above.
350
351 H
352 Sames as h, but operates recursively.
353
354 a, a+
355 Set POSIX ACLs (access control lists), see acl(5). If suffixed with
356 +, the specified entries will be added to the existing set.
357 systemd-tmpfiles will automatically add the required base entries
358 for user and group based on the access mode of the file, unless
359 base entries already exist or are explicitly specified. The mask
360 will be added if not specified explicitly or already present. Lines
361 of this type accept shell-style globs in place of normal path
362 names. This can be useful for allowing additional access to certain
363 files. Does not follow symlinks.
364
365 A, A+
366 Same as a and a+, but recursive. Does not follow symlinks.
367
368 If the exclamation mark ("!") is used, this line is only safe to
369 execute during boot, and can break a running system. Lines without the
370 exclamation mark are presumed to be safe to execute at any time, e.g.
371 on package upgrades. systemd-tmpfiles will take lines with an
372 exclamation mark only into consideration, if the --boot option is
373 given.
374
375 For example:
376
377 # Make sure these are created by default so that nobody else can
378 d /tmp/.X11-unix 1777 root root 10d
379
380 # Unlink the X11 lock files
381 r! /tmp/.X[0-9]*-lock
382
383 The second line in contrast to the first one would break a running
384 system, and will only be executed with --boot.
385
386 If the minus sign ("-") is used, this line failing to run successfully
387 during create (and only create) will not cause the execution of
388 systemd-tmpfiles to return an error.
389
390 For example:
391
392 # Modify sysfs but don't fail if we are in a container with a read-only /proc
393 w- /proc/sys/vm/swappiness - - - - 10
394
395 If the equals sign ("=") is used, the file types of existing objects in
396 the specified path are checked, and removed if they do not match. This
397 includes any implicitly created parent directories (which can be either
398 directories or directory symlinks). For example, if there is a FIFO in
399 place of one of the parent path components it will be replaced with a
400 directory.
401
402 Note that for all line types that result in creation of any kind of
403 file node (i.e. f/F, d/D/v/q/Q, p, L, c/b and C) leading directories
404 are implicitly created if needed, owned by root with an access mode of
405 0755. In order to create them with different modes or ownership make
406 sure to add appropriate d lines.
407
408 Path
409 The file system path specification supports simple specifier expansion,
410 see below. The path (after expansion) must be absolute.
411
412 Mode
413 The file access mode to use when creating this file or directory. If
414 omitted or when set to "-", the default is used: 0755 for directories,
415 0644 for all other file objects. For z, Z lines, if omitted or when set
416 to "-", the file access mode will not be modified. This parameter is
417 ignored for x, r, R, L, t, and a lines.
418
419 Optionally, if prefixed with "~", the access mode is masked based on
420 the already set access bits for existing file or directories: if the
421 existing file has all executable bits unset, all executable bits are
422 removed from the new access mode, too. Similarly, if all read bits are
423 removed from the old access mode, they will be removed from the new
424 access mode too, and if all write bits are removed, they will be
425 removed from the new access mode too. In addition, the sticky/SUID/SGID
426 bit is removed unless applied to a directory. This functionality is
427 particularly useful in conjunction with Z.
428
429 User, Group
430 The user and group to use for this file or directory. This may either
431 be a numeric ID or a user/group name. If omitted or when set to "-",
432 the user and group of the user who invokes systemd-tmpfiles is used.
433 For z and Z lines, when omitted or when set to "-", the file ownership
434 will not be modified. These parameters are ignored for x, r, R, L, t,
435 and a lines.
436
437 This field should generally only reference system users/groups, i.e.
438 users/groups that are guaranteed to be resolvable during early boot. If
439 this field references users/groups that only become resolveable during
440 later boot (i.e. after NIS, LDAP or a similar networked directory
441 service become available), execution of the operations declared by the
442 line will likely fail. Also see Notes on Resolvability of User and
443 Group Names[1] for more information on requirements on system
444 user/group definitions.
445
446 Age
447 The date field, when set, is used to decide what files to delete when
448 cleaning. If a file or directory is older than the current time minus
449 the age field, it is deleted. The field format is a series of integers
450 each followed by one of the following suffixes for the respective time
451 units: s, m or min, h, d, w, ms, and us, meaning seconds, minutes,
452 hours, days, weeks, milliseconds, and microseconds, respectively. Full
453 names of the time units can be used too.
454
455 If multiple integers and units are specified, the time values are
456 summed. If an integer is given without a unit, s is assumed.
457
458 When the age is set to zero, the files are cleaned unconditionally.
459
460 The age field only applies to lines starting with d, D, e, v, q, Q, C,
461 x and X. If omitted or set to "-", no automatic clean-up is done.
462
463 If the age field starts with a tilde character "~", clean-up is only
464 applied to files and directories one level inside the directory
465 specified, but not the files and directories immediately inside it.
466
467 The age of a file system entry is determined from its last modification
468 timestamp (mtime), its last access timestamp (atime), and (except for
469 directories) its last status change timestamp (ctime). By default, any
470 of these three (or two) values will prevent cleanup if it is more
471 recent than the current time minus the age field. To restrict the
472 deletion based on particular type of file timestamps, the age-by
473 argument can be used.
474
475 The age-by argument overrides the timestamp types to be used for the
476 age check. It can be specified by prefixing the age argument with a
477 sequence of characters to specify the timestamp types and a colon
478 (":"): "age-by...:cleanup-age". The argument can consist of a (A for
479 directories), b (B for directories), c (C for directories), or m (M for
480 directories). Those respectively indicate access, creation, last status
481 change, and last modification time of a file system entry. The
482 lower-case letter signifies that the given timestamp type should be
483 considered for files, while the upper-case letter signifies that the
484 given timestamp type should be considered for directories. See statx(2)
485 file timestamp fields for more details about timestamp types.
486
487 If not specified, the age-by field defaults to abcmABM, i.e. by default
488 all file timestamps are taken into consideration, with the exception of
489 the last status change timestamp (ctime) for directories. This is
490 because the aging logic itself will alter the ctime whenever it deletes
491 a file inside it. To ensure that running the aging logic does not feed
492 back into the next iteration of itself, ctime for directories is
493 ignored by default.
494
495 For example:
496
497 # Files created and modified, and directories accessed more than
498 # an hour ago in "/tmp/foo/bar", are subject to time-based cleanup.
499 d /tmp/foo/bar - - - - bmA:1h -
500
501 Note that while the aging algorithm is run a 'shared' BSD file lock
502 (see flock(2)) is taken on each directory the algorithm descends into
503 (and each directory below that, and so on). If the aging algorithm
504 finds a lock is already taken on some directory, it (and everything
505 below it) is skipped. Applications may use this to temporarily exclude
506 certain directory subtrees from the aging algorithm: the applications
507 can take a BSD file lock themselves, and as long as they keep it aging
508 of the directory and everything below it is disabled.
509
510 Argument
511 For L lines determines the destination path of the symlink. For c and
512 b, determines the major/minor of the device node, with major and minor
513 formatted as integers, separated by ":", e.g. "1:3". For f, F, and w,
514 the argument may be used to specify a short string that is written to
515 the file, suffixed by a newline. For C, specifies the source file or
516 directory. For t and T, determines extended attributes to be set. For a
517 and A, determines ACL attributes to be set. For h and H, determines the
518 file attributes to set. Ignored for all other lines.
519
520 This field can contain specifiers, see below.
521
523 Specifiers can be used in the "path" and "argument" fields. An unknown
524 or unresolvable specifier is treated as invalid configuration. The
525 following expansions are understood:
526
527 Table 1. Specifiers available
528 ┌──────────┬─────────────────────┬────────────────────────┐
529 │Specifier │ Meaning │ Details │
530 ├──────────┼─────────────────────┼────────────────────────┤
531 │"%a" │ Architecture │ A short string │
532 │ │ │ identifying the │
533 │ │ │ architecture of the │
534 │ │ │ local system. A │
535 │ │ │ string such as x86, │
536 │ │ │ x86-64 or arm64. │
537 │ │ │ See the │
538 │ │ │ architectures │
539 │ │ │ defined for │
540 │ │ │ ConditionArchitecture= │
541 │ │ │ in systemd.unit(5) │
542 │ │ │ for a full list. │
543 ├──────────┼─────────────────────┼────────────────────────┤
544 │"%A" │ Operating system │ The operating system │
545 │ │ image version │ image version │
546 │ │ │ identifier of the │
547 │ │ │ running system, as │
548 │ │ │ read from the │
549 │ │ │ IMAGE_VERSION= field │
550 │ │ │ of /etc/os-release. If │
551 │ │ │ not set, resolves to │
552 │ │ │ an empty string. See │
553 │ │ │ os-release(5) for more │
554 │ │ │ information. │
555 ├──────────┼─────────────────────┼────────────────────────┤
556 │"%b" │ Boot ID │ The boot ID of the │
557 │ │ │ running system, │
558 │ │ │ formatted as string. │
559 │ │ │ See random(4) for more │
560 │ │ │ information. │
561 ├──────────┼─────────────────────┼────────────────────────┤
562 │"%B" │ Operating system │ The operating system │
563 │ │ build ID │ build identifier of │
564 │ │ │ the running system, as │
565 │ │ │ read from the │
566 │ │ │ BUILD_ID= field of │
567 │ │ │ /etc/os-release. If │
568 │ │ │ not set, resolves to │
569 │ │ │ an empty string. See │
570 │ │ │ os-release(5) for more │
571 │ │ │ information. │
572 ├──────────┼─────────────────────┼────────────────────────┤
573 │"%C" │ System or user │ In --user mode, this │
574 │ │ cache directory │ is the same as │
575 │ │ │ $XDG_CACHE_HOME, and │
576 │ │ │ /var/cache otherwise. │
577 ├──────────┼─────────────────────┼────────────────────────┤
578 │"%g" │ User group │ This is the name of │
579 │ │ │ the group running the │
580 │ │ │ command. In case of │
581 │ │ │ the system instance │
582 │ │ │ this resolves to │
583 │ │ │ "root". │
584 ├──────────┼─────────────────────┼────────────────────────┤
585 │"%G" │ User GID │ This is the numeric │
586 │ │ │ GID of the group │
587 │ │ │ running the command. │
588 │ │ │ In case of the system │
589 │ │ │ instance this resolves │
590 │ │ │ to 0. │
591 ├──────────┼─────────────────────┼────────────────────────┤
592 │"%h" │ User home directory │ This is the home │
593 │ │ │ directory of the user │
594 │ │ │ running the command. │
595 │ │ │ In case of the system │
596 │ │ │ instance this resolves │
597 │ │ │ to "/root". │
598 ├──────────┼─────────────────────┼────────────────────────┤
599 │"%H" │ Host name │ The hostname of the │
600 │ │ │ running system. │
601 ├──────────┼─────────────────────┼────────────────────────┤
602 │"%l" │ Short host name │ The hostname of the │
603 │ │ │ running system, │
604 │ │ │ truncated at the first │
605 │ │ │ dot to remove any │
606 │ │ │ domain component. │
607 ├──────────┼─────────────────────┼────────────────────────┤
608 │"%L" │ System or user log │ In --user mode, this │
609 │ │ directory │ is the same as │
610 │ │ │ $XDG_CONFIG_HOME with │
611 │ │ │ /log appended, and │
612 │ │ │ /var/log otherwise. │
613 ├──────────┼─────────────────────┼────────────────────────┤
614 │"%m" │ Machine ID │ The machine ID of the │
615 │ │ │ running system, │
616 │ │ │ formatted as string. │
617 │ │ │ See machine-id(5) for │
618 │ │ │ more information. │
619 ├──────────┼─────────────────────┼────────────────────────┤
620 │"%M" │ Operating system │ The operating system │
621 │ │ image identifier │ image identifier of │
622 │ │ │ the running system, as │
623 │ │ │ read from the │
624 │ │ │ IMAGE_ID= field of │
625 │ │ │ /etc/os-release. If │
626 │ │ │ not set, resolves to │
627 │ │ │ an empty string. See │
628 │ │ │ os-release(5) for more │
629 │ │ │ information. │
630 ├──────────┼─────────────────────┼────────────────────────┤
631 │"%o" │ Operating system ID │ The operating system │
632 │ │ │ identifier of the │
633 │ │ │ running system, as │
634 │ │ │ read from the ID= │
635 │ │ │ field of │
636 │ │ │ /etc/os-release. See │
637 │ │ │ os-release(5) for more │
638 │ │ │ information. │
639 ├──────────┼─────────────────────┼────────────────────────┤
640 │"%S" │ System or user │ In --user mode, this │
641 │ │ state directory │ is the same as │
642 │ │ │ $XDG_CONFIG_HOME, and │
643 │ │ │ /var/lib otherwise. │
644 ├──────────┼─────────────────────┼────────────────────────┤
645 │"%t" │ System or user │ In --user mode, this │
646 │ │ runtime directory │ is the same │
647 │ │ │ $XDG_RUNTIME_DIR, and │
648 │ │ │ /run/ otherwise. │
649 ├──────────┼─────────────────────┼────────────────────────┤
650 │"%T" │ Directory for │ This is either /tmp or │
651 │ │ temporary files │ the path "$TMPDIR", │
652 │ │ │ "$TEMP" or "$TMP" are │
653 │ │ │ set to. (Note that the │
654 │ │ │ directory may be │
655 │ │ │ specified without a │
656 │ │ │ trailing slash.) │
657 ├──────────┼─────────────────────┼────────────────────────┤
658 │"%u" │ User name │ This is the name of │
659 │ │ │ the user running the │
660 │ │ │ command. In case of │
661 │ │ │ the system instance │
662 │ │ │ this resolves to │
663 │ │ │ "root". │
664 ├──────────┼─────────────────────┼────────────────────────┤
665 │"%U" │ User UID │ This is the numeric │
666 │ │ │ UID of the user │
667 │ │ │ running the command. │
668 │ │ │ In case of the system │
669 │ │ │ instance this resolves │
670 │ │ │ to 0. │
671 ├──────────┼─────────────────────┼────────────────────────┤
672 │"%v" │ Kernel release │ Identical to uname -r │
673 │ │ │ output. │
674 ├──────────┼─────────────────────┼────────────────────────┤
675 │"%V" │ Directory for │ This is either │
676 │ │ larger and │ /var/tmp or the path │
677 │ │ persistent │ "$TMPDIR", "$TEMP" or │
678 │ │ temporary files │ "$TMP" are set to. │
679 │ │ │ (Note that the │
680 │ │ │ directory may be │
681 │ │ │ specified without a │
682 │ │ │ trailing slash.) │
683 ├──────────┼─────────────────────┼────────────────────────┤
684 │"%w" │ Operating system │ The operating system │
685 │ │ version ID │ version identifier of │
686 │ │ │ the running system, as │
687 │ │ │ read from the │
688 │ │ │ VERSION_ID= field of │
689 │ │ │ /etc/os-release. If │
690 │ │ │ not set, resolves to │
691 │ │ │ an empty string. See │
692 │ │ │ os-release(5) for more │
693 │ │ │ information. │
694 ├──────────┼─────────────────────┼────────────────────────┤
695 │"%W" │ Operating system │ The operating system │
696 │ │ variant ID │ variant identifier of │
697 │ │ │ the running system, as │
698 │ │ │ read from the │
699 │ │ │ VARIANT_ID= field of │
700 │ │ │ /etc/os-release. If │
701 │ │ │ not set, resolves to │
702 │ │ │ an empty string. See │
703 │ │ │ os-release(5) for more │
704 │ │ │ information. │
705 ├──────────┼─────────────────────┼────────────────────────┤
706 │"%%" │ Single percent sign │ Use "%%" in place of │
707 │ │ │ "%" to specify a │
708 │ │ │ single percent sign. │
709 └──────────┴─────────────────────┴────────────────────────┘
710
712 Example 1. Create directories with specific mode and ownership
713
714 screen(1), needs two directories created at boot with specific modes
715 and ownership:
716
717 # /usr/lib/tmpfiles.d/screen.conf
718 d /run/screens 1777 root screen 10d
719 d /run/uscreens 0755 root screen 10d12h
720
721 Contents of /run/screens and /run/uscreens will be cleaned up after 10
722 and 10½ days, respectively.
723
724 Example 2. Create a directory with a SMACK attribute
725
726 D /run/cups - - - -
727 t /run/cups - - - - security.SMACK64=printing user.attr-with-spaces="foo bar"
728
729
730 The directory will be owned by root and have default mode. Its contents
731 are not subject to time based cleanup, but will be obliterated when
732 systemd-tmpfiles --remove runs.
733
734 Example 3. Create a directory and prevent its contents from cleanup
735
736 abrt(1), needs a directory created at boot with specific mode and
737 ownership and its content should be preserved from the automatic
738 cleanup applied to the contents of /var/tmp:
739
740 # /usr/lib/tmpfiles.d/tmp.conf
741 d /var/tmp 1777 root root 30d
742
743 # /usr/lib/tmpfiles.d/abrt.conf
744 d /var/tmp/abrt 0755 abrt abrt -
745
746 Example 4. Apply clean up during boot and based on time
747
748 # /usr/lib/tmpfiles.d/dnf.conf
749 r! /var/cache/dnf/*/*/download_lock.pid
750 r! /var/cache/dnf/*/*/metadata_lock.pid
751 r! /var/lib/dnf/rpmdb_lock.pid
752 e /var/cache/dnf/ - - - 30d
753
754 The lock files will be removed during boot. Any files and directories
755 in /var/cache/dnf/ will be removed after they have not been accessed in
756 30 days.
757
758 Example 5. Empty the contents of a cache directory on boot
759
760 # /usr/lib/tmpfiles.d/krb5rcache.conf
761 e! /var/cache/krb5rcache - - - 0
762
763 Any files and subdirectories in /var/cache/krb5rcache/ will be removed
764 on boot. The directory will not be created.
765
767 /var/run/ is a deprecated symlink to /run/, and applications should use
768 the latter. systemd-tmpfiles will warn if /var/run/ is used.
769
771 systemd(1), systemd-tmpfiles(8), systemd-delta(1), systemd.exec(5),
772 attr(5), getfattr(1), setfattr(1), setfacl(1), getfacl(1), chattr(1),
773 btrfs-subvolume(8), btrfs-qgroup(8)
774
776 1. Notes on Resolvability of User and Group Names
777 https://systemd.io/UIDS-GIDS/#notes-on-resolvability-of-user-and-group-names
778
779
780
781systemd 249 TMPFILES.D(5)