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