1TMPFILES.D(5)                     tmpfiles.d                     TMPFILES.D(5)
2
3
4

NAME

6       tmpfiles.d - Configuration for creation, deletion and cleaning of
7       volatile and temporary files
8

SYNOPSIS

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

DESCRIPTION

23       systemd-tmpfiles uses the configuration files from the above
24       directories to describe the creation, cleaning and removal of volatile
25       and temporary files and directories which usually reside in directories
26       such as /run or /tmp.
27
28       Volatile and temporary files and directories are those located in /run
29       (and its alias /var/run), /tmp, /var/tmp, the API file systems such as
30       /sys or /proc, as well as some other directories below /var.
31
32       System daemons frequently require private runtime directories below
33       /run to place communication sockets and similar in. For these, consider
34       declaring them in their unit files using RuntimeDirectory= (see
35       systemd.exec(5) for details), if this is feasible.
36

CONFIGURATION DIRECTORIES AND PRECEDENCE

38       Each configuration file shall be named in the style of package.conf or
39       package-part.conf. The second variant should be used when it is
40       desirable to make it easy to override just this part of configuration.
41
42       Files in /etc/tmpfiles.d override files with the same name in
43       /usr/lib/tmpfiles.d and /run/tmpfiles.d. Files in /run/tmpfiles.d
44       override files with the same name in /usr/lib/tmpfiles.d. Packages
45       should install their configuration files in /usr/lib/tmpfiles.d. Files
46       in /etc/tmpfiles.d are reserved for the local administrator, who may
47       use this logic to override the configuration files installed by vendor
48       packages. All configuration files are sorted by their filename in
49       lexicographic order, regardless of which of the directories they reside
50       in. If multiple files specify the same path, the entry in the file with
51       the lexicographically earliest name will be applied. All other
52       conflicting entries will be logged as errors. When two lines are prefix
53       and suffix of each other, then the prefix is always processed first,
54       the suffix later. Lines that take globs are applied after those
55       accepting no globs. If multiple operations shall be applied on the same
56       file, (such as ACL, xattr, file attribute adjustments), these are
57       always done in the same fixed order. Otherwise, the files/directories
58       are processed in the order they are listed.
59
60       If the administrator wants to disable a configuration file supplied by
61       the vendor, the recommended way is to place a symlink to /dev/null in
62       /etc/tmpfiles.d/ bearing the same filename.
63

CONFIGURATION FILE FORMAT

