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