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