65       The configuration format is one line per path containing type, path,
66       mode, ownership, age, and argument fields:
67
68           #Type Path        Mode UID  GID  Age Argument
69           d     /run/user   0755 root root 10d -
70           L     /tmp/foobar -    -    -    -   /dev/null
71
72       Fields may be enclosed within quotes and contain C-style escapes.
73
74   Type
75       The type consists of a single letter and optionally an exclamation
76       mark.
77
78       The following line types are understood:
79
80       f
81           Create a file if it does not exist yet. If the argument parameter
82           is given and the file did not exist yet, it will be written to the
83           file. Does not follow symlinks.
84
85       F
86           Create or truncate a file. If the argument parameter is given, it
87           will be written to the file. Does not follow symlinks.
88
89       w
90           Write the argument parameter to a file, if the file exists. Lines
91           of this type accept shell-style globs in place of normal path
92           names. The argument parameter will be written without a trailing
93           newline. C-style backslash escapes are interpreted. Follows
94           symlinks.
95
96       d
97           Create a directory. The mode and ownership will be adjusted if
98           specified and the directory already exists. Contents of this
99           directory are subject to time based cleanup if the age argument is
100           specified.
101
102       D
103           Similar to d, but in addition the contents of the directory will be
104           removed when --remove is used.
105
106       e
107           Similar to d, but the directory will not be created if it does not
108           exist. Lines of this type accept shell-style globs in place of
109           normal path names. For this entry to be useful, at least one of the
110           mode, uid, gid, or age arguments must be specified, since otherwise
111           this entry has no effect. If the age argument is "0", contents of
112           the directory will be unconditionally deleted every time
113           systemd-tmpfiles --clean is run. This can be useful when combined
114           with !, see the examples.
115
116       v
117           Create a subvolume if the path does not exist yet, the file system
118           supports subvolumes (btrfs), and the system itself is installed
119           into a subvolume (specifically: the root directory / is itself a
120           subvolume). Otherwise, create a normal directory, in the same way
121           as d. A subvolume created with this line type is not assigned to
122           any higher-level quota group. For that, use q or Q, which allow
123           creating simple quota group hierarchies, see below.
124
125       q
126           Similar to v. However, makes sure that the subvolume will be
127           assigned to the same higher-level quota groups as the subvolume it
128           has been created in. This ensures that higher-level limits and
129           accounting applied to the parent subvolume also include the
130           specified subvolume. On non-btrfs file systems, this line type is
131           identical to d. If the subvolume already exists and is already
132           assigned to one or more higher level quota groups, no change to the
133           quota hierarchy is made. Also see Q below. See btrfs-qgroup(8) for
134           details about the btrfs quota group concept.
135
136       Q
137           Similar to q. However, instead of copying the higher-level quota
138           group assignments from the parent as-is, the lowest quota group of
139           the parent subvolume is determined that is not the leaf quota
140           group. Then, an "intermediary" quota group is inserted that is one
141           level below this level, and shares the same ID part as the
142           specified subvolume. If no higher-level quota group exists for the
143           parent subvolume, a new quota group at level 255 sharing the same
144           ID as the specified subvolume is inserted instead. This new
145           intermediary quota group is then assigned to the parent subvolume's
146           higher-level quota groups, and the specified subvolume's leaf quota
147           group is assigned to it.
148
149           Effectively, this has a similar effect as q, however introduces a
150           new higher-level quota group for the specified subvolume that may
151           be used to enforce limits and accounting to the specified subvolume
152           and children subvolume created within it. Thus, by creating
153           subvolumes only via q and Q, a concept of "subtree quotas" is
154           implemented. Each subvolume for which Q is set will get a "subtree"
155           quota group created, and all child subvolumes created within it
156           will be assigned to it. Each subvolume for which q is set will not
157           get such a "subtree" quota group, but it is ensured that they are
158           added to the same "subtree" quota group as their immediate parents.
159
160           It is recommended to use Q for subvolumes that typically contain
161           further subvolumes, and where it is desirable to have accounting
162           and quota limits on all child subvolumes together. Examples for Q
163           are typically /home or /var/lib/machines. In contrast, q should be
164           used for subvolumes that either usually do not include further
165           subvolumes or where no accounting and quota limits are needed that
166           apply to all child subvolumes together. Examples for q are
167           typically /var or /var/tmp. As with Q, q has no effect on the quota
168           group hierarchy if the subvolume exists and already has at least
169           one higher-level quota group assigned.
170
171       p, p+
172           Create a named pipe (FIFO) if it does not exist yet. If suffixed
173           with + and a file already exists where the pipe is to be created,
174           it will be removed and be replaced by the pipe.
175
176       L, L+
177           Create a symlink if it does not exist yet. If suffixed with + and a
178           file or directory already exists where the symlink is to be
179           created, it will be removed and be replaced by the symlink. If the
180           argument is omitted, symlinks to files with the same name residing
181           in the directory /usr/share/factory/ are created. Note that
182           permissions and ownership on symlinks are ignored.
183
184       c, c+
185           Create a character device node if it does not exist yet. If
186           suffixed with + and a file already exists where the device node is
187           to be created, it will be removed and be replaced by the device
188           node. It is recommended to suffix this entry with an exclamation
189           mark to only create static device nodes at boot, as udev will not
190           manage static device nodes that are created at runtime.
191
192       b, b+
193           Create a block device node if it does not exist yet. If suffixed
194           with + and a file already exists where the device node is to be
195           created, it will be removed and be replaced by the device node. It
196           is recommended to suffix this entry with an exclamation mark to
197           only create static device nodes at boot, as udev will not manage
198           static device nodes that are created at runtime.
199
200       C
201           Recursively copy a file or directory, if the destination files or
202           directories do not exist yet. Note that this command will not
203           descend into subdirectories if the destination directory already
204           exists. Instead, the entire copy operation is skipped. If the
205           argument is omitted, files from the source directory
206           /usr/share/factory/ with the same name are copied. Does not follow
207           symlinks.
208
209       x
210           Ignore a path during cleaning. Use this type to exclude paths from
211           clean-up as controlled with the Age parameter. Note that lines of
212           this type do not influence the effect of r or R lines. Lines of
213           this type accept shell-style globs in place of normal path names.
214
215       X
216           Ignore a path during cleaning. Use this type to exclude paths from
217           clean-up as controlled with the Age parameter. Unlike x, this
218           parameter will not exclude the content if path is a directory, but
219           only directory itself. Note that lines of this type do not
220           influence the effect of r or R lines. Lines of this type accept
221           shell-style globs in place of normal path names.
222
223       r
224           Remove a file or directory if it exists. This may not be used to
225           remove non-empty directories, use R for that. Lines of this type
226           accept shell-style globs in place of normal path names. Does not
227           follow symlinks.
228
229       R
230           Recursively remove a path and all its subdirectories (if it is a
231           directory). Lines of this type accept shell-style globs in place of
232           normal path names. Does not follow symlinks.
233
234       z
235           Adjust the access mode, group and user, and restore the SELinux
236           security context of a file or directory, if it exists. Lines of
237           this type accept shell-style globs in place of normal path names.
238           Does not follow symlinks.
239
240       Z
241           Recursively set the access mode, group and user, and restore the
242           SELinux security context of a file or directory if it exists, as
243           well as of its subdirectories and the files contained therein (if
244           applicable). Lines of this type accept shell-style globs in place
245           of normal path names. Does not follow symlinks.
246
247       t
248           Set extended attributes. Lines of this type accept shell-style
249           globs in place of normal path names. This can be useful for setting
250           SMACK labels. Does not follow symlinks.
251
252       T
253           Recursively set extended attributes. Lines of this type accept
254           shell-style globs in place of normal path names. This can be useful
255           for setting SMACK labels. Does not follow symlinks.
256
257       h
258           Set file/directory attributes. Lines of this type accept
259           shell-style globs in place of normal path names.
260
261           The format of the argument field is [+-=][aAcCdDeijsStTu] . The
262           prefix + (the default one) causes the attribute(s) to be added; -
263           causes the attribute(s) to be removed; = causes the attributes to
264           be set exactly as the following letters. The letters
265           "aAcCdDeijsStTu" select the new attributes for the files, see
266           chattr(1) for further information.
267
268           Passing only = as argument resets all the file attributes listed
269           above. It has to be pointed out that the = prefix limits itself to
270           the attributes corresponding to the letters listed here. All other
271           attributes will be left untouched. Does not follow symlinks.
272
273       H
274           Recursively set file/directory attributes. Lines of this type
275           accept shell-style globs in place of normal path names. Does not
276           follow symlinks.
277
278       a, a+
279           Set POSIX ACLs (access control lists). If suffixed with +, the
280           specified entries will be added to the existing set.
281           systemd-tmpfiles will automatically add the required base entries
282           for user and group based on the access mode of the file, unless
283           base entries already exist or are explicitly specified. The mask
284           will be added if not specified explicitly or already present. Lines
285           of this type accept shell-style globs in place of normal path
286           names. This can be useful for allowing additional access to certain
287           files. Does not follow symlinks.
288
289       A, A+
290           Same as a and a+, but recursive. Does not follow symlinks.
291
292       If the exclamation mark is used, this line is only safe of execute
293       during boot, and can break a running system. Lines without the
294       exclamation mark are presumed to be safe to execute at any time, e.g.
295       on package upgrades.  systemd-tmpfiles will execute line with an
296       exclamation mark only if option --boot is given.
297
298       For example:
299
300           # Make sure these are created by default so that nobody else can
301           d /tmp/.X11-unix 1777 root root 10d
302
303           # Unlink the X11 lock files
304           r! /tmp/.X[0-9]*-lock
305
306       The second line in contrast to the first one would break a running
307       system, and will only be executed with --boot.
308
309       Note that for all line types that result in creation of any kind of
310       file node (i.e.  f/F, d/D/v/q/Q, p, L, c/b and C) leading directories
311       are implicitly created if needed, owned by root with an access mode of
312       0755. In order to create them with different modes or ownership make
313       sure to add appropriate d lines.
314
315   Path
316       The file system path specification supports simple specifier expansion,
317       see below. The path (after expansion) must be absolute.
318
319   Mode
320       The file access mode to use when creating this file or directory. If
321       omitted or when set to "-", the default is used: 0755 for directories,
322       0644 for all other file objects. For z, Z lines, if omitted or when set
323       to "-", the file access mode will not be modified. This parameter is
324       ignored for x, r, R, L, t, and a lines.
325
326       Optionally, if prefixed with "~", the access mode is masked based on
327       the already set access bits for existing file or directories: if the
328       existing file has all executable bits unset, all executable bits are
329       removed from the new access mode, too. Similarly, if all read bits are
330       removed from the old access mode, they will be removed from the new
331       access mode too, and if all write bits are removed, they will be
332       removed from the new access mode too. In addition, the sticky/SUID/SGID
333       bit is removed unless applied to a directory. This functionality is
334       particularly useful in conjunction with Z.
335
336   UID, GID
337       The user and group to use for this file or directory. This may either
338       be a numeric user/group ID or a user or group name. If omitted or when
339       set to "-", the default 0 (root) is used. For z and Z lines, when
340       omitted or when set to "-", the file ownership will not be modified.
341       These parameters are ignored for x, r, R, L, t, and a lines.
342
343   Age
344       The date field, when set, is used to decide what files to delete when
345       cleaning. If a file or directory is older than the current time minus
346       the age field, it is deleted. The field format is a series of integers
347       each followed by one of the following suffixes for the respective time
348       units: s, m or min, h, d, w, ms, and us, meaning seconds, minutes,
349       hours, days, weeks, milliseconds, and microseconds, respectively. Full
350       names of the time units can be used too.
351
352       If multiple integers and units are specified, the time values are
353       summed. If an integer is given without a unit, s is assumed.
354
355       When the age is set to zero, the files are cleaned unconditionally.
356
357       The age field only applies to lines starting with d, D, e, v, q, Q, C,
358       x and X. If omitted or set to "-", no automatic clean-up is done.
359
360       If the age field starts with a tilde character "~", the clean-up is
361       only applied to files and directories one level inside the directory
362       specified, but not the files and directories immediately inside it.
363
364       The age of a file system entry is determined from its last modification
365       timestamp (mtime), its last access timestamp (atime), and (except for
366       directories) its last status change timestamp (ctime). Any of these
367       three (or two) values will prevent cleanup if it is more recent than
368       the current time minus the age field.
369
370   Argument
371       For L lines determines the destination path of the symlink. For c and
372       b, determines the major/minor of the device node, with major and minor
373       formatted as integers, separated by ":", e.g.  "1:3". For f, F, and w,
374       the argument may be used to specify a short string that is written to
375       the file, suffixed by a newline. For C, specifies the source file or
376       directory. For t and T, determines extended attributes to be set. For a
377       and A, determines ACL attributes to be set. For h and H, determines the
378       file attributes to set. Ignored for all other lines.
379
380       This field can contain specifiers, see below.
381

