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