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><program>.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 alphabetical order, regardless in which of the
83 directories they reside, to guarantee that a specific
84 configuration file takes precedence over another file
85 with an alphabetically later name.</para>
87 <para>If the administrator wants to disable a
88 configuration file supplied by the vendor the
89 recommended way is to place a symlink to
90 <filename>/dev/null</filename> in
91 <filename>/etc/tmpfiles.d/</filename> bearing the
92 same file name.</para>
94 <para>The configuration format is one line per path
95 containing action, path, mode, ownership, age and argument
98 <programlisting>Type Path Mode UID GID Age Argument
99 d /run/user 0755 root root 10d -
100 L /tmp/foobar - - - - /dev/null</programlisting>
106 <term><varname>f</varname></term>
107 <listitem><para>Create a file if it doesn't exist yet (optionally writing a short string into it, if the argument parameter is passed)</para></listitem>
111 <term><varname>F</varname></term>
112 <listitem><para>Create or truncate a file (optionally writing a short string into it, if the argument parameter is passed)</para></listitem>
116 <term><varname>w</varname></term>
117 <listitem><para>Write the argument parameter to a file, if the file exists.
118 Lines of this type accept shell-style globs in place of normal path
119 names. The argument parameter will be written without a trailing
120 newline. C-style backslash escapes are interpreted.</para></listitem>
124 <term><varname>d</varname></term>
125 <listitem><para>Create a directory if it doesn't exist yet</para></listitem>
129 <term><varname>D</varname></term>
130 <listitem><para>Create or empty a directory</para></listitem>
134 <term><varname>p</varname></term>
135 <listitem><para>Create a named pipe (FIFO) if it doesn't exist yet</para></listitem>
139 <term><varname>L</varname></term>
140 <listitem><para>Create a symlink if it doesn't exist yet</para></listitem>
144 <term><varname>c</varname></term>
145 <listitem><para>Create a character device node if it doesn't exist yet</para></listitem>
149 <term><varname>b</varname></term>
150 <listitem><para>Create a block device node if it doesn't exist yet</para></listitem>
154 <term><varname>x</varname></term>
155 <listitem><para>Ignore a path
156 during cleaning. Use this type
157 to exclude paths from clean-up
158 as controlled with the Age
159 parameter. Note that lines of
160 this type do not influence the
161 effect of r or R lines. Lines
163 shell-style globs in place of
165 names.</para></listitem>
169 <term><varname>r</varname></term>
170 <listitem><para>Remove a file
172 exists. This may not be used
174 directories, use R for
175 that. Lines of this type
176 accept shell-style globs in
178 names.</para></listitem>
182 <term><varname>R</varname></term>
183 <listitem><para>Recursively
184 remove a path and all its
185 subdirectories (if it is a
186 directory). Lines of this type
187 accept shell-style globs in
189 names.</para></listitem>
193 <term><varname>z</varname></term>
194 <listitem><para>Restore
195 SELinux security context label
196 and set ownership and access
197 mode of a file or directory if
198 it exists. Lines of this type
199 accept shell-style globs in
200 place of normal path names.
205 <term><varname>Z</varname></term>
206 <listitem><para>Recursively
207 restore SELinux security
208 context label and set
209 ownership and access mode of a
211 subdirectories (if it is a
212 directory). Lines of this type
213 accept shell-style globs in
215 names.</para></listitem>
223 <para>The file access mode to use when
224 creating this file or directory. If omitted or
225 when set to - the default is used: 0755 for
226 directories, 0644 for all other file
227 objects. For z, Z lines if omitted or when set
228 to - the file access mode will not be
229 modified. This parameter is ignored for x, r,
234 <title>UID, GID</title>
236 <para>The user and group to use for this file
237 or directory. This may either be a numeric
238 user/group ID or a user or group name. If
239 omitted or when set to - the default 0 (root)
240 is used. For z, Z lines when omitted or when set to -
241 the file ownership will not be modified.
242 These parameters are ignored for x, r, R, L lines.</para>
247 <para>The date field, when set, is used to
248 decide what files to delete when cleaning. If
249 a file or directory is older than the current
250 time minus the age field it is deleted. The
251 field format is a series of integers each
252 followed by one of the following
253 postfixes for the respective time units:</para>
257 <term><varname>s</varname></term>
258 <term><varname>min</varname></term>
259 <term><varname>h</varname></term>
260 <term><varname>d</varname></term>
261 <term><varname>w</varname></term>
262 <term><varname>ms</varname></term>
263 <term><varname>m</varname></term>
264 <term><varname>us</varname></term></varlistentry>
267 <para>If multiple integers and units are specified the time
268 values are summed up. If an integer is given without a unit,
272 <para>When the age is set to zero, the files are cleaned
273 unconditionally.</para>
275 <para>The age field only applies to lines starting with
276 d, D and x. If omitted or set to - no automatic clean-up
279 <para>If the age field starts with a tilde
280 character (~) the clean-up is only applied to
281 files and directories one level inside the
282 directory specified, but not the files and
283 directories immediately inside it.</para>
287 <title>Argument</title>
289 <para>For L lines determines the destination
290 path of the symlink. For c, b determines the
291 major/minor of the device node, with major and
292 minor formatted as integers, separated by :,
293 e.g. "1:3". For f, F, w may be used to specify
294 a short string that is written to the file,
295 suffixed by a newline. Ignored for all other
302 <title>Example</title>
304 <title>/etc/tmpfiles.d/screen.conf example</title>
305 <para><command>screen</command> needs two directories created at boot with specific modes and ownership.</para>
307 <programlisting>d /var/run/screens 1777 root root 10d
308 d /var/run/uscreens 0755 root root 10d12h</programlisting>
313 <title>See Also</title>
315 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
316 <citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
317 <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>