SPECIFIERS

383       Specifiers can be used in the "path" and "argument" fields. An unknown
384       or unresolvable specifier is treated as invalid configuration. The
385       following expansions are understood:
386
387       Table 1. Specifiers available
388       ┌──────────┬─────────────────────┬─────────────────────┐
389Specifier Meaning             Details             
390       ├──────────┼─────────────────────┼─────────────────────┤
391       │"%b"      │ Boot ID             │ The boot ID of the  │
392       │          │                     │ running system,     │
393       │          │                     │ formatted as        │
394       │          │                     │ string. See         │
395       │          │                     │ random(4) for more  │
396       │          │                     │ information.        │
397       ├──────────┼─────────────────────┼─────────────────────┤
398       │"%C"      │ System or user      │ In --user mode,     │
399       │          │ cache directory     │ this is the same as │
400       │          │                     │ $XDG_CACHE_HOME,    │
401       │          │                     │ and /var/cache      │
402       │          │                     │ otherwise.          │
403       ├──────────┼─────────────────────┼─────────────────────┤
404       │"%h"      │ User home directory │ This is the home    │
405       │          │                     │ directory of the    │
406       │          │                     │ user running the    │
407       │          │                     │ command. In case of │
408       │          │                     │ the system instance │
409       │          │                     │ this resolves to    │
410       │          │                     │ "/root".            │
411       ├──────────┼─────────────────────┼─────────────────────┤
412       │"%H"      │ Host name           │ The hostname of the │
413       │          │                     │ running system.     │
414       ├──────────┼─────────────────────┼─────────────────────┤
415       │"%L"      │ System or user log  │ In --user mode,     │
416       │          │ directory           │ this is the same as │
417       │          │                     │ $XDG_CONFIG_HOME
418       │          │                     │ with /log appended, │
419       │          │                     │ and /var/log        │
420       │          │                     │ otherwise.          │
421       ├──────────┼─────────────────────┼─────────────────────┤
422       │"%m"      │ Machine ID          │ The machine ID of   │
423       │          │                     │ the running system, │
424       │          │                     │ formatted as        │
425       │          │                     │ string. See         │
426       │          │                     │ machine-id(5) for   │
427       │          │                     │ more information.   │
428       ├──────────┼─────────────────────┼─────────────────────┤
429       │"%S"      │ System or user      │ In --user mode,     │
430       │          │ state directory     │ this is the same as │
431       │          │                     │ $XDG_CONFIG_HOME,   │
432       │          │                     │ and /var/lib        │
433       │          │                     │ otherwise.          │
434       ├──────────┼─────────────────────┼─────────────────────┤
435       │"%t"      │ System or user      │ In --user mode,     │
436       │          │ runtime directory   │ this is the same    │
437       │          │                     │ $XDG_RUNTIME_DIR,   │
438       │          │                     │ and /run otherwise. │
439       ├──────────┼─────────────────────┼─────────────────────┤
440       │"%T"      │ Directory for       │ This is either /tmp │
441       │          │ temporary files     │ or the path         │
442       │          │                     │ "$TMPDIR", "$TEMP"  │
443       │          │                     │ or "$TMP" are set   │
444       │          │                     │ to.                 │
445       ├──────────┼─────────────────────┼─────────────────────┤
446       │"%u"      │ User name           │ This is the name of │
447       │          │                     │ the user running    │
448       │          │                     │ the command. In     │
449       │          │                     │ case of the system  │
450       │          │                     │ instance this       │
451       │          │                     │ resolves to "root". │
452       ├──────────┼─────────────────────┼─────────────────────┤
453       │"%U"      │ User UID            │ This is the numeric │
454       │          │                     │ UID of the user     │
455       │          │                     │ running the         │
456       │          │                     │ command. In case of │
457       │          │                     │ the system instance │
458       │          │                     │ this resolves to 0. │
459       ├──────────┼─────────────────────┼─────────────────────┤
460       │"%v"      │ Kernel release      │ Identical to uname  
461       │          │                     │ -r output.          │
462       ├──────────┼─────────────────────┼─────────────────────┤
463       │"%V"      │ Directory for       │ This is either      │
464       │          │ larger and          │ /var/tmp or the     │
465       │          │ persistent          │ path "$TMPDIR",     │
466       │          │ temporary files     │ "$TEMP" or "$TMP"   │
467       │          │                     │ are set to.         │
468       ├──────────┼─────────────────────┼─────────────────────┤
469       │"%%"      │ Escaped "%"         │ Single percent      │
470       │          │                     │ sign.               │
471       └──────────┴─────────────────────┴─────────────────────┘
472

