3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5 This file is part of systemd.
7 Copyright 2010 Brandon Philips
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.
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.
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/>.
22 <refentry id="tmpfiles.d">
25 <title>tmpfiles.d</title>
26 <productname>systemd</productname>
30 <contrib>Documentation</contrib>
31 <firstname>Brandon</firstname>
32 <surname>Philips</surname>
33 <email>brandon@ifup.org</email>
39 <refentrytitle>tmpfiles.d</refentrytitle>
40 <manvolnum>5</manvolnum>
44 <refname>tmpfiles.d</refname>
45 <refpurpose>Configuration for creation, deletion and
46 cleaning of volatile and temporary files</refpurpose>
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>
56 <title>Description</title>
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>
67 <title>Configuration Format</title>
69 <para>Each configuration file shall be named in the
70 style of <filename><package>.conf</filename>.
71 Files in <filename>/etc/</filename> override files
72 with the same name in <filename>/usr/lib/</filename>
73 and <filename>/run/</filename>. Files in
74 <filename>/run/</filename> override files with the same
75 name in <filename>/usr/lib/</filename>. Packages
76 should install their configuration files in
77 <filename>/usr/lib/</filename>. Files in
78 <filename>/etc/</filename> are reserved for the local
79 administrator, who may use this logic to override the
80 configuration files installed by vendor packages. All
81 configuration files are sorted by their filename in
82 lexicographic order, regardless in which of the
83 directories they reside. If multiple files specify the
84 same path, the entry in the file with the lexicographically
85 earliest name will be applied, all all other conflicting
86 entries logged as errors.</para>
88 <para>If the administrator wants to disable a
89 configuration file supplied by the vendor, the
90 recommended way is to place a symlink to
91 <filename>/dev/null</filename> in
92 <filename>/etc/tmpfiles.d/</filename> bearing the
95 <para>The configuration format is one line per path
96 containing action, path, mode, ownership, age and argument
99 <programlisting>Type Path Mode UID GID Age Argument
100 d /run/user 0755 root root 10d -
101 L /tmp/foobar - - - - /dev/null</programlisting>
107 <para>The following line types are understood:</para>
111 <term><varname>f</varname></term>
112 <listitem><para>Create a file if it does not exist yet (optionally writing a short string into it, if the argument parameter is passed)</para></listitem>
116 <term><varname>F</varname></term>
117 <listitem><para>Create or truncate a file (optionally writing a short string into it, if the argument parameter is passed)</para></listitem>
121 <term><varname>w</varname></term>
122 <listitem><para>Write the argument parameter to a file, if the file exists.
123 Lines of this type accept shell-style globs in place of normal path
124 names. The argument parameter will be written without a trailing
125 newline. C-style backslash escapes are interpreted.</para></listitem>
129 <term><varname>d</varname></term>
130 <listitem><para>Create a directory if it does not exist yet</para></listitem>
134 <term><varname>D</varname></term>
135 <listitem><para>Create or empty a directory</para></listitem>
139 <term><varname>p</varname></term>
140 <listitem><para>Create a named pipe (FIFO) if it does not exist yet</para></listitem>
144 <term><varname>L</varname></term>
145 <listitem><para>Create a symlink if it does not exist yet</para></listitem>
149 <term><varname>c</varname></term>
150 <listitem><para>Create a character device node if it does not exist yet</para></listitem>
154 <term><varname>b</varname></term>
155 <listitem><para>Create a block device node if it does not exist yet</para></listitem>
159 <term><varname>x</varname></term>
160 <listitem><para>Ignore a path
161 during cleaning. Use this type
162 to exclude paths from clean-up
163 as controlled with the Age
164 parameter. Note that lines of
165 this type do not influence the
166 effect of r or R lines. Lines
168 shell-style globs in place of
170 names.</para></listitem>
174 <term><varname>X</varname></term>
175 <listitem><para>Ignore a path
176 during cleanup. Use this type
177 to prevent path removal as
178 controlled with the Age parameter.
179 Note that if path is a directory,
180 content of a directory is not
181 excluded from clean-up, only
182 directory itself. Lines of this
183 type accept shell-style globs
184 in place of normal path
185 names.</para></listitem>
189 <term><varname>r</varname></term>
190 <listitem><para>Remove a file
192 exists. This may not be used
194 directories, use R for
195 that. Lines of this type
196 accept shell-style globs in
198 names.</para></listitem>
202 <term><varname>R</varname></term>
203 <listitem><para>Recursively
204 remove a path and all its
205 subdirectories (if it is a
206 directory). Lines of this type
207 accept shell-style globs in
209 names.</para></listitem>
213 <term><varname>z</varname></term>
214 <listitem><para>Restore
215 SELinux security context label
216 and set ownership and access
217 mode of a file or directory if
218 it exists. Lines of this type
219 accept shell-style globs in
220 place of normal path names.
225 <term><varname>Z</varname></term>
226 <listitem><para>Recursively
227 restore SELinux security
228 context label and set
229 ownership and access mode of a
231 subdirectories (if it is a
232 directory). Lines of this type
233 accept shell-style globs in
235 names.</para></listitem>
243 <para>The file system path specification supports simple specifier
244 expansion. The following expansions are
248 <title>Specifiers available</title>
249 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
250 <colspec colname="spec" />
251 <colspec colname="mean" />
252 <colspec colname="detail" />
255 <entry>Specifier</entry>
256 <entry>Meaning</entry>
257 <entry>Details</entry>
262 <entry><literal>%m</literal></entry>
263 <entry>Machine ID</entry>
264 <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>
267 <entry><literal>%b</literal></entry>
268 <entry>Boot ID</entry>
269 <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
272 <entry><literal>%H</literal></entry>
273 <entry>Host name</entry>
274 <entry>The hostname of the running system.</entry>
277 <entry><literal>%v</literal></entry>
278 <entry>Kernel release</entry>
279 <entry>Identical to <command>uname -r</command> output.</entry>
282 <entry><literal>%%</literal></entry>
283 <entry>Escaped %</entry>
284 <entry>Single percent sign.</entry>
294 <para>The file access mode to use when
295 creating this file or directory. If omitted or
296 when set to -, the default is used: 0755 for
297 directories, 0644 for all other file
298 objects. For z, Z lines, if omitted or when set
299 to -, the file access mode will not be
300 modified. This parameter is ignored for x, r,
305 <title>UID, GID</title>
307 <para>The user and group to use for this file
308 or directory. This may either be a numeric
309 user/group ID or a user or group name. If
310 omitted or when set to -, the default 0 (root)
311 is used. For z, Z lines, when omitted or when set to -,
312 the file ownership will not be modified.
313 These parameters are ignored for x, r, R, L lines.</para>
318 <para>The date field, when set, is used to
319 decide what files to delete when cleaning. If
320 a file or directory is older than the current
321 time minus the age field, it is deleted. The
322 field format is a series of integers each
323 followed by one of the following
324 postfixes for the respective time units:</para>
328 <term><varname>s</varname></term>
329 <term><varname>min</varname></term>
330 <term><varname>h</varname></term>
331 <term><varname>d</varname></term>
332 <term><varname>w</varname></term>
333 <term><varname>ms</varname></term>
334 <term><varname>m</varname></term>
335 <term><varname>us</varname></term></varlistentry>
338 <para>If multiple integers and units are specified, the time
339 values are summed up. If an integer is given without a unit,
343 <para>When the age is set to zero, the files are cleaned
344 unconditionally.</para>
346 <para>The age field only applies to lines starting with
347 d, D and x. If omitted or set to -, no automatic clean-up
350 <para>If the age field starts with a tilde
351 character (~), the clean-up is only applied to
352 files and directories one level inside the
353 directory specified, but not the files and
354 directories immediately inside it.</para>
358 <title>Argument</title>
360 <para>For L lines determines the destination
361 path of the symlink. For c, b determines the
362 major/minor of the device node, with major and
363 minor formatted as integers, separated by :,
364 e.g. "1:3". For f, F, w may be used to specify
365 a short string that is written to the file,
366 suffixed by a newline. Ignored for all other
373 <title>Example</title>
375 <title>/etc/tmpfiles.d/screen.conf example</title>
376 <para><command>screen</command> needs two directories created at boot with specific modes and ownership.</para>
378 <programlisting>d /var/run/screens 1777 root root 10d
379 d /var/run/uscreens 0755 root root 10d12h</programlisting>
382 <title>/etc/tmpfiles.d/abrt.conf example</title>
383 <para><command>abrt</command> needs a directory created at boot with specific mode and ownership and its content should be preserved.</para>
385 <programlisting>d /var/tmp/abrt 0755 abrt abrt
386 x /var/tmp/abrt/*</programlisting>
391 <title>See Also</title>
393 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
394 <citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
395 <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>