chiark / gitweb /
udev: util - use log_level_from_string()
[elogind.git] / man / tmpfiles.d.xml
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
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
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
17   Lesser General Public License for more details.
18
19   You should have received a copy of the GNU Lesser General Public License
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>
45                 <refpurpose>Configuration for creation, deletion and
46                 cleaning of volatile and temporary files</refpurpose>
47         </refnamediv>
48
49         <refsynopsisdiv>
50                 <para><filename>/etc/tmpfiles.d/*.conf</filename></para>
51                 <para><filename>/run/tmpfiles.d/*.conf</filename></para>
52                 <para><filename>/usr/lib/tmpfiles.d/*.conf</filename></para>
53         </refsynopsisdiv>
54
55         <refsect1>
56                 <title>Description</title>
57
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>
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>
81         </refsect1>
82
83         <refsect1>
84                 <title>Configuration Format</title>
85
86                 <para>Each configuration file shall be named in the
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
102                 should install their configuration files in
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
108                 filename in lexicographic order, regardless of which
109                 of the directories they reside in. If multiple files
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 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>
117
118                 <para>If the administrator wants to disable a
119                 configuration file supplied by the vendor, the
120                 recommended way is to place a symlink to
121                 <filename>/dev/null</filename> in
122                 <filename>/etc/tmpfiles.d/</filename> bearing the
123                 same filename.</para>
124
125                 <para>The configuration format is one line per path
126                 containing type, path, mode, ownership, age, and argument
127                 fields:</para>
128
129                 <programlisting>#Type Path        Mode UID  GID  Age Argument
130 d    /run/user   0755 root root 10d -
131 L    /tmp/foobar -    -    -    -   /dev/null</programlisting>
132
133                 <refsect2>
134                         <title>Type</title>
135
136                         <para>The type consists of a single letter and
137                         optionally an exclamation mark.</para>
138
139                         <para>The following line types are understood:</para>
140
141                         <variablelist>
142                                 <varlistentry>
143                                         <term><varname>f</varname></term>
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>
145                                 </varlistentry>
146
147                                 <varlistentry>
148                                         <term><varname>F</varname></term>
149                                         <listitem><para>Create or truncate a file. If the argument parameter is given, it will be written to the file.</para></listitem>
150                                 </varlistentry>
151
152                                 <varlistentry>
153                                         <term><varname>w</varname></term>
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>
158                                 </varlistentry>
159
160                                 <varlistentry>
161                                         <term><varname>d</varname></term>
162                                         <listitem><para>Create a directory if it does not exist yet.</para></listitem>
163                                 </varlistentry>
164
165                                 <varlistentry>
166                                         <term><varname>D</varname></term>
167                                         <listitem><para>Create or empty a directory.</para></listitem>
168                                 </varlistentry>
169
170                                 <varlistentry>
171                                         <term><varname>p</varname></term>
172                                         <term><varname>p+</varname></term>
173                                         <listitem><para>Create a named
174                                         pipe (FIFO) if it does not
175                                         exist yet. If suffixed with
176                                         <varname>+</varname> and a
177                                         file already exists where the
178                                         pipe is to be created, it will
179                                         be removed and be replaced by
180                                         the pipe.</para></listitem>
181                                 </varlistentry>
182
183                                 <varlistentry>
184                                         <term><varname>L</varname></term>
185                                         <term><varname>L+</varname></term>
186                                         <listitem><para>Create a
187                                         symlink if it does not exist
188                                         yet. If suffixed with
189                                         <varname>+</varname> and a
190                                         file already exists where the
191                                         symlink is to be created, it
192                                         will be removed and be
193                                         replaced by the
194                                         symlink. If the argument is omitted,
195                                         symlinks to files with the same name
196                                         residing in the directory
197                                         <filename>/usr/share/factory/</filename>
198                                         are created.</para></listitem>
199                                 </varlistentry>
200
201                                 <varlistentry>
202                                         <term><varname>c</varname></term>
203                                         <term><varname>c+</varname></term>
204                                         <listitem><para>Create a
205                                         character device node if it
206                                         does not exist yet. If
207                                         suffixed with
208                                         <varname>+</varname> and a
209                                         file already exists where the
210                                         device node is to be created,
211                                         it will be removed and be
212                                         replaced by the device
213                                         node.</para></listitem>
214                                 </varlistentry>
215
216                                 <varlistentry>
217                                         <term><varname>b</varname></term>
218                                         <term><varname>b+</varname></term>
219                                         <listitem><para>Create a block
220                                         device node if it does not
221                                         exist yet. If suffixed with
222                                         <varname>+</varname> and a
223                                         file already exists where the
224                                         device node is to be created,
225                                         it will be removed and be
226                                         replaced by the device
227                                         node.</para></listitem>
228                                 </varlistentry>
229
230                                 <varlistentry>
231                                         <term><varname>C</varname></term>
232                                         <listitem><para>Recursively
233                                         copy a file or directory, if
234                                         the destination files or
235                                         directories do not exist
236                                         yet. Note that this command
237                                         will not descend into
238                                         subdirectories if the
239                                         destination directory already
240                                         exists. Instead, the entire
241                                         copy operation is
242                                         skipped. If the argument is omitted,
243                                         files from the source directory
244                                         <filename>/usr/share/factory/</filename>
245                                         with the same name are copied.</para></listitem>
246                                 </varlistentry>
247
248                                 <varlistentry>
249                                         <term><varname>x</varname></term>
250                                         <listitem><para>Ignore a path
251                                         during cleaning. Use this type
252                                         to exclude paths from clean-up
253                                         as controlled with the Age
254                                         parameter. Note that lines of
255                                         this type do not influence the
256                                         effect of <varname>r</varname>
257                                         or <varname>R</varname> lines.
258                                         Lines of this type accept
259                                         shell-style globs in place of
260                                         normal path names.
261                                         </para></listitem>
262                                 </varlistentry>
263
264                                 <varlistentry>
265                                         <term><varname>X</varname></term>
266                                         <listitem><para>Ignore a path
267                                         during cleaning. Use this type
268                                         to exclude paths from clean-up
269                                         as controlled with the Age
270                                         parameter. Unlike
271                                         <varname>x</varname>, this
272                                         parameter will not exclude the
273                                         content if path is a
274                                         directory, but only directory
275                                         itself. Note that lines of
276                                         this type do not influence the
277                                         effect of <varname>r</varname>
278                                         or <varname>R</varname> lines.
279                                         Lines of this type accept
280                                         shell-style globs in place of
281                                         normal path names.
282                                         </para></listitem>
283                                 </varlistentry>
284
285                                 <varlistentry>
286                                         <term><varname>r</varname></term>
287                                         <listitem><para>Remove a file
288                                         or directory if it exists.
289                                         This may not be used to remove
290                                         non-empty directories, use
291                                         <varname>R</varname> for that.
292                                         Lines of this type accept
293                                         shell-style globs in place of
294                                         normal path
295                                         names.</para></listitem>
296                                 </varlistentry>
297
298                                 <varlistentry>
299                                         <term><varname>R</varname></term>
300                                         <listitem><para>Recursively
301                                         remove a path and all its
302                                         subdirectories (if it is a
303                                         directory). Lines of this type
304                                         accept shell-style globs in
305                                         place of normal path
306                                         names.</para></listitem>
307                                 </varlistentry>
308
309                                 <varlistentry>
310                                         <term><varname>z</varname></term>
311                                         <listitem><para>Adjust the
312                                         access mode, group and user,
313                                         and restore the SELinux security
314                                         context of a file or directory,
315                                         if it exists. Lines of this
316                                         type accept shell-style globs
317                                         in place of normal path names.
318                                         </para></listitem>
319                                 </varlistentry>
320
321                                 <varlistentry>
322                                         <term><varname>Z</varname></term>
323                                         <listitem><para>Recursively
324                                         set the access mode, group and
325                                         user, and restore the SELinux
326                                         security context of a file or
327                                         directory if it exists, as
328                                         well as of its subdirectories
329                                         and the files contained
330                                         therein (if applicable). Lines
331                                         of this type accept
332                                         shell-style globs in place of
333                                         normal path
334                                         names.</para></listitem>
335                                 </varlistentry>
336                         </variablelist>
337
338                         <para>If the exclamation mark is used, this
339                         line is only safe of execute during boot, and
340                         can break a running system. Lines without the
341                         exclamation mark are presumed to be safe to
342                         execute at any time, e.g. on package upgrades.
343                         <command>systemd-tmpfiles</command> will
344                         execute line with an exclamation mark only if
345                         option <option>--boot</option> is given.
346                         </para>
347
348                         <para>For example:
349                         <programlisting># Make sure these are created by default so that nobody else can
350 d /tmp/.X11-unix 1777 root root 10d
351
352 # Unlink the X11 lock files
353 r! /tmp/.X[0-9]*-lock</programlisting>
354                         The second line in contrast to the first one
355                         would break a running system, and will only be
356                         executed with <option>--boot</option>.</para>
357                 </refsect2>
358
359                 <refsect2>
360                         <title>Path</title>
361
362                         <para>The file system path specification supports simple specifier
363                         expansion. The following expansions are
364                         understood:</para>
365
366                         <table>
367                                 <title>Specifiers available</title>
368                                 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
369                                         <colspec colname="spec" />
370                                         <colspec colname="mean" />
371                                         <colspec colname="detail" />
372                                         <thead>
373                                                 <row>
374                                                         <entry>Specifier</entry>
375                                                         <entry>Meaning</entry>
376                                                         <entry>Details</entry>
377                                                 </row>
378                                         </thead>
379                                         <tbody>
380                                                 <row>
381                                                         <entry><literal>%m</literal></entry>
382                                                         <entry>Machine ID</entry>
383                                                         <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>
384                                                 </row>
385                                                 <row>
386                                                         <entry><literal>%b</literal></entry>
387                                                         <entry>Boot ID</entry>
388                                                         <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
389                                                 </row>
390                                                 <row>
391                                                         <entry><literal>%H</literal></entry>
392                                                         <entry>Host name</entry>
393                                                         <entry>The hostname of the running system.</entry>
394                                                 </row>
395                                                 <row>
396                                                         <entry><literal>%v</literal></entry>
397                                                         <entry>Kernel release</entry>
398                                                         <entry>Identical to <command>uname -r</command> output.</entry>
399                                                 </row>
400                                                 <row>
401                                                         <entry><literal>%%</literal></entry>
402                                                         <entry>Escaped %</entry>
403                                                         <entry>Single percent sign.</entry>
404                                                 </row>
405                                         </tbody>
406                                 </tgroup>
407                         </table>
408                 </refsect2>
409
410                 <refsect2>
411                         <title>Mode</title>
412
413                         <para>The file access mode to use when
414                         creating this file or directory. If omitted or
415                         when set to -, the default is used: 0755 for
416                         directories, 0644 for all other file objects.
417                         For <varname>z</varname>, <varname>Z</varname>
418                         lines, if omitted or when set to
419                         <literal>-</literal>, the file access mode
420                         will not be modified. This parameter is
421                         ignored for <varname>x</varname>,
422                         <varname>r</varname>, <varname>R</varname>,
423                         <varname>L</varname> lines.</para>
424
425                         <para>Optionally, if prefixed with
426                         <literal>~</literal>, the access mode is masked
427                         based on the already set access bits for
428                         existing file or directories: if the existing
429                         file has all executable bits unset, all
430                         executable bits are removed from the new
431                         access mode, too. Similarly, if all read bits
432                         are removed from the old access mode, they will
433                         be removed from the new access mode too, and
434                         if all write bits are removed, they will be
435                         removed from the new access mode too. In
436                         addition, the sticky/SUID/SGID bit is removed unless
437                         applied to a directory. This
438                         functionality is particularly useful in
439                         conjunction with <varname>Z</varname>.</para>
440                 </refsect2>
441
442                 <refsect2>
443                         <title>UID, GID</title>
444
445                         <para>The user and group to use for this file
446                         or directory. This may either be a numeric
447                         user/group ID or a user or group name. If
448                         omitted or when set to <literal>-</literal>,
449                         the default 0 (root) is used. For
450                         <varname>z</varname>, <varname>Z</varname>
451                         lines, when omitted or when set to -, the file
452                         ownership will not be modified. These
453                         parameters are ignored for
454                         <varname>x</varname>, <varname>r</varname>,
455                         <varname>R</varname>, <varname>L</varname>
456                         lines.</para>
457                 </refsect2>
458
459                 <refsect2>
460                         <title>Age</title>
461                         <para>The date field, when set, is used to
462                         decide what files to delete when cleaning. If
463                         a file or directory is older than the current
464                         time minus the age field, it is deleted. The
465                         field format is a series of integers each
466                         followed by one of the following
467                         postfixes for the respective time units:</para>
468
469                         <variablelist>
470                                 <varlistentry>
471                                 <term><varname>s</varname></term>
472                                 <term><varname>min</varname></term>
473                                 <term><varname>h</varname></term>
474                                 <term><varname>d</varname></term>
475                                 <term><varname>w</varname></term>
476                                 <term><varname>ms</varname></term>
477                                 <term><varname>m</varname></term>
478                                 <term><varname>us</varname></term></varlistentry>
479                         </variablelist>
480
481                         <para>If multiple integers and units are specified, the time
482                         values are summed up. If an integer is given without a unit,
483                         s is assumed.
484                         </para>
485
486                         <para>When the age is set to zero, the files are cleaned
487                         unconditionally.</para>
488
489                         <para>The age field only applies to lines
490                         starting with <varname>d</varname>,
491                         <varname>D</varname>, and
492                         <varname>x</varname>. If omitted or set to
493                         <literal>-</literal>, no automatic clean-up is
494                         done.</para>
495
496                         <para>If the age field starts with a tilde
497                         character <literal>~</literal>, the clean-up
498                         is only applied to files and directories one
499                         level inside the directory specified, but not
500                         the files and directories immediately inside
501                         it.</para>
502                 </refsect2>
503
504                 <refsect2>
505                         <title>Argument</title>
506
507                         <para>For <varname>L</varname> lines
508                         determines the destination path of the
509                         symlink. For <varname>c</varname>,
510                         <varname>b</varname> determines the
511                         major/minor of the device node, with major and
512                         minor formatted as integers, separated by
513                         <literal>:</literal>, e.g.
514                         <literal>1:3</literal>. For
515                         <varname>f</varname>, <varname>F</varname>,
516                         and <varname>w</varname> may be used to
517                         specify a short string that is written to the
518                         file, suffixed by a newline. For
519                         <varname>C</varname>, specifies the source file
520                         or directory. Ignored for all other
521                         lines.</para>
522                 </refsect2>
523
524         </refsect1>
525
526         <refsect1>
527                 <title>Example</title>
528                 <example>
529                         <title>/etc/tmpfiles.d/screen.conf example</title>
530                         <para><command>screen</command> needs two directories created at boot with specific modes and ownership.</para>
531
532                         <programlisting>d /run/screens  1777 root root 10d
533 d /run/uscreens 0755 root root 10d12h</programlisting>
534                 </example>
535                 <example>
536                         <title>/etc/tmpfiles.d/abrt.conf example</title>
537                         <para><command>abrt</command> needs a directory created at boot with specific mode and ownership and its content should be preserved.</para>
538
539                         <programlisting>d /var/tmp/abrt 0755 abrt abrt
540 x /var/tmp/abrt/*</programlisting>
541                 </example>
542         </refsect1>
543
544         <refsect1>
545                 <title>See Also</title>
546                 <para>
547                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
548                         <citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
549                         <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
550                         <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
551                 </para>
552         </refsect1>
553
554 </refentry>