EXAMPLES

474       Example 1. Create directories with specific mode and ownership
475
476       screen(1), needs two directories created at boot with specific modes
477       and ownership:
478
479           # /usr/lib/tmpfiles.d/screen.conf
480           d /run/screens  1777 root screen 10d
481           d /run/uscreens 0755 root screen 10d12h
482
483       Contents of /run/screens and /run/uscreens will be cleaned up after 10
484       and 10½ days, respectively.
485
486       Example 2. Create a directory with a SMACK attribute
487
488           D /run/cups - - - -
489           t /run/cups - - - - security.SMACK64=printing user.attr-with-spaces="foo bar"
490
491
492       The directory will be owned by root and have default mode. Its contents
493       are not subject to time based cleanup, but will be obliterated when
494       systemd-tmpfiles --remove runs.
495
496       Example 3. Create a directory and prevent its contents from cleanup
497
498       abrt(1), needs a directory created at boot with specific mode and
499       ownership and its content should be preserved from the automatic
500       cleanup applied to the contents of /var/tmp:
501
502           # /usr/lib/tmpfiles.d/tmp.conf
503           d /var/tmp 1777 root root 30d
504
505           # /usr/lib/tmpfiles.d/abrt.conf
506           d /var/tmp/abrt 0755 abrt abrt -
507
508       Example 4. Apply clean up during boot and based on time
509
510           # /usr/lib/tmpfiles.d/dnf.conf
511           r! /var/cache/dnf/*/*/download_lock.pid
512           r! /var/cache/dnf/*/*/metadata_lock.pid
513           r! /var/lib/dnf/rpmdb_lock.pid
514           e  /var/cache/dnf/ - - - 30d
515
516       The lock files will be removed during boot. Any files and directories
517       in /var/cache/dnf/ will be removed after they have not been accessed in
518       30 days.
519
520       Example 5. Empty the contents of a cache directory on boot
521
522           # /usr/lib/tmpfiles.d/krb5rcache.conf
523           e! /var/cache/krb5rcache - - - 0
524
525       Any files and subdirectories in /var/cache/krb5rcache/ will be removed
526       on boot. The directory will not be created.
527

SEE ALSO

529       systemd(1), systemd-tmpfiles(8), systemd-delta(1), systemd.exec(5),
530       attr(5), getfattr(1), setfattr(1), setfacl(1), getfacl(1), chattr(1),
531       btrfs-subvolume(8), btrfs-qgroup(8)
532
533
534
535systemd 239                                                      TMPFILES.D(5)
Impressum