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