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