chiark / gitweb /
coredump: coredumpctl is so useful now, make it a first-class citizen
[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.</para></listitem>
195                                 </varlistentry>
196
197                                 <varlistentry>
198                                         <term><varname>c</varname></term>
199                                         <term><varname>c+</varname></term>
200                                         <listitem><para>Create a
201                                         character device node if it
202                                         does not exist yet. If
203                                         suffixed with
204                                         <varname>+</varname> and a
205                                         file already exists where the
206                                         device node is to be created
207                                         it will be removed and be
208                                         replaced by the device
209                                         node.</para></listitem>
210                                 </varlistentry>
211
212                                 <varlistentry>
213                                         <term><varname>b</varname></term>
214                                         <term><varname>b+</varname></term>
215                                         <listitem><para>Create a block
216                                         device node if it does not
217                                         exist yet. If suffixed with
218                                         <varname>+</varname> and a
219                                         file already exists where the
220                                         device node is to be created
221                                         it will be removed and be
222                                         replaced by the device
223                                         node.</para></listitem>
224                                 </varlistentry>
225
226                                 <varlistentry>
227                                         <term><varname>C</varname></term>
228                                         <listitem><para>Recursively copy a file or directory, if the destination files or directories don't exist yet.</para></listitem>
229                                 </varlistentry>
230
231                                 <varlistentry>
232                                         <term><varname>x</varname></term>
233                                         <listitem><para>Ignore a path
234                                         during cleaning. Use this type
235                                         to exclude paths from clean-up
236                                         as controlled with the Age
237                                         parameter. Note that lines of
238                                         this type do not influence the
239                                         effect of <varname>r</varname>
240                                         or <varname>R</varname> lines.
241                                         Lines of this type accept
242                                         shell-style globs in place of
243                                         normal path names.
244                                         </para></listitem>
245                                 </varlistentry>
246
247                                 <varlistentry>
248                                         <term><varname>X</varname></term>
249                                         <listitem><para>Ignore a path
250                                         during cleaning. Use this type
251                                         to exclude paths from clean-up
252                                         as controlled with the Age
253                                         parameter. Unlike
254                                         <varname>x</varname>, this
255                                         parameter will not exclude the
256                                         content if path is a
257                                         directory, but only directory
258                                         itself. Note that lines of
259                                         this type do not influence the
260                                         effect of <varname>r</varname>
261                                         or <varname>R</varname> lines.
262                                         Lines of this type accept
263                                         shell-style globs in place of
264                                         normal path names.
265                                         </para></listitem>
266                                 </varlistentry>
267
268                                 <varlistentry>
269                                         <term><varname>r</varname></term>
270                                         <listitem><para>Remove a file
271                                         or directory if it exists.
272                                         This may not be used to remove
273                                         non-empty directories, use
274                                         <varname>R</varname> for that.
275                                         Lines of this type accept
276                                         shell-style globs in place of
277                                         normal path
278                                         names.</para></listitem>
279                                 </varlistentry>
280
281                                 <varlistentry>
282                                         <term><varname>R</varname></term>
283                                         <listitem><para>Recursively
284                                         remove a path and all its
285                                         subdirectories (if it is a
286                                         directory). Lines of this type
287                                         accept shell-style globs in
288                                         place of normal path
289                                         names.</para></listitem>
290                                 </varlistentry>
291
292                                 <varlistentry>
293                                         <term><varname>z</varname></term>
294                                         <listitem><para>Adjust the
295                                         access mode, group and user,
296                                         and restore the SELinux security
297                                         context of a file or directory,
298                                         if it exists. Lines of this
299                                         type accept shell-style globs
300                                         in place of normal path names.
301                                         </para></listitem>
302                                 </varlistentry>
303
304                                 <varlistentry>
305                                         <term><varname>Z</varname></term>
306                                         <listitem><para>Recursively
307                                         set the access mode, group and
308                                         user, and restore the SELinux
309                                         security context of a file or
310                                         directory if it exists, as
311                                         well as of its subdirectories
312                                         and the files contained
313                                         therein (if applicable). Lines
314                                         of this type accept
315                                         shell-style globs in place of
316                                         normal path
317                                         names.</para></listitem>
318                                 </varlistentry>
319                         </variablelist>
320
321                         <para>If the exclamation mark is used, this
322                         line is only safe of execute during boot, and
323                         can break a running system. Lines without the
324                         exclamation mark are presumed to be safe to
325                         execute at any time, e.g. on package upgrades.
326                         <command>systemd-tmpfiles</command> will
327                         execute line with an exclamation mark only if
328                         option <option>--boot</option> is given.
329                         </para>
330
331                         <para>For example:
332                         <programlisting># Make sure these are created by default so that nobody else can
333 d /tmp/.X11-unix 1777 root root 10d
334
335 # Unlink the X11 lock files
336 r! /tmp/.X[0-9]*-lock</programlisting>
337                         The second line in contrast to the first one
338                         would break a running system, and will only be
339                         executed with <option>--boot</option>.</para>
340                 </refsect2>
341
342                 <refsect2>
343                         <title>Path</title>
344
345                         <para>The file system path specification supports simple specifier
346                         expansion. The following expansions are
347                         understood:</para>
348
349                         <table>
350                                 <title>Specifiers available</title>
351                                 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
352                                         <colspec colname="spec" />
353                                         <colspec colname="mean" />
354                                         <colspec colname="detail" />
355                                         <thead>
356                                                 <row>
357                                                         <entry>Specifier</entry>
358                                                         <entry>Meaning</entry>
359                                                         <entry>Details</entry>
360                                                 </row>
361                                         </thead>
362                                         <tbody>
363                                                 <row>
364                                                         <entry><literal>%m</literal></entry>
365                                                         <entry>Machine ID</entry>
366                                                         <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>
367                                                 </row>
368                                                 <row>
369                                                         <entry><literal>%b</literal></entry>
370                                                         <entry>Boot ID</entry>
371                                                         <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
372                                                 </row>
373                                                 <row>
374                                                         <entry><literal>%H</literal></entry>
375                                                         <entry>Host name</entry>
376                                                         <entry>The hostname of the running system.</entry>
377                                                 </row>
378                                                 <row>
379                                                         <entry><literal>%v</literal></entry>
380                                                         <entry>Kernel release</entry>
381                                                         <entry>Identical to <command>uname -r</command> output.</entry>
382                                                 </row>
383                                                 <row>
384                                                         <entry><literal>%%</literal></entry>
385                                                         <entry>Escaped %</entry>
386                                                         <entry>Single percent sign.</entry>
387                                                 </row>
388                                         </tbody>
389                                 </tgroup>
390                         </table>
391                 </refsect2>
392
393                 <refsect2>
394                         <title>Mode</title>
395
396                         <para>The file access mode to use when
397                         creating this file or directory. If omitted or
398                         when set to -, the default is used: 0755 for
399                         directories, 0644 for all other file objects.
400                         For <varname>z</varname>, <varname>Z</varname>
401                         lines, if omitted or when set to
402                         <literal>-</literal>, the file access mode
403                         will not be modified. This parameter is
404                         ignored for <varname>x</varname>,
405                         <varname>r</varname>, <varname>R</varname>,
406                         <varname>L</varname> lines.</para>
407
408                         <para>Optionally, if prefixed with
409                         <literal>~</literal> the access mode is masked
410                         based on the already set access bits for
411                         existing file or directories: if the existing
412                         file has all executable bits unset then all
413                         executable bits are removed from the new
414                         access mode, too. Similar, if all read bits
415                         are removed from the old access mode they will
416                         be removed from the new access mode too, and
417                         if all write bits are removed, they will be
418                         removed from the new access mode too. In
419                         addition the sticky/suid/gid bit is removed unless
420                         applied to a directory. This
421                         functionality is particularly useful in
422                         conjunction with <varname>Z</varname>.</para>
423                 </refsect2>
424
425                 <refsect2>
426                         <title>UID, GID</title>
427
428                         <para>The user and group to use for this file
429                         or directory. This may either be a numeric
430                         user/group ID or a user or group name. If
431                         omitted or when set to <literal>-</literal>,
432                         the default 0 (root) is used. For
433                         <varname>z</varname>, <varname>Z</varname>
434                         lines, when omitted or when set to -, the file
435                         ownership will not be modified. These
436                         parameters are ignored for
437                         <varname>x</varname>, <varname>r</varname>,
438                         <varname>R</varname>, <varname>L</varname>
439                         lines.</para>
440                 </refsect2>
441
442                 <refsect2>
443                         <title>Age</title>
444                         <para>The date field, when set, is used to
445                         decide what files to delete when cleaning. If
446                         a file or directory is older than the current
447                         time minus the age field, it is deleted. The
448                         field format is a series of integers each
449                         followed by one of the following
450                         postfixes for the respective time units:</para>
451
452                         <variablelist>
453                                 <varlistentry>
454                                 <term><varname>s</varname></term>
455                                 <term><varname>min</varname></term>
456                                 <term><varname>h</varname></term>
457                                 <term><varname>d</varname></term>
458                                 <term><varname>w</varname></term>
459                                 <term><varname>ms</varname></term>
460                                 <term><varname>m</varname></term>
461                                 <term><varname>us</varname></term></varlistentry>
462                         </variablelist>
463
464                         <para>If multiple integers and units are specified, the time
465                         values are summed up. If an integer is given without a unit,
466                         s is assumed.
467                         </para>
468
469                         <para>When the age is set to zero, the files are cleaned
470                         unconditionally.</para>
471
472                         <para>The age field only applies to lines
473                         starting with <varname>d</varname>,
474                         <varname>D</varname>, and
475                         <varname>x</varname>. If omitted or set to
476                         <literal>-</literal>, no automatic clean-up is
477                         done.</para>
478
479                         <para>If the age field starts with a tilde
480                         character <literal>~</literal>, the clean-up
481                         is only applied to files and directories one
482                         level inside the directory specified, but not
483                         the files and directories immediately inside
484                         it.</para>
485                 </refsect2>
486
487                 <refsect2>
488                         <title>Argument</title>
489
490                         <para>For <varname>L</varname> lines
491                         determines the destination path of the
492                         symlink. For <varname>c</varname>,
493                         <varname>b</varname> determines the
494                         major/minor of the device node, with major and
495                         minor formatted as integers, separated by
496                         <literal>:</literal>, e.g.
497                         <literal>1:3</literal>. For
498                         <varname>f</varname>, <varname>F</varname>,
499                         and <varname>w</varname> may be used to
500                         specify a short string that is written to the
501                         file, suffixed by a newline. For
502                         <varname>C</varname> specifies the source file
503                         or directory. Ignored for all other
504                         lines.</para>
505                 </refsect2>
506
507         </refsect1>
508
509         <refsect1>
510                 <title>Example</title>
511                 <example>
512                         <title>/etc/tmpfiles.d/screen.conf example</title>
513                         <para><command>screen</command> needs two directories created at boot with specific modes and ownership.</para>
514
515                         <programlisting>d /run/screens  1777 root root 10d
516 d /run/uscreens 0755 root root 10d12h</programlisting>
517                 </example>
518                 <example>
519                         <title>/etc/tmpfiles.d/abrt.conf example</title>
520                         <para><command>abrt</command> needs a directory created at boot with specific mode and ownership and its content should be preserved.</para>
521
522                         <programlisting>d /var/tmp/abrt 0755 abrt abrt
523 x /var/tmp/abrt/*</programlisting>
524                 </example>
525         </refsect1>
526
527         <refsect1>
528                 <title>See Also</title>
529                 <para>
530                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
531                         <citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
532                         <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
533                         <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
534                 </para>
535         </refsect1>
536
537 </refentry>