]>
Commit | Line | Data |
---|---|---|
4149f86d BP |
1 | <?xml version="1.0"?> |
2 | <!--*-nxml-*--> | |
3 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
4 | <!-- | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2010 Brandon Philips | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
10 | under the terms of the GNU Lesser General Public License as published by |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
4149f86d BP |
12 | (at your option) any later version. |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 17 | Lesser General Public License for more details. |
4149f86d | 18 | |
5430f7f2 | 19 | You should have received a copy of the GNU Lesser General Public License |
4149f86d BP |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
21 | --> | |
22 | <refentry id="tmpfiles.d"> | |
23 | ||
24 | <refentryinfo> | |
25 | <title>tmpfiles.d</title> | |
26 | <productname>systemd</productname> | |
27 | ||
28 | <authorgroup> | |
29 | <author> | |
30 | <contrib>Documentation</contrib> | |
31 | <firstname>Brandon</firstname> | |
32 | <surname>Philips</surname> | |
33 | <email>brandon@ifup.org</email> | |
34 | </author> | |
35 | </authorgroup> | |
36 | </refentryinfo> | |
37 | ||
38 | <refmeta> | |
39 | <refentrytitle>tmpfiles.d</refentrytitle> | |
40 | <manvolnum>5</manvolnum> | |
41 | </refmeta> | |
42 | ||
43 | <refnamediv> | |
44 | <refname>tmpfiles.d</refname> | |
522d4a49 LP |
45 | <refpurpose>Configuration for creation, deletion and |
46 | cleaning of volatile and temporary files</refpurpose> | |
4149f86d BP |
47 | </refnamediv> |
48 | ||
a7c64469 LP |
49 | <refsynopsisdiv> |
50 | <para><filename>/etc/tmpfiles.d/*.conf</filename></para> | |
772f8371 | 51 | <para><filename>/run/tmpfiles.d/*.conf</filename></para> |
fc1a2e06 | 52 | <para><filename>/usr/lib/tmpfiles.d/*.conf</filename></para> |
a7c64469 LP |
53 | </refsynopsisdiv> |
54 | ||
4149f86d BP |
55 | <refsect1> |
56 | <title>Description</title> | |
57 | ||
0e25e94e KS |
58 | <para><command>systemd-tmpfiles</command> uses the |
59 | configuration files from the above directories to describe the | |
60 | creation, cleaning and removal of volatile and | |
61 | temporary files and directories which usually reside | |
62 | in directories such as <filename>/run</filename> | |
63 | or <filename>/tmp</filename>.</para> | |
e66cf1a3 LP |
64 | |
65 | <para>Volatile and temporary files and directories are | |
66 | those located in <filename>/run</filename> (and its | |
67 | alias <filename>/var/run</filename>), | |
68 | <filename>/tmp</filename>, | |
69 | <filename>/var/tmp</filename>, the API file systems | |
70 | such as <filename>/sys</filename> or | |
71 | <filename>/proc</filename>, as well as some other | |
72 | directories below <filename>/var</filename>.</para> | |
73 | ||
74 | <para>System daemons frequently require private | |
75 | runtime directories below <filename>/run</filename> to | |
b8bde116 | 76 | place communication sockets and similar in. For these, |
e66cf1a3 LP |
77 | consider declaring them in their unit files using |
78 | <varname>RuntimeDirectory=</varname> | |
79 | (see <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details), | |
80 | if this is feasible.</para> | |
4149f86d BP |
81 | </refsect1> |
82 | ||
83 | <refsect1> | |
0e25e94e | 84 | <title>Configuration Format</title> |
4149f86d | 85 | |
6110885c | 86 | <para>Each configuration file shall be named in the |
ef72c1f0 ZJS |
87 | style of |
88 | <filename><replaceable>package</replaceable>.conf</filename> | |
89 | or | |
90 | <filename><replaceable>package</replaceable>-<replaceable>part</replaceable>.conf</filename>. | |
91 | The second variant should be used when it is desirable | |
92 | to make it easy to override just this part of | |
93 | configuration.</para> | |
94 | ||
95 | <para>Files in <filename>/etc/tmpfiles.d</filename> | |
96 | override files with the same name in | |
97 | <filename>/usr/lib/tmpfiles.d</filename> and | |
98 | <filename>/run/tmpfiles.d</filename>. Files in | |
99 | <filename>/run/tmpfiles.d</filename> override files | |
100 | with the same name in | |
101 | <filename>/usr/lib/tmpfiles.d</filename>. Packages | |
6110885c | 102 | should install their configuration files in |
ef72c1f0 ZJS |
103 | <filename>/usr/lib/tmpfiles.d</filename>. Files in |
104 | <filename>/etc/tmpfiles.d</filename> are reserved for | |
105 | the local administrator, who may use this logic to | |
106 | override the configuration files installed by vendor | |
107 | packages. All configuration files are sorted by their | |
494a6682 JE |
108 | filename in lexicographic order, regardless of which |
109 | of the directories they reside in. If multiple files | |
ef72c1f0 ZJS |
110 | specify the same path, the entry in the file with the |
111 | lexicographically earliest name will be applied, all | |
1910cd0e LP |
112 | all other conflicting entries will be logged as |
113 | errors. When two lines are prefix and suffix of each | |
114 | other, then the prefix is always processed first, the | |
115 | suffix later. Otherwise the files/directories are | |
116 | processed in the order they are listed.</para> | |
6110885c KS |
117 | |
118 | <para>If the administrator wants to disable a | |
79640424 | 119 | configuration file supplied by the vendor, the |
6110885c KS |
120 | recommended way is to place a symlink to |
121 | <filename>/dev/null</filename> in | |
122 | <filename>/etc/tmpfiles.d/</filename> bearing the | |
e9dd9f95 | 123 | same filename.</para> |
772f8371 | 124 | |
0e25e94e | 125 | <para>The configuration format is one line per path |
ef72c1f0 | 126 | containing type, path, mode, ownership, age, and argument |
0e25e94e | 127 | fields:</para> |
aeee2322 | 128 | |
ef72c1f0 | 129 | <programlisting>#Type Path Mode UID GID Age Argument |
468d726b LP |
130 | d /run/user 0755 root root 10d - |
131 | L /tmp/foobar - - - - /dev/null</programlisting> | |
aeee2322 LP |
132 | |
133 | <refsect2> | |
88aebb62 | 134 | <title>Type</title> |
1731e34a | 135 | |
c4708f13 ZJS |
136 | <para>The type consists of a single letter and |
137 | optionally an exclamation mark.</para> | |
138 | ||
1731e34a LP |
139 | <para>The following line types are understood:</para> |
140 | ||
aeee2322 LP |
141 | <variablelist> |
142 | <varlistentry> | |
143 | <term><varname>f</varname></term> | |
ef72c1f0 | 144 | <listitem><para>Create a file if it does not exist yet. If the argument parameter is given, it will be written to the file.</para></listitem> |
aeee2322 LP |
145 | </varlistentry> |
146 | ||
147 | <varlistentry> | |
148 | <term><varname>F</varname></term> | |
ef72c1f0 | 149 | <listitem><para>Create or truncate a file. If the argument parameter is given, it will be written to the file.</para></listitem> |
31ed59c5 LP |
150 | </varlistentry> |
151 | ||
152 | <varlistentry> | |
153 | <term><varname>w</varname></term> | |
54693d9b DR |
154 | <listitem><para>Write the argument parameter to a file, if the file exists. |
155 | Lines of this type accept shell-style globs in place of normal path | |
156 | names. The argument parameter will be written without a trailing | |
157 | newline. C-style backslash escapes are interpreted.</para></listitem> | |
aeee2322 LP |
158 | </varlistentry> |
159 | ||
160 | <varlistentry> | |
161 | <term><varname>d</varname></term> | |
ef72c1f0 | 162 | <listitem><para>Create a directory if it does not exist yet.</para></listitem> |
aeee2322 LP |
163 | </varlistentry> |
164 | ||
165 | <varlistentry> | |
166 | <term><varname>D</varname></term> | |
ef72c1f0 | 167 | <listitem><para>Create or empty a directory.</para></listitem> |
aeee2322 LP |
168 | </varlistentry> |
169 | ||
ee17ee7c LP |
170 | <varlistentry> |
171 | <term><varname>p</varname></term> | |
ef72c1f0 | 172 | <listitem><para>Create a named pipe (FIFO) if it does not exist yet.</para></listitem> |
ee17ee7c LP |
173 | </varlistentry> |
174 | ||
468d726b LP |
175 | <varlistentry> |
176 | <term><varname>L</varname></term> | |
2e78fa79 LP |
177 | <term><varname>L+</varname></term> |
178 | <listitem><para>Create a | |
179 | symlink if it does not exist | |
180 | yet. If suffixed with | |
181 | <varname>+</varname> and a | |
182 | file already exists where the | |
183 | symlink is to be created it | |
184 | will be removed and be | |
185 | replaced by the | |
186 | symlink.</para></listitem> | |
468d726b LP |
187 | </varlistentry> |
188 | ||
189 | <varlistentry> | |
190 | <term><varname>c</varname></term> | |
ef72c1f0 | 191 | <listitem><para>Create a character device node if it does not exist yet.</para></listitem> |
468d726b LP |
192 | </varlistentry> |
193 | ||
194 | <varlistentry> | |
195 | <term><varname>b</varname></term> | |
ef72c1f0 | 196 | <listitem><para>Create a block device node if it does not exist yet.</para></listitem> |
468d726b LP |
197 | </varlistentry> |
198 | ||
849958d1 LP |
199 | <varlistentry> |
200 | <term><varname>C</varname></term> | |
201 | <listitem><para>Recursively copy a file or directory, if the destination files or directories don't exist yet.</para></listitem> | |
202 | </varlistentry> | |
203 | ||
aeee2322 LP |
204 | <varlistentry> |
205 | <term><varname>x</varname></term> | |
b8bb3e8f LP |
206 | <listitem><para>Ignore a path |
207 | during cleaning. Use this type | |
208 | to exclude paths from clean-up | |
209 | as controlled with the Age | |
210 | parameter. Note that lines of | |
211 | this type do not influence the | |
ef72c1f0 ZJS |
212 | effect of <varname>r</varname> |
213 | or <varname>R</varname> lines. | |
214 | Lines of this type accept | |
b8bb3e8f | 215 | shell-style globs in place of |
ef72c1f0 ZJS |
216 | normal path names. |
217 | </para></listitem> | |
aeee2322 LP |
218 | </varlistentry> |
219 | ||
78a92a5a MS |
220 | <varlistentry> |
221 | <term><varname>X</varname></term> | |
222 | <listitem><para>Ignore a path | |
e776c8cf VP |
223 | during cleaning. Use this type |
224 | to exclude paths from clean-up | |
225 | as controlled with the Age | |
ef72c1f0 ZJS |
226 | parameter. Unlike |
227 | <varname>x</varname>, this | |
e776c8cf | 228 | parameter will not exclude the |
ef72c1f0 ZJS |
229 | content if path is a |
230 | directory, but only directory | |
231 | itself. Note that lines of | |
232 | this type do not influence the | |
233 | effect of <varname>r</varname> | |
234 | or <varname>R</varname> lines. | |
235 | Lines of this type accept | |
236 | shell-style globs in place of | |
237 | normal path names. | |
238 | </para></listitem> | |
78a92a5a MS |
239 | </varlistentry> |
240 | ||
aeee2322 LP |
241 | <varlistentry> |
242 | <term><varname>r</varname></term> | |
b8bb3e8f | 243 | <listitem><para>Remove a file |
ef72c1f0 ZJS |
244 | or directory if it exists. |
245 | This may not be used to remove | |
246 | non-empty directories, use | |
247 | <varname>R</varname> for that. | |
248 | Lines of this type accept | |
249 | shell-style globs in place of | |
250 | normal path | |
b8bb3e8f | 251 | names.</para></listitem> |
aeee2322 LP |
252 | </varlistentry> |
253 | ||
254 | <varlistentry> | |
255 | <term><varname>R</varname></term> | |
b8bb3e8f LP |
256 | <listitem><para>Recursively |
257 | remove a path and all its | |
258 | subdirectories (if it is a | |
259 | directory). Lines of this type | |
260 | accept shell-style globs in | |
261 | place of normal path | |
262 | names.</para></listitem> | |
aeee2322 | 263 | </varlistentry> |
462d63db | 264 | |
777b87e7 MS |
265 | <varlistentry> |
266 | <term><varname>z</varname></term> | |
e73a03e0 LP |
267 | <listitem><para>Adjust the |
268 | access mode, group and user, | |
269 | and restore the SELinux security | |
270 | context of a file or directory, | |
271 | if it exists. Lines of this | |
272 | type accept shell-style globs | |
273 | in place of normal path names. | |
777b87e7 MS |
274 | </para></listitem> |
275 | </varlistentry> | |
276 | ||
462d63db MS |
277 | <varlistentry> |
278 | <term><varname>Z</varname></term> | |
669e49fe | 279 | <listitem><para>Recursively |
e73a03e0 LP |
280 | set the access mode, group and |
281 | user, and restore the SELinux | |
282 | security context of a file or | |
283 | directory if it exists, as | |
284 | well as of its subdirectories | |
285 | and the files contained | |
286 | therein (if applicable). Lines | |
287 | of this type accept | |
288 | shell-style globs in place of | |
289 | normal path | |
669e49fe | 290 | names.</para></listitem> |
462d63db | 291 | </varlistentry> |
aeee2322 | 292 | </variablelist> |
c4708f13 ZJS |
293 | |
294 | <para>If the exclamation mark is used, this | |
295 | line is only safe of execute during boot, and | |
296 | can break a running system. Lines without the | |
297 | exclamation mark are presumed to be safe to | |
298 | execute at any time, e.g. on package upgrades. | |
299 | <command>systemd-tmpfiles</command> will | |
300 | execute line with an exclamation mark only if | |
81815651 | 301 | option <option>--boot</option> is given. |
c4708f13 ZJS |
302 | </para> |
303 | ||
304 | <para>For example: | |
9fccdb0f | 305 | <programlisting># Make sure these are created by default so that nobody else can |
c4708f13 ZJS |
306 | d /tmp/.X11-unix 1777 root root 10d |
307 | ||
308 | # Unlink the X11 lock files | |
9fccdb0f | 309 | r! /tmp/.X[0-9]*-lock</programlisting> |
c4708f13 ZJS |
310 | The second line in contrast to the first one |
311 | would break a running system, and will only be | |
81815651 | 312 | executed with <option>--boot</option>.</para> |
aeee2322 LP |
313 | </refsect2> |
314 | ||
1731e34a LP |
315 | <refsect2> |
316 | <title>Path</title> | |
317 | ||
318 | <para>The file system path specification supports simple specifier | |
319 | expansion. The following expansions are | |
320 | understood:</para> | |
321 | ||
322 | <table> | |
323 | <title>Specifiers available</title> | |
324 | <tgroup cols='3' align='left' colsep='1' rowsep='1'> | |
325 | <colspec colname="spec" /> | |
326 | <colspec colname="mean" /> | |
327 | <colspec colname="detail" /> | |
328 | <thead> | |
329 | <row> | |
330 | <entry>Specifier</entry> | |
331 | <entry>Meaning</entry> | |
332 | <entry>Details</entry> | |
333 | </row> | |
334 | </thead> | |
335 | <tbody> | |
336 | <row> | |
337 | <entry><literal>%m</literal></entry> | |
338 | <entry>Machine ID</entry> | |
339 | <entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry> | |
340 | </row> | |
341 | <row> | |
342 | <entry><literal>%b</literal></entry> | |
343 | <entry>Boot ID</entry> | |
344 | <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry> | |
345 | </row> | |
346 | <row> | |
347 | <entry><literal>%H</literal></entry> | |
348 | <entry>Host name</entry> | |
349 | <entry>The hostname of the running system.</entry> | |
350 | </row> | |
351 | <row> | |
352 | <entry><literal>%v</literal></entry> | |
353 | <entry>Kernel release</entry> | |
354 | <entry>Identical to <command>uname -r</command> output.</entry> | |
355 | </row> | |
356 | <row> | |
357 | <entry><literal>%%</literal></entry> | |
358 | <entry>Escaped %</entry> | |
359 | <entry>Single percent sign.</entry> | |
360 | </row> | |
361 | </tbody> | |
362 | </tgroup> | |
363 | </table> | |
364 | </refsect2> | |
365 | ||
aeee2322 | 366 | <refsect2> |
88aebb62 LP |
367 | <title>Mode</title> |
368 | ||
b8bb3e8f LP |
369 | <para>The file access mode to use when |
370 | creating this file or directory. If omitted or | |
79640424 | 371 | when set to -, the default is used: 0755 for |
ef72c1f0 ZJS |
372 | directories, 0644 for all other file objects. |
373 | For <varname>z</varname>, <varname>Z</varname> | |
374 | lines, if omitted or when set to | |
375 | <literal>-</literal>, the file access mode | |
376 | will not be modified. This parameter is | |
377 | ignored for <varname>x</varname>, | |
378 | <varname>r</varname>, <varname>R</varname>, | |
379 | <varname>L</varname> lines.</para> | |
abef3f91 LP |
380 | |
381 | <para>Optionally, if prefixed with | |
382 | <literal>~</literal> the access mode is masked | |
383 | based on the already set access bits for | |
384 | existing file or directories: if the existing | |
385 | file has all executable bits unset then all | |
386 | executable bits are removed from the new | |
387 | access mode, too. Similar, if all read bits | |
388 | are removed from the old access mode they will | |
389 | be removed from the new access mode too, and | |
390 | if all write bits are removed, they will be | |
391 | removed from the new access mode too. In | |
392 | addition the sticky/suid/gid bit is removed unless | |
393 | applied to a directory. This | |
394 | functionality is particularly useful in | |
395 | conjunction with <varname>Z</varname>.</para> | |
88aebb62 LP |
396 | </refsect2> |
397 | ||
398 | <refsect2> | |
399 | <title>UID, GID</title> | |
400 | ||
401 | <para>The user and group to use for this file | |
402 | or directory. This may either be a numeric | |
403 | user/group ID or a user or group name. If | |
ef72c1f0 ZJS |
404 | omitted or when set to <literal>-</literal>, |
405 | the default 0 (root) is used. For | |
406 | <varname>z</varname>, <varname>Z</varname> | |
407 | lines, when omitted or when set to -, the file | |
408 | ownership will not be modified. These | |
409 | parameters are ignored for | |
410 | <varname>x</varname>, <varname>r</varname>, | |
411 | <varname>R</varname>, <varname>L</varname> | |
412 | lines.</para> | |
88aebb62 LP |
413 | </refsect2> |
414 | ||
415 | <refsect2> | |
416 | <title>Age</title> | |
aeee2322 LP |
417 | <para>The date field, when set, is used to |
418 | decide what files to delete when cleaning. If | |
419 | a file or directory is older than the current | |
79640424 | 420 | time minus the age field, it is deleted. The |
aeee2322 LP |
421 | field format is a series of integers each |
422 | followed by one of the following | |
423 | postfixes for the respective time units:</para> | |
424 | ||
425 | <variablelist> | |
426 | <varlistentry> | |
427 | <term><varname>s</varname></term> | |
428 | <term><varname>min</varname></term> | |
429 | <term><varname>h</varname></term> | |
430 | <term><varname>d</varname></term> | |
431 | <term><varname>w</varname></term> | |
432 | <term><varname>ms</varname></term> | |
433 | <term><varname>m</varname></term> | |
434 | <term><varname>us</varname></term></varlistentry> | |
435 | </variablelist> | |
4149f86d | 436 | |
79640424 | 437 | <para>If multiple integers and units are specified, the time |
ef44ed4e | 438 | values are summed up. If an integer is given without a unit, |
a2558205 TG |
439 | s is assumed. |
440 | </para> | |
441 | ||
442 | <para>When the age is set to zero, the files are cleaned | |
443 | unconditionally.</para> | |
4149f86d | 444 | |
ef72c1f0 ZJS |
445 | <para>The age field only applies to lines |
446 | starting with <varname>d</varname>, | |
447 | <varname>D</varname>, and | |
448 | <varname>x</varname>. If omitted or set to | |
449 | <literal>-</literal>, no automatic clean-up is | |
450 | done.</para> | |
24f3a374 LP |
451 | |
452 | <para>If the age field starts with a tilde | |
ef72c1f0 ZJS |
453 | character <literal>~</literal>, the clean-up |
454 | is only applied to files and directories one | |
455 | level inside the directory specified, but not | |
456 | the files and directories immediately inside | |
457 | it.</para> | |
aeee2322 | 458 | </refsect2> |
4149f86d | 459 | |
468d726b LP |
460 | <refsect2> |
461 | <title>Argument</title> | |
462 | ||
ef72c1f0 ZJS |
463 | <para>For <varname>L</varname> lines |
464 | determines the destination path of the | |
465 | symlink. For <varname>c</varname>, | |
466 | <varname>b</varname> determines the | |
468d726b | 467 | major/minor of the device node, with major and |
ef72c1f0 ZJS |
468 | minor formatted as integers, separated by |
469 | <literal>:</literal>, e.g. | |
470 | <literal>1:3</literal>. For | |
471 | <varname>f</varname>, <varname>F</varname>, | |
472 | and <varname>w</varname> may be used to | |
473 | specify a short string that is written to the | |
849958d1 LP |
474 | file, suffixed by a newline. For |
475 | <varname>C</varname> specifies the source file | |
476 | or directory. Ignored for all other | |
477 | lines.</para> | |
468d726b LP |
478 | </refsect2> |
479 | ||
4149f86d BP |
480 | </refsect1> |
481 | ||
482 | <refsect1> | |
483 | <title>Example</title> | |
484 | <example> | |
485 | <title>/etc/tmpfiles.d/screen.conf example</title> | |
486 | <para><command>screen</command> needs two directories created at boot with specific modes and ownership.</para> | |
487 | ||
41a55c46 ZJS |
488 | <programlisting>d /run/screens 1777 root root 10d |
489 | d /run/uscreens 0755 root root 10d12h</programlisting> | |
4149f86d | 490 | </example> |
1e444481 LN |
491 | <example> |
492 | <title>/etc/tmpfiles.d/abrt.conf example</title> | |
493 | <para><command>abrt</command> needs a directory created at boot with specific mode and ownership and its content should be preserved.</para> | |
494 | ||
495 | <programlisting>d /var/tmp/abrt 0755 abrt abrt | |
496 | x /var/tmp/abrt/*</programlisting> | |
497 | </example> | |
4149f86d BP |
498 | </refsect1> |
499 | ||
500 | <refsect1> | |
501 | <title>See Also</title> | |
502 | <para> | |
522d4a49 | 503 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
75945bad | 504 | <citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
e66cf1a3 LP |
505 | <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
506 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
4149f86d BP |
507 | </para> |
508 | </refsect1> | |
509 | ||
510 | </refentry> |