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