| TMPFILES.D(5) | tmpfiles.d | TMPFILES.D(5) |
NAME
tmpfiles.d - Configuration for creation, deletion, and cleaning of files and directories
SYNOPSIS
#Type Path Mode User Group Age Argument f /file/to/create mode user group - content f+ /file/to/create-or-truncate mode user group - content w /file/to/write-to - - - - content w+ /file/to/append-to - - - - content d /directory/to/create-and-clean-up mode user group cleanup-age - D /directory/to/create-and-remove mode user group cleanup-age - e /directory/to/clean-up mode user group cleanup-age - v /subvolume-or-directory/to/create mode user group cleanup-age - q /subvolume-or-directory/to/create mode user group cleanup-age - Q /subvolume-or-directory/to/create mode user group cleanup-age - p /fifo/to/create mode user group - - p+ /fifo/to/[re]create mode user group - - L /symlink/to/create - - - - symlink/target/path L+ /symlink/to/[re]create - - - - symlink/target/path c /dev/char-device-to-create mode user group - major:minor c+ /dev/char-device-to-[re]create mode user group - major:minor b /dev/block-device-to-create mode user group - major:minor b+ /dev/block-device-to-[re]create mode user group - major:minor C /target/to/create - - - cleanup-age /source/to/copy C+ /target/to/create - - - cleanup-age /source/to/copy x /path-or-glob/to/ignore/recursively - - - cleanup-age - X /path-or-glob/to/ignore - - - cleanup-age - r /path-or-glob/to/remove - - - - - R /path-or-glob/to/remove/recursively - - - - - z /path-or-glob/to/adjust/mode mode user group - - Z /path-or-glob/to/adjust/mode/recursively mode user group - - t /path-or-glob/to/set/xattrs - - - - xattrs T /path-or-glob/to/set/xattrs/recursively - - - - xattrs h /path-or-glob/to/set/attrs - - - - file attrs H /path-or-glob/to/set/attrs/recursively - - - - file attrs a /path-or-glob/to/set/acls - - - - POSIX ACLs a+ /path-or-glob/to/append/acls - - - - POSIX ACLs A /path-or-glob/to/set/acls/recursively - - - - POSIX ACLs A+ /path-or-glob/to/append/acls/recursively - - - - POSIX ACLs
DESCRIPTION
tmpfiles.d configuration files provide a generic mechanism to define the creation of regular files, directories, pipes, and device nodes, adjustments to their access mode, ownership, attributes, quota assignments, and contents, and finally their time-based removal. It is mostly commonly used for volatile and temporary files and directories (such as those located under /run/, /tmp/, /var/tmp/, the API file systems such as /sys/ or /proc/, as well as some other directories below /var/).
systemd-tmpfiles(8) uses this configuration to create volatile files and directories during boot and to do periodic cleanup afterwards. See systemd-tmpfiles(8) for the description of systemd-tmpfiles-setup.service, systemd-tmpfiles-clean.service, and associated units.
System daemons frequently require private runtime directories below /run/ to store communication sockets and similar. For these, it is better to use RuntimeDirectory= in their unit files (see systemd.exec(5) for details), if the flexibility provided by tmpfiles.d is not required. The advantages are that the configuration required by the unit is centralized in one place, and that the lifetime of the directory is tied to the lifetime of the service itself. Similarly, StateDirectory=, CacheDirectory=, LogsDirectory=, and ConfigurationDirectory= should be used to create directories under /var/lib/, /var/cache/, /var/log/, and /etc/. tmpfiles.d should be used for files whose lifetime is independent of any service or requires more complicated configuration.
CONFIGURATION DIRECTORIES AND PRECEDENCE
Each configuration file shall be named in the style of package.conf or package-part.conf. The second variant should be used when it is desirable to make it easy to override just this part of configuration.
Files in /etc/tmpfiles.d override files with the same name in /usr/lib/tmpfiles.d and /run/tmpfiles.d. Files in /run/tmpfiles.d override files with the same name in /usr/lib/tmpfiles.d. Packages should install their configuration files in /usr/lib/tmpfiles.d. Files in /etc/tmpfiles.d are reserved for the local administrator, who may use this logic to override the configuration files installed by vendor packages. All configuration files are sorted by their filename in lexicographic order, regardless of which of the directories they reside in. If multiple files specify the same path, the entry in the file with the lexicographically earliest name will be applied (note that lines suppressed due to the "!" are filtered before application, meaning that if an early line carries the exclamation mark and is suppressed because of that, a later line matching in path will be applied). All other conflicting entries will be logged as errors. When two lines are prefix path and suffix path of each other, then the prefix line is always created first, the suffix later (and if removal applies to the line, the order is reversed: the suffix is removed first, the prefix later). Lines that take globs are applied after those accepting no globs. If multiple operations shall be applied on the same file (such as ACL, xattr, file attribute adjustments), these are always done in the same fixed order. Except for those cases, the files/directories are processed in the order they are listed.
If the administrator wants to disable a configuration file supplied by the vendor, the recommended way is to place a symlink to /dev/null in /etc/tmpfiles.d/ bearing the same filename.
CONFIGURATION FILE FORMAT
The configuration format is one line per path, containing type, path, mode, ownership, age, and argument fields. The lines are separated by newlines, the fields by whitespace:
#Type Path Mode User Group Age Argument... d /run/user 0755 root root 10d - L /tmp/foobar - - - - /dev/null
Fields may contain C-style escapes. With the exception of the seventh field (the "argument") all fields may be enclosed in quotes. Note that any whitespace found in the line after the beginning of the argument field will be considered part of the argument field. To begin the argument field with a whitespace character, use C-style escapes (e.g. "\x20").
Type
The type consists of a single letter and optionally one or more modifier characters: a plus sign ("+"), exclamation mark ("!"), minus sign ("-"), equals sign ("="), tilde character ("~") and/or caret ("^").
The following line types are understood:
f, f+
w, w+
d
D
e
For this entry to be useful, at least one of the mode, user, group, or age arguments must be specified, since otherwise this entry has no effect. As an exception, an entry with no effect may be useful when combined with !, see the examples.
Added in version 230.
v
A subvolume created with this line type is not assigned to any higher-level quota group. For that, use q or Q, which allow creating simple quota group hierarchies, see below.
Added in version 219.
q
If the subvolume already exists, no change to the quota hierarchy is made, regardless of whether the subvolume is already attached to a quota group or not. Also see Q below. See btrfs-qgroup(8) for details about the btrfs quota group concept.
Added in version 228.
Q
Effectively, this has a similar effect as q, however introduces a new higher-level quota group for the specified subvolume that may be used to enforce limits and accounting to the specified subvolume and children subvolume created within it. Thus, by creating subvolumes only via q and Q, a concept of "subtree quotas" is implemented. Each subvolume for which Q is set will get a "subtree" quota group created, and all child subvolumes created within it will be assigned to it. Each subvolume for which q is set will not get such a "subtree" quota group, but it is ensured that they are added to the same "subtree" quota group as their immediate parents.
It is recommended to use Q for subvolumes that typically contain further subvolumes, and where it is desirable to have accounting and quota limits on all child subvolumes together. Examples for Q are typically /home/ or /var/lib/machines/. In contrast, q should be used for subvolumes that either usually do not include further subvolumes or where no accounting and quota limits are needed that apply to all child subvolumes together. Examples for q are typically /var/ or /var/tmp/.
As with q, Q has no effect on the quota group hierarchy if the subvolume already exists, regardless of whether the subvolume already belong to a quota group or not.
Added in version 228.
p, p+
L, L+, L?
c, c+
b, b+
C, C+
Added in version 214.
x
X
Added in version 198.
r
R
z
Z
t
Please note that extended attributes settable with this line type are a different concept from the Linux file attributes settable with h/H, see below.
Added in version 218.
T
Added in version 219.
h
The format of the argument field is [+-=][aAcCdDeijPsStTu]. The prefix + (the default one) causes the attributes to be added; - causes the attributes to be removed; = causes the attributes to be set exactly as the following letters. The letters "aAcCdDeijPsStTu" select the new attributes for the files, see chattr(1) for further information.
Passing only = as argument resets all the file attributes listed above. It has to be pointed out that the = prefix limits itself to the attributes corresponding to the letters listed here. All other attributes will be left untouched. Does not follow symlinks.
Please note that the Linux file attributes settable with this line type are a different concept from the extended attributes settable with t/T, see above.
H
Added in version 220.
a, a+