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 ("!") and/or minus 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 Note that for all line types that result in creation of any kind of
396 file node (i.e. f/F, d/D/v/q/Q, p, L, c/b and C) leading directories
397 are implicitly created if needed, owned by root with an access mode of
398 0755. In order to create them with different modes or ownership make
399 sure to add appropriate d lines.
400
401 Path
402 The file system path specification supports simple specifier expansion,
403 see below. The path (after expansion) must be absolute.
404
405 Mode
406 The file access mode to use when creating this file or directory. If
407 omitted or when set to "-", the default is used: 0755 for directories,
408 0644 for all other file objects. For z, Z lines, if omitted or when set
409 to "-", the file access mode will not be modified. This parameter is
410 ignored for x, r, R, L, t, and a lines.
411
412 Optionally, if prefixed with "~", the access mode is masked based on
413 the already set access bits for existing file or directories: if the
414 existing file has all executable bits unset, all executable bits are
415 removed from the new access mode, too. Similarly, if all read bits are
416 removed from the old access mode, they will be removed from the new
417 access mode too, and if all write bits are removed, they will be
418 removed from the new access mode too. In addition, the sticky/SUID/SGID
419 bit is removed unless applied to a directory. This functionality is
420 particularly useful in conjunction with Z.
421
422 User, Group
423 The user and group to use for this file or directory. This may either
424 be a numeric ID or a user/group name. If omitted or when set to "-",
425 the user and group of the user who invokes systemd-tmpfiles is used.
426 For z and Z lines, when omitted or when set to "-", the file ownership
427 will not be modified. These parameters are ignored for x, r, R, L, t,
428 and a lines.
429
430 This field should generally only reference system users/groups, i.e.
431 users/groups that are guaranteed to be resolvable during early boot. If
432 this field references users/groups that only become resolveable during
433 later boot (i.e. after NIS, LDAP or a similar networked directory
434 service become available), execution of the operations declared by the
435 line will likely fail. Also see Notes on Resolvability of User and
436 Group Names[1] for more information on requirements on system
437 user/group definitions.
438
439 Age
440 The date field, when set, is used to decide what files to delete when
441 cleaning. If a file or directory is older than the current time minus
442 the age field, it is deleted. The field format is a series of integers
443 each followed by one of the following suffixes for the respective time
444 units: s, m or min, h, d, w, ms, and us, meaning seconds, minutes,
445 hours, days, weeks, milliseconds, and microseconds, respectively. Full
446 names of the time units can be used too.
447
448 If multiple integers and units are specified, the time values are
449 summed. If an integer is given without a unit, s is assumed.
450
451 When the age is set to zero, the files are cleaned unconditionally.
452
453 The age field only applies to lines starting with d, D, e, v, q, Q, C,
454 x and X. If omitted or set to "-", no automatic clean-up is done.
455
456 If the age field starts with a tilde character "~", the clean-up is
457 only applied to files and directories one level inside the directory
458 specified, but not the files and directories immediately inside it.
459
460 The age of a file system entry is determined from its last modification
461 timestamp (mtime), its last access timestamp (atime), and (except for
462 directories) its last status change timestamp (ctime). Any of these
463 three (or two) values will prevent cleanup if it is more recent than
464 the current time minus the age field.
465
466 Note that while the aging algorithm is run a 'shared' BSD file lock
467 (see flock(2)) is taken on each directory the algorithm descends into
468 (and each directory below that, and so on). If the aging algorithm
469 finds a lock is already taken on some directory, it (and everything
470 below it) is skipped. Applications may use this to temporarily exclude
471 certain directory subtrees from the aging algorithm: the applications
472 can take a BSD file lock themselves, and as long as they keep it aging
473 of the directory and everything below it is disabled.
474
475 Argument
476 For L lines determines the destination path of the symlink. For c and
477 b, determines the major/minor of the device node, with major and minor
478 formatted as integers, separated by ":", e.g. "1:3". For f, F, and w,
479 the argument may be used to specify a short string that is written to
480 the file, suffixed by a newline. For C, specifies the source file or
481 directory. For t and T, determines extended attributes to be set. For a
482 and A, determines ACL attributes to be set. For h and H, determines the
483 file attributes to set. Ignored for all other lines.
484
485 This field can contain specifiers, see below.
486
488 Specifiers can be used in the "path" and "argument" fields. An unknown
489 or unresolvable specifier is treated as invalid configuration. The
490 following expansions are understood:
491
492 Table 1. Specifiers available
493 ┌──────────┬─────────────────────┬────────────────────────┐
494 │Specifier │ Meaning │ Details │
495 ├──────────┼─────────────────────┼────────────────────────┤
496 │"%a" │ Architecture │ A short string │
497 │ │ │ identifying the │
498 │ │ │ architecture of the │
499 │ │ │ local system. A │
500 │ │ │ string such as x86, │
501 │ │ │ x86-64 or arm64. │
502 │ │ │ See the │
503 │ │ │ architectures │
504 │ │ │ defined for │
505 │ │ │ ConditionArchitecture= │
506 │ │ │ in systemd.unit(5) │
507 │ │ │ for a full list. │
508 ├──────────┼─────────────────────┼────────────────────────┤
509 │"%b" │ Boot ID │ The boot ID of the │
510 │ │ │ running system, │
511 │ │ │ formatted as string. │
512 │ │ │ See random(4) for more │
513 │ │ │ information. │
514 ├──────────┼─────────────────────┼────────────────────────┤
515 │"%B" │ Operating system │ The operating system │
516 │ │ build ID │ build identifier of │
517 │ │ │ the running system, as │
518 │ │ │ read from the │
519 │ │ │ BUILD_ID= field of │
520 │ │ │ /etc/os-release. If │
521 │ │ │ not set, resolves to │
522 │ │ │ an empty string. See │
523 │ │ │ os-release(5) for more │
524 │ │ │ information. │
525 ├──────────┼─────────────────────┼────────────────────────┤
526 │"%C" │ System or user │ In --user mode, this │
527 │ │ cache directory │ is the same as │
528 │ │ │ $XDG_CACHE_HOME, and │
529 │ │ │ /var/cache otherwise. │
530 ├──────────┼─────────────────────┼────────────────────────┤
531 │"%g" │ User group │ This is the name of │
532 │ │ │ the group running the │
533 │ │ │ command. In case of │
534 │ │ │ the system instance │
535 │ │ │ this resolves to │
536 │ │ │ "root". │
537 ├──────────┼─────────────────────┼────────────────────────┤
538 │"%G" │ User GID │ This is the numeric │
539 │ │ │ GID of the group │
540 │ │ │ running the command. │
541 │ │ │ In case of the system │
542 │ │ │ instance this resolves │
543 │ │ │ to 0. │
544 ├──────────┼─────────────────────┼────────────────────────┤
545 │"%h" │ User home directory │ This is the home │
546 │ │ │ directory of the user │
547 │ │ │ running the command. │
548 │ │ │ In case of the system │
549 │ │ │ instance this resolves │
550 │ │ │ to "/root". │
551 ├──────────┼─────────────────────┼────────────────────────┤
552 │"%H" │ Host name │ The hostname of the │
553 │ │ │ running system. │
554 ├──────────┼─────────────────────┼────────────────────────┤
555 │"%l" │ Short host name │ The hostname of the │
556 │ │ │ running system, │
557 │ │ │ truncated at the first │
558 │ │ │ dot to remove any │
559 │ │ │ domain component. │
560 ├──────────┼─────────────────────┼────────────────────────┤
561 │"%L" │ System or user log │ In --user mode, this │
562 │ │ directory │ is the same as │
563 │ │ │ $XDG_CONFIG_HOME with │
564 │ │ │ /log appended, and │
565 │ │ │ /var/log otherwise. │
566 ├──────────┼─────────────────────┼────────────────────────┤
567 │"%m" │ Machine ID │ The machine ID of the │
568 │ │ │ running system, │
569 │ │ │ formatted as string. │
570 │ │ │ See machine-id(5) for │
571 │ │ │ more information. │
572 ├──────────┼─────────────────────┼────────────────────────┤
573 │"%o" │ Operating system ID │ The operating system │
574 │ │ │ identifier of the │
575 │ │ │ running system, as │
576 │ │ │ read from the ID= │
577 │ │ │ field of │
578 │ │ │ /etc/os-release. See │
579 │ │ │ os-release(5) for more │
580 │ │ │ information. │
581 ├──────────┼─────────────────────┼────────────────────────┤
582 │"%S" │ System or user │ In --user mode, this │
583 │ │ state directory │ is the same as │
584 │ │ │ $XDG_CONFIG_HOME, and │
585 │ │ │ /var/lib otherwise. │
586 ├──────────┼─────────────────────┼────────────────────────┤
587 │"%t" │ System or user │ In --user mode, this │
588 │ │ runtime directory │ is the same │
589 │ │ │ $XDG_RUNTIME_DIR, and │
590 │ │ │ /run/ otherwise. │
591 ├──────────┼─────────────────────┼────────────────────────┤
592 │"%T" │ Directory for │ This is either /tmp or │
593 │ │ temporary files │ the path "$TMPDIR", │
594 │ │ │ "$TEMP" or "$TMP" are │
595 │ │ │ set to. (Note that the │
596 │ │ │ directory may be │
597 │ │ │ specified without a │
598 │ │ │ trailing slash.) │
599 ├──────────┼─────────────────────┼────────────────────────┤
600 │"%u" │ User name │ This is the name of │
601 │ │ │ the user running the │
602 │ │ │ command. In case of │
603 │ │ │ the system instance │
604 │ │ │ this resolves to │
605 │ │ │ "root". │
606 ├──────────┼─────────────────────┼────────────────────────┤
607 │"%U" │ User UID │ This is the numeric │
608 │ │ │ UID of the user │
609 │ │ │ running the command. │
610 │ │ │ In case of the system │
611 │ │ │ instance this resolves │
612 │ │ │ to 0. │
613 ├──────────┼─────────────────────┼────────────────────────┤
614 │"%v" │ Kernel release │ Identical to uname -r │
615 │ │ │ output. │
616 ├──────────┼─────────────────────┼────────────────────────┤
617 │"%V" │ Directory for │ This is either │
618 │ │ larger and │ /var/tmp or the path │
619 │ │ persistent │ "$TMPDIR", "$TEMP" or │
620 │ │ temporary files │ "$TMP" are set to. │
621 │ │ │ (Note that the │
622 │ │ │ directory may be │
623 │ │ │ specified without a │
624 │ │ │ trailing slash.) │
625 ├──────────┼─────────────────────┼────────────────────────┤
626 │"%w" │ Operating system │ The operating system │
627 │ │ version ID │ version identifier of │
628 │ │ │ the running system, as │
629 │ │ │ read from the │
630 │ │ │ VERSION_ID= field of │
631 │ │ │ /etc/os-release. If │
632 │ │ │ not set, resolves to │
633 │ │ │ an empty string. See │
634 │ │ │ os-release(5) for more │
635 │ │ │ information. │
636 ├──────────┼─────────────────────┼────────────────────────┤
637 │"%W" │ Operating system │ The operating system │
638 │ │ variant ID │ variant identifier of │
639 │ │ │ the running system, as │
640 │ │ │ read from the │
641 │ │ │ VARIANT_ID= field of │
642 │ │ │ /etc/os-release. If │
643 │ │ │ not set, resolves to │
644 │ │ │ an empty string. See │
645 │ │ │ os-release(5) for more │
646 │ │ │ information. │
647 ├──────────┼─────────────────────┼────────────────────────┤
648 │"%%" │ Single percent sign │ Use "%%" in place of │
649 │ │ │ "%" to specify a │
650 │ │ │ single percent sign. │
651 └──────────┴─────────────────────┴────────────────────────┘
652
654 Example 1. Create directories with specific mode and ownership
655
656 screen(1), needs two directories created at boot with specific modes
657 and ownership:
658
659 # /usr/lib/tmpfiles.d/screen.conf
660 d /run/screens 1777 root screen 10d
661 d /run/uscreens 0755 root screen 10d12h
662
663 Contents of /run/screens and /run/uscreens will be cleaned up after 10
664 and 10½ days, respectively.
665
666 Example 2. Create a directory with a SMACK attribute
667
668 D /run/cups - - - -
669 t /run/cups - - - - security.SMACK64=printing user.attr-with-spaces="foo bar"
670
671
672 The directory will be owned by root and have default mode. Its contents
673 are not subject to time based cleanup, but will be obliterated when
674 systemd-tmpfiles --remove runs.
675
676 Example 3. Create a directory and prevent its contents from cleanup
677
678 abrt(1), needs a directory created at boot with specific mode and
679 ownership and its content should be preserved from the automatic
680 cleanup applied to the contents of /var/tmp:
681
682 # /usr/lib/tmpfiles.d/tmp.conf
683 d /var/tmp 1777 root root 30d
684
685 # /usr/lib/tmpfiles.d/abrt.conf
686 d /var/tmp/abrt 0755 abrt abrt -
687
688 Example 4. Apply clean up during boot and based on time
689
690 # /usr/lib/tmpfiles.d/dnf.conf
691 r! /var/cache/dnf/*/*/download_lock.pid
692 r! /var/cache/dnf/*/*/metadata_lock.pid
693 r! /var/lib/dnf/rpmdb_lock.pid
694 e /var/cache/dnf/ - - - 30d
695
696 The lock files will be removed during boot. Any files and directories
697 in /var/cache/dnf/ will be removed after they have not been accessed in
698 30 days.
699
700 Example 5. Empty the contents of a cache directory on boot
701
702 # /usr/lib/tmpfiles.d/krb5rcache.conf
703 e! /var/cache/krb5rcache - - - 0
704
705 Any files and subdirectories in /var/cache/krb5rcache/ will be removed
706 on boot. The directory will not be created.
707
709 /var/run/ is a deprecated symlink to /run/, and applications should use
710 the latter. systemd-tmpfiles will warn if /var/run/ is used.
711
713 systemd(1), systemd-tmpfiles(8), systemd-delta(1), systemd.exec(5),
714 attr(5), getfattr(1), setfattr(1), setfacl(1), getfacl(1), chattr(1),
715 btrfs-subvolume(8), btrfs-qgroup(8)
716
718 1. Notes on Resolvability of User and Group Names
719 https://systemd.io/UIDS-GIDS/#notes-on-resolvability-of-user-and-group-names
720
721
722
723systemd 248 TMPFILES.D(5)