]>
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 | |
76 | place communication sockets and similar in. For these | |
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 | |
112 | all other conflicting entries logged as errors.</para> | |
6110885c KS |
113 | |
114 | <para>If the administrator wants to disable a | |
79640424 | 115 | configuration file supplied by the vendor, the |
6110885c KS |
116 | recommended way is to place a symlink to |
117 | <filename>/dev/null</filename> in | |
118 | <filename>/etc/tmpfiles.d/</filename> bearing the | |
e9dd9f95 | 119 | same filename.</para> |
772f8371 | 120 | |
0e25e94e | 121 | <para>The configuration format is one line per path |
ef72c1f0 | 122 | containing type, path, mode, ownership, age, and argument |
0e25e94e | 123 | fields:</para> |
aeee2322 | 124 | |
ef72c1f0 | 125 | <programlisting>#Type Path Mode UID GID Age Argument |
468d726b LP |
126 | d /run/user 0755 root root 10d - |
127 | L /tmp/foobar - - - - /dev/null</programlisting> | |
aeee2322 LP |
128 | |
129 | <refsect2> | |
88aebb62 | 130 | <title>Type</title> |
1731e34a | 131 | |
c4708f13 ZJS |
132 | <para>The type consists of a single letter and |
133 | optionally an exclamation mark.</para> | |
134 | ||
1731e34a LP |
135 | <para>The following line types are understood:</para> |
136 | ||
aeee2322 LP |
137 | <variablelist> |
138 | <varlistentry> | |
139 | <term><varname>f</varname></term> | |
ef72c1f0 | 140 | <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 |
141 | </varlistentry> |
142 | ||
143 | <varlistentry> | |
144 | <term><varname>F</varname></term> | |
ef72c1f0 | 145 | <listitem><para>Create or truncate a file. If the argument parameter is given, it will be written to the file.</para></listitem> |
31ed59c5 LP |
146 | </varlistentry> |
147 | ||
148 | <varlistentry> | |
149 | <term><varname>w</varname></term> | |
54693d9b DR |
150 | <listitem><para>Write the argument parameter to a file, if the file exists. |
151 | Lines of this type accept shell-style globs in place of normal path | |
152 | names. The argument parameter will be written without a trailing | |
153 | newline. C-style backslash escapes are interpreted.</para></listitem> | |
aeee2322 LP |
154 | </varlistentry> |
155 | ||
156 | <varlistentry> | |
157 | <term><varname>d</varname></term> | |
ef72c1f0 | 158 | <listitem><para>Create a directory if it does not exist yet.</para></listitem> |
aeee2322 LP |
159 | </varlistentry> |
160 | ||
161 | <varlistentry> | |
162 | <term><varname>D</varname></term> | |
ef72c1f0 | 163 | <listitem><para>Create or empty a directory.</para></listitem> |
aeee2322 LP |
164 | </varlistentry> |
165 | ||
ee17ee7c LP |
166 | <varlistentry> |
167 | <term><varname>p</varname></term> | |
ef72c1f0 | 168 | <listitem><para>Create a named pipe (FIFO) if it does not exist yet.</para></listitem> |
ee17ee7c LP |
169 | </varlistentry> |
170 | ||
468d726b LP |
171 | <varlistentry> |
172 | <term><varname>L</varname></term> | |
ef72c1f0 | 173 | <listitem><para>Create a symlink if it does not exist yet.</para></listitem> |
468d726b LP |
174 | </varlistentry> |
175 | ||
176 | <varlistentry> | |
177 | <term><varname>c</varname></term> | |
ef72c1f0 | 178 | <listitem><para>Create a character device node if it does not exist yet.</para></listitem> |
468d726b LP |
179 | </varlistentry> |
180 | ||
181 | <varlistentry> | |
182 | <term><varname>b</varname></term> | |
ef72c1f0 | 183 | <listitem><para>Create a block device node if it does not exist yet.</para></listitem> |
468d726b LP |
184 | </varlistentry> |
185 | ||
265ffa1e LP |
186 | <varlistentry> |
187 | <term><varname>m</varname></term> | |
188 | <listitem><para>If the | |
72f4d966 | 189 | specified file path exists, |
265ffa1e LP |
190 | adjust its access mode, group |
191 | and user to the specified | |
192 | values and reset the SELinux | |
82adf6af | 193 | security context. If it does not exist, do |
265ffa1e LP |
194 | nothing.</para></listitem> |
195 | </varlistentry> | |
196 | ||
aeee2322 LP |
197 | <varlistentry> |
198 | <term><varname>x</varname></term> | |
b8bb3e8f LP |
199 | <listitem><para>Ignore a path |
200 | during cleaning. Use this type | |
201 | to exclude paths from clean-up | |
202 | as controlled with the Age | |
203 | parameter. Note that lines of | |
204 | this type do not influence the | |
ef72c1f0 ZJS |
205 | effect of <varname>r</varname> |
206 | or <varname>R</varname> lines. | |
207 | Lines of this type accept | |
b8bb3e8f | 208 | shell-style globs in place of |
ef72c1f0 ZJS |
209 | normal path names. |
210 | </para></listitem> | |
aeee2322 LP |
211 | </varlistentry> |
212 | ||
78a92a5a MS |
213 | <varlistentry> |
214 | <term><varname>X</varname></term> | |
215 | <listitem><para>Ignore a path | |
e776c8cf VP |
216 | during cleaning. Use this type |
217 | to exclude paths from clean-up | |
218 | as controlled with the Age | |
ef72c1f0 ZJS |
219 | parameter. Unlike |
220 | <varname>x</varname>, this | |
e776c8cf | 221 | parameter will not exclude the |
ef72c1f0 ZJS |
222 | content if path is a |
223 | directory, but only directory | |
224 | itself. Note that lines of | |
225 | this type do not influence the | |
226 | effect of <varname>r</varname> | |
227 | or <varname>R</varname> lines. | |
228 | Lines of this type accept | |
229 | shell-style globs in place of | |
230 | normal path names. | |
231 | </para></listitem> | |
78a92a5a MS |
232 | </varlistentry> |
233 | ||
aeee2322 LP |
234 | <varlistentry> |
235 | <term><varname>r</varname></term> | |
b8bb3e8f | 236 | <listitem><para>Remove a file |
ef72c1f0 ZJS |
237 | or directory if it exists. |
238 | This may not be used to remove | |
239 | non-empty directories, use | |
240 | <varname>R</varname> for that. | |
241 | Lines of this type accept | |
242 | shell-style globs in place of | |
243 | normal path | |
b8bb3e8f | 244 | names.</para></listitem> |
aeee2322 LP |
245 | </varlistentry> |
246 | ||
247 | <varlistentry> | |
248 | <term><varname>R</varname></term> | |
b8bb3e8f LP |
249 | <listitem><para>Recursively |
250 | remove a path and all its | |
251 | subdirectories (if it is a | |
252 | directory). Lines of this type | |
253 | accept shell-style globs in | |
254 | place of normal path | |
255 | names.</para></listitem> | |
aeee2322 | 256 | </varlistentry> |
462d63db | 257 | |
777b87e7 MS |
258 | <varlistentry> |
259 | <term><varname>z</varname></term> | |
669e49fe | 260 | <listitem><para>Restore |
82adf6af | 261 | SELinux security context |
669e49fe LP |
262 | and set ownership and access |
263 | mode of a file or directory if | |
264 | it exists. Lines of this type | |
265 | accept shell-style globs in | |
266 | place of normal path names. | |
777b87e7 MS |
267 | </para></listitem> |
268 | </varlistentry> | |
269 | ||
462d63db MS |
270 | <varlistentry> |
271 | <term><varname>Z</varname></term> | |
669e49fe LP |
272 | <listitem><para>Recursively |
273 | restore SELinux security | |
82adf6af | 274 | context and set |
669e49fe LP |
275 | ownership and access mode of a |
276 | path and all its | |
277 | subdirectories (if it is a | |
278 | directory). Lines of this type | |
279 | accept shell-style globs in | |
280 | place of normal path | |
281 | names.</para></listitem> | |
462d63db | 282 | </varlistentry> |
aeee2322 | 283 | </variablelist> |
c4708f13 ZJS |
284 | |
285 | <para>If the exclamation mark is used, this | |
286 | line is only safe of execute during boot, and | |
287 | can break a running system. Lines without the | |
288 | exclamation mark are presumed to be safe to | |
289 | execute at any time, e.g. on package upgrades. | |
290 | <command>systemd-tmpfiles</command> will | |
291 | execute line with an exclamation mark only if | |
81815651 | 292 | option <option>--boot</option> is given. |
c4708f13 ZJS |
293 | </para> |
294 | ||
295 | <para>For example: | |
9fccdb0f | 296 | <programlisting># Make sure these are created by default so that nobody else can |
c4708f13 ZJS |
297 | d /tmp/.X11-unix 1777 root root 10d |
298 | ||
299 | # Unlink the X11 lock files | |
9fccdb0f | 300 | r! /tmp/.X[0-9]*-lock</programlisting> |
c4708f13 ZJS |
301 | The second line in contrast to the first one |
302 | would break a running system, and will only be | |
81815651 | 303 | executed with <option>--boot</option>.</para> |
aeee2322 LP |
304 | </refsect2> |
305 | ||
1731e34a LP |
306 | <refsect2> |
307 | <title>Path</title> | |
308 | ||
309 | <para>The file system path specification supports simple specifier | |
310 | expansion. The following expansions are | |
311 | understood:</para> | |
312 | ||
313 | <table> | |
314 | <title>Specifiers available</title> | |
315 | <tgroup cols='3' align='left' colsep='1' rowsep='1'> | |
316 | <colspec colname="spec" /> | |
317 | <colspec colname="mean" /> | |
318 | <colspec colname="detail" /> | |
319 | <thead> | |
320 | <row> | |
321 | <entry>Specifier</entry> | |
322 | <entry>Meaning</entry> | |
323 | <entry>Details</entry> | |
324 | </row> | |
325 | </thead> | |
326 | <tbody> | |
327 | <row> | |
328 | <entry><literal>%m</literal></entry> | |
329 | <entry>Machine ID</entry> | |
330 | <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> | |
331 | </row> | |
332 | <row> | |
333 | <entry><literal>%b</literal></entry> | |
334 | <entry>Boot ID</entry> | |
335 | <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry> | |
336 | </row> | |
337 | <row> | |
338 | <entry><literal>%H</literal></entry> | |
339 | <entry>Host name</entry> | |
340 | <entry>The hostname of the running system.</entry> | |
341 | </row> | |
342 | <row> | |
343 | <entry><literal>%v</literal></entry> | |
344 | <entry>Kernel release</entry> | |
345 | <entry>Identical to <command>uname -r</command> output.</entry> | |
346 | </row> | |
347 | <row> | |
348 | <entry><literal>%%</literal></entry> | |
349 | <entry>Escaped %</entry> | |
350 | <entry>Single percent sign.</entry> | |
351 | </row> | |
352 | </tbody> | |
353 | </tgroup> | |
354 | </table> | |
355 | </refsect2> | |
356 | ||
aeee2322 | 357 | <refsect2> |
88aebb62 LP |
358 | <title>Mode</title> |
359 | ||
b8bb3e8f LP |
360 | <para>The file access mode to use when |
361 | creating this file or directory. If omitted or | |
79640424 | 362 | when set to -, the default is used: 0755 for |
ef72c1f0 ZJS |
363 | directories, 0644 for all other file objects. |
364 | For <varname>z</varname>, <varname>Z</varname> | |
365 | lines, if omitted or when set to | |
366 | <literal>-</literal>, the file access mode | |
367 | will not be modified. This parameter is | |
368 | ignored for <varname>x</varname>, | |
369 | <varname>r</varname>, <varname>R</varname>, | |
370 | <varname>L</varname> lines.</para> | |
88aebb62 LP |
371 | </refsect2> |
372 | ||
373 | <refsect2> | |
374 | <title>UID, GID</title> | |
375 | ||
376 | <para>The user and group to use for this file | |
377 | or directory. This may either be a numeric | |
378 | user/group ID or a user or group name. If | |
ef72c1f0 ZJS |
379 | omitted or when set to <literal>-</literal>, |
380 | the default 0 (root) is used. For | |
381 | <varname>z</varname>, <varname>Z</varname> | |
382 | lines, when omitted or when set to -, the file | |
383 | ownership will not be modified. These | |
384 | parameters are ignored for | |
385 | <varname>x</varname>, <varname>r</varname>, | |
386 | <varname>R</varname>, <varname>L</varname> | |
387 | lines.</para> | |
88aebb62 LP |
388 | </refsect2> |
389 | ||
390 | <refsect2> | |
391 | <title>Age</title> | |
aeee2322 LP |
392 | <para>The date field, when set, is used to |
393 | decide what files to delete when cleaning. If | |
394 | a file or directory is older than the current | |
79640424 | 395 | time minus the age field, it is deleted. The |
aeee2322 LP |
396 | field format is a series of integers each |
397 | followed by one of the following | |
398 | postfixes for the respective time units:</para> | |
399 | ||
400 | <variablelist> | |
401 | <varlistentry> | |
402 | <term><varname>s</varname></term> | |
403 | <term><varname>min</varname></term> | |
404 | <term><varname>h</varname></term> | |
405 | <term><varname>d</varname></term> | |
406 | <term><varname>w</varname></term> | |
407 | <term><varname>ms</varname></term> | |
408 | <term><varname>m</varname></term> | |
409 | <term><varname>us</varname></term></varlistentry> | |
410 | </variablelist> | |
4149f86d | 411 | |
79640424 | 412 | <para>If multiple integers and units are specified, the time |
ef44ed4e | 413 | values are summed up. If an integer is given without a unit, |
a2558205 TG |
414 | s is assumed. |
415 | </para> | |
416 | ||
417 | <para>When the age is set to zero, the files are cleaned | |
418 | unconditionally.</para> | |
4149f86d | 419 | |
ef72c1f0 ZJS |
420 | <para>The age field only applies to lines |
421 | starting with <varname>d</varname>, | |
422 | <varname>D</varname>, and | |
423 | <varname>x</varname>. If omitted or set to | |
424 | <literal>-</literal>, no automatic clean-up is | |
425 | done.</para> | |
24f3a374 LP |
426 | |
427 | <para>If the age field starts with a tilde | |
ef72c1f0 ZJS |
428 | character <literal>~</literal>, the clean-up |
429 | is only applied to files and directories one | |
430 | level inside the directory specified, but not | |
431 | the files and directories immediately inside | |
432 | it.</para> | |
aeee2322 | 433 | </refsect2> |
4149f86d | 434 | |
468d726b LP |
435 | <refsect2> |
436 | <title>Argument</title> | |
437 | ||
ef72c1f0 ZJS |
438 | <para>For <varname>L</varname> lines |
439 | determines the destination path of the | |
440 | symlink. For <varname>c</varname>, | |
441 | <varname>b</varname> determines the | |
468d726b | 442 | major/minor of the device node, with major and |
ef72c1f0 ZJS |
443 | minor formatted as integers, separated by |
444 | <literal>:</literal>, e.g. | |
445 | <literal>1:3</literal>. For | |
446 | <varname>f</varname>, <varname>F</varname>, | |
447 | and <varname>w</varname> may be used to | |
448 | specify a short string that is written to the | |
449 | file, suffixed by a newline. Ignored for all | |
450 | other lines.</para> | |
468d726b LP |
451 | </refsect2> |
452 | ||
4149f86d BP |
453 | </refsect1> |
454 | ||
455 | <refsect1> | |
456 | <title>Example</title> | |
457 | <example> | |
458 | <title>/etc/tmpfiles.d/screen.conf example</title> | |
459 | <para><command>screen</command> needs two directories created at boot with specific modes and ownership.</para> | |
460 | ||
41a55c46 ZJS |
461 | <programlisting>d /run/screens 1777 root root 10d |
462 | d /run/uscreens 0755 root root 10d12h</programlisting> | |
4149f86d | 463 | </example> |
1e444481 LN |
464 | <example> |
465 | <title>/etc/tmpfiles.d/abrt.conf example</title> | |
466 | <para><command>abrt</command> needs a directory created at boot with specific mode and ownership and its content should be preserved.</para> | |
467 | ||
468 | <programlisting>d /var/tmp/abrt 0755 abrt abrt | |
469 | x /var/tmp/abrt/*</programlisting> | |
470 | </example> | |
4149f86d BP |
471 | </refsect1> |
472 | ||
473 | <refsect1> | |
474 | <title>See Also</title> | |
475 | <para> | |
522d4a49 | 476 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
75945bad | 477 | <citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
e66cf1a3 LP |
478 | <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
479 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
4149f86d BP |
480 | </para> |
481 | </refsect1> | |
482 | ||
483 | </refentry> |