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