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
12 /run/tmpfiles.d/*.conf
13
14 /usr/lib/tmpfiles.d/*.conf
15
17 systemd-tmpfiles uses the configuration files from the above
18 directories to describe the creation, cleaning and removal of volatile
19 and temporary files and directories which usually reside in directories
20 such as /run or /tmp.
21
22 Volatile and temporary files and directories are those located in /run
23 (and its alias /var/run), /tmp, /var/tmp, the API file systems such as
24 /sys or /proc, as well as some other directories below /var.
25
26 System daemons frequently require private runtime directories below
27 /run to place communication sockets and similar in. For these, consider
28 declaring them in their unit files using RuntimeDirectory= (see
29 systemd.exec(5) for details), if this is feasible.
30
32 Each configuration file shall be named in the style of package.conf or
33 package-part.conf. The second variant should be used when it is
34 desirable to make it easy to override just this part of configuration.
35
36 Files in /etc/tmpfiles.d override files with the same name in
37 /usr/lib/tmpfiles.d and /run/tmpfiles.d. Files in /run/tmpfiles.d
38 override files with the same name in /usr/lib/tmpfiles.d. Packages
39 should install their configuration files in /usr/lib/tmpfiles.d. Files
40 in /etc/tmpfiles.d are reserved for the local administrator, who may
41 use this logic to override the configuration files installed by vendor
42 packages. All configuration files are sorted by their filename in
43 lexicographic order, regardless of which of the directories they reside
44 in. If multiple files specify the same path, the entry in the file with
45 the lexicographically earliest name will be applied. All other
46 conflicting entries will be logged as errors. When two lines are prefix
47 and suffix of each other, then the prefix is always processed first,
48 the suffix later. Otherwise, the files/directories are processed in the
49 order they are listed.
50
51 If the administrator wants to disable a configuration file supplied by
52 the vendor, the recommended way is to place a symlink to /dev/null in
53 /etc/tmpfiles.d/ bearing the same filename.
54
55 The configuration format is one line per path containing type, path,
56 mode, ownership, age, and argument fields:
57
58 #Type Path Mode UID GID Age Argument
59 d /run/user 0755 root root 10d -
60 L /tmp/foobar - - - - /dev/null
61
62 Type
63 The type consists of a single letter and optionally an exclamation
64 mark.
65
66 The following line types are understood:
67
68 f
69 Create a file if it does not exist yet. If the argument parameter
70 is given, it will be written to the file.
71
72 F
73 Create or truncate a file. If the argument parameter is given, it
74 will be written to the file.
75
76 w
77 Write the argument parameter to a file, if the file exists. Lines
78 of this type accept shell-style globs in place of normal path
79 names. The argument parameter will be written without a trailing
80 newline. C-style backslash escapes are interpreted.
81
82 d
83 Create a directory if it does not exist yet.
84
85 D
86 Create or empty a directory.
87
88 e
89 Clean directory contents based on the age argument. Lines of this
90 type accept shell-style globs in place of normal path names.
91
92 v
93 Create a subvolume if the path does not exist yet and the file
94 system supports this (btrfs). Otherwise create a normal directory,
95 in the same way as d.
96
97 p, p+
98 Create a named pipe (FIFO) if it does not exist yet. If suffixed
99 with + and a file already exists where the pipe is to be created,
100 it will be removed and be replaced by the pipe.
101
102 L, L+
103 Create a symlink if it does not exist yet. If suffixed with + and a
104 file already exists where the symlink is to be created, it will be
105 removed and be replaced by the symlink. If the argument is omitted,
106 symlinks to files with the same name residing in the directory
107 /usr/share/factory/ are created. Note that permissions and
108 ownership on symlinks are ignored.
109
110 c, c+
111 Create a character device node if it does not exist yet. If
112 suffixed with + and a file already exists where the device node is
113 to be created, it will be removed and be replaced by the device
114 node. It is recommended to suffix this entry with an exclamation
115 mark to only create static device nodes at boot, as udev will not
116 manage static device nodes that are created at runtime.
117
118 b, b+
119 Create a block device node if it does not exist yet. If suffixed
120 with + and a file already exists where the device node is to be
121 created, it will be removed and be replaced by the device node. It
122 is recommended to suffix this entry with an exclamation mark to
123 only create static device nodes at boot, as udev will not manage
124 static device nodes that are created at runtime.
125
126 C
127 Recursively copy a file or directory, if the destination files or
128 directories do not exist yet. Note that this command will not
129 descend into subdirectories if the destination directory already
130 exists. Instead, the entire copy operation is skipped. If the
131 argument is omitted, files from the source directory
132 /usr/share/factory/ with the same name are copied.
133
134 x
135 Ignore a path during cleaning. Use this type to exclude paths from
136 clean-up as controlled with the Age parameter. Note that lines of
137 this type do not influence the effect of r or R lines. Lines of
138 this type accept shell-style globs in place of normal path names.
139
140 X
141 Ignore a path during cleaning. Use this type to exclude paths from
142 clean-up as controlled with the Age parameter. Unlike x, this
143 parameter will not exclude the content if path is a directory, but
144 only directory itself. Note that lines of this type do not
145 influence the effect of r or R lines. Lines of this type accept
146 shell-style globs in place of normal path names.
147
148 r
149 Remove a file or directory if it exists. This may not be used to
150 remove non-empty directories, use R for that. Lines of this type
151 accept shell-style globs in place of normal path names.
152
153 R
154 Recursively remove a path and all its subdirectories (if it is a
155 directory). Lines of this type accept shell-style globs in place of
156 normal path names.
157
158 z
159 Adjust the access mode, group and user, and restore the SELinux
160 security context of a file or directory, if it exists. Lines of
161 this type accept shell-style globs in place of normal path names.
162
163 Z
164 Recursively set the access mode, group and user, and restore the
165 SELinux security context of a file or directory if it exists, as
166 well as of its subdirectories and the files contained therein (if
167 applicable). Lines of this type accept shell-style globs in place
168 of normal path names.
169
170 t
171 Set extended attributes. Lines of this type accept shell-style
172 globs in place of normal path names. This can be useful for setting
173 SMACK labels.
174
175 T
176 Recursively set extended attributes. Lines of this type accept
177 shell-style globs in place of normal path names. This can be useful
178 for setting SMACK labels.
179
180 a, a+
181 Set POSIX ACLs (access control lists). If suffixed with +,
182 specified entries will be added to the existing set.
183 systemd-tmpfiles will automatically add the required base entries
184 for user and group based on the access mode of the file, unless
185 base entries already exist or are explictly specified. The mask
186 will be added if not specified explicitly or already present. Lines
187 of this type accept shell-style globs in place of normal path
188 names. This can be useful for allowing additional access to certain
189 files.
190
191 A, A+
192 Same as a and a+, but recursive.
193
194 If the exclamation mark is used, this line is only safe of execute
195 during boot, and can break a running system. Lines without the
196 exclamation mark are presumed to be safe to execute at any time, e.g.
197 on package upgrades. systemd-tmpfiles will execute line with an
198 exclamation mark only if option --boot is given.
199
200 For example:
201
202 # Make sure these are created by default so that nobody else can
203 d /tmp/.X11-unix 1777 root root 10d
204
205 # Unlink the X11 lock files
206 r! /tmp/.X[0-9]*-lock
207
208 The second line in contrast to the first one would break a running
209 system, and will only be executed with --boot.
210
211 Path
212 The file system path specification supports simple specifier expansion.
213 The following expansions are understood:
214
215 Table 1. Specifiers available
216 ┌──────────┬────────────────┬─────────────────────┐
217 │Specifier │ Meaning │ Details │
218 ├──────────┼────────────────┼─────────────────────┤
219 │"%m" │ Machine ID │ The machine ID of │
220 │ │ │ the running system, │
221 │ │ │ formatted as │
222 │ │ │ string. See │
223 │ │ │ machine-id(5) for │
224 │ │ │ more information. │
225 ├──────────┼────────────────┼─────────────────────┤
226 │"%b" │ Boot ID │ The boot ID of the │
227 │ │ │ running system, │
228 │ │ │ formatted as │
229 │ │ │ string. See │
230 │ │ │ random(4) for more │
231 │ │ │ information. │
232 ├──────────┼────────────────┼─────────────────────┤
233 │"%H" │ Host name │ The hostname of the │
234 │ │ │ running system. │
235 ├──────────┼────────────────┼─────────────────────┤
236 │"%v" │ Kernel release │ Identical to uname │
237 │ │ │ -r output. │
238 ├──────────┼────────────────┼─────────────────────┤
239 │"%%" │ Escaped % │ Single percent │
240 │ │ │ sign. │
241 └──────────┴────────────────┴─────────────────────┘
242
243 Mode
244 The file access mode to use when creating this file or directory. If
245 omitted or when set to "-", the default is used: 0755 for directories,
246 0644 for all other file objects. For z, Z lines, if omitted or when set
247 to "-", the file access mode will not be modified. This parameter is
248 ignored for x, r, R, L, t, and a lines.
249
250 Optionally, if prefixed with "~", the access mode is masked based on
251 the already set access bits for existing file or directories: if the
252 existing file has all executable bits unset, all executable bits are
253 removed from the new access mode, too. Similarly, if all read bits are
254 removed from the old access mode, they will be removed from the new
255 access mode too, and if all write bits are removed, they will be
256 removed from the new access mode too. In addition, the sticky/SUID/SGID
257 bit is removed unless applied to a directory. This functionality is
258 particularly useful in conjunction with Z.
259
260 UID, GID
261 The user and group to use for this file or directory. This may either
262 be a numeric user/group ID or a user or group name. If omitted or when
263 set to "-", the default 0 (root) is used. For z, Z lines, when omitted
264 or when set to "-", the file ownership will not be modified. These
265 parameters are ignored for x, r, R, L, t, and a lines.
266
267 Age
268 The date field, when set, is used to decide what files to delete when
269 cleaning. If a file or directory is older than the current time minus
270 the age field, it is deleted. The field format is a series of integers
271 each followed by one of the following postfixes for the respective time
272 units: s, m or min, h, d, w, ms, us, respectively meaning seconds,
273 minutes, hours, days, weeks, milliseconds, and microseconds. Full names
274 of the time units can be used too.
275
276 If multiple integers and units are specified, the time values are
277 summed. If an integer is given without a unit, s is assumed.
278
279 When the age is set to zero, the files are cleaned unconditionally.
280
281 The age field only applies to lines starting with d, D, e and x. If
282 omitted or set to "-", no automatic clean-up is done.
283
284 If the age field starts with a tilde character "~", the clean-up is
285 only applied to files and directories one level inside the directory
286 specified, but not the files and directories immediately inside it.
287
288 Argument
289 For L lines determines the destination path of the symlink. For c, b
290 determines the major/minor of the device node, with major and minor
291 formatted as integers, separated by ":", e.g. "1:3". For f, F, and w
292 may be used to specify a short string that is written to the file,
293 suffixed by a newline. For C, specifies the source file or directory.
294 For t determines extended attributes to be set. For a determines ACL
295 attributes to be set. Ignored for all other lines.
296
298 Example 1. /etc/tmpfiles.d/screen.conf example
299
300 screen needs two directories created at boot with specific modes and
301 ownership.
302
303 d /run/screens 1777 root root 10d
304 d /run/uscreens 0755 root root 10d12h
305 t /run/screen - - - - user.name="John Smith" security.SMACK64=screen
306
307 Example 2. /etc/tmpfiles.d/abrt.conf example
308
309 abrt needs a directory created at boot with specific mode and ownership
310 and its content should be preserved.
311
312 d /var/tmp/abrt 0755 abrt abrt
313 x /var/tmp/abrt/*
314
316 systemd(1), systemd-tmpfiles(8), systemd-delta(1), systemd.exec(5),
317 attr(5), getfattr(1), setfattr(1), setfacl(1), getfacl(1)
318
319
320
321systemd 219 TMPFILES.D(5)