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