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 General Public License as published by
11 the Free Software Foundation; either version 2 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 General Public License for more details.
19 You should have received a copy of the GNU 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>/usr/lib/tmpfiles.d/*.conf</filename></para>
51 <para><filename>/etc/tmpfiles.d/*.conf</filename></para>
52 <para><filename>/run/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 is named in the style of
70 <filename><program>.conf</filename>. Files in
71 <filename>/etc/</filename> override files with the
72 same name in <filename>/usr/lib/</filename>. Files in
73 <filename>/run</filename> override files with the same
74 name in <filename>/etc/</filename> and
75 <filename>/usr/lib/</filename>. Packages should
76 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 choose to override the
80 configurations installed from packages. The list of
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
84 configuration file takes precedence over another
85 configuration file with an alphabetically later
88 <para>The configuration format is one line per path
89 containing action, path, mode, ownership, age and argument
92 <programlisting>Type Path Mode UID GID Age Argument
93 d /run/user 0755 root root 10d -
94 L /tmp/foobar - - - - /dev/null</programlisting>
100 <term><varname>f</varname></term>
101 <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>
105 <term><varname>F</varname></term>
106 <listitem><para>Create or truncate a file (optionally writing a short string into it, if the argument parameter is passed)</para></listitem>
110 <term><varname>w</varname></term>
111 <listitem><para>Write the argument parameter to a file, if it exists.</para></listitem>
115 <term><varname>d</varname></term>
116 <listitem><para>Create a directory if it doesn't exist yet</para></listitem>
120 <term><varname>D</varname></term>
121 <listitem><para>Create or empty a directory</para></listitem>
125 <term><varname>p</varname></term>
126 <listitem><para>Create a named pipe (FIFO) if it doesn't exist yet</para></listitem>
130 <term><varname>L</varname></term>
131 <listitem><para>Create a symlink if it doesn't exist yet</para></listitem>
135 <term><varname>c</varname></term>
136 <listitem><para>Create a character device node if it doesn't exist yet</para></listitem>
140 <term><varname>b</varname></term>
141 <listitem><para>Create a block device node if it doesn't exist yet</para></listitem>
145 <term><varname>x</varname></term>
146 <listitem><para>Ignore a path
147 during cleaning. Use this type
148 to exclude paths from clean-up
149 as controlled with the Age
150 parameter. Note that lines of
151 this type do not influence the
152 effect of r or R lines. Lines
154 shell-style globs in place of
156 names.</para></listitem>
160 <term><varname>r</varname></term>
161 <listitem><para>Remove a file
163 exists. This may not be used
165 directories, use R for
166 that. Lines of this type
167 accept shell-style globs in
169 names.</para></listitem>
173 <term><varname>R</varname></term>
174 <listitem><para>Recursively
175 remove a path and all its
176 subdirectories (if it is a
177 directory). Lines of this type
178 accept shell-style globs in
180 names.</para></listitem>
184 <term><varname>z</varname></term>
185 <listitem><para>Set ownership, access
186 mode and relabel security context of
187 a file or directory if it exists.
188 Lines of this type accept shell-style
189 globs in place of normal path names.
194 <term><varname>Z</varname></term>
195 <listitem><para>Recursively set
196 ownership, access mode and relabel
197 security context of a path and
198 all its subdirectories (if it is a
199 directory). Lines of this type accept
200 shell-style globs in place of normal
201 path names.</para></listitem>
209 <para>The file access mode to use when
210 creating this file or directory. If omitted or
211 when set to - the default is used: 0755 for
212 directories, 0644 for all other file
213 objects. For z, Z lines if omitted or when set
214 to - the file access mode will not be
215 modified. This parameter is ignored for x, r,
220 <title>UID, GID</title>
222 <para>The user and group to use for this file
223 or directory. This may either be a numeric
224 user/group ID or a user or group name. If
225 omitted or when set to - the default 0 (root)
226 is used. For z, Z lines when omitted or when set to -
227 the file ownership will not be modified.
228 These parameters are ignored for x, r, R, L lines.</para>
233 <para>The date field, when set, is used to
234 decide what files to delete when cleaning. If
235 a file or directory is older than the current
236 time minus the age field it is deleted. The
237 field format is a series of integers each
238 followed by one of the following
239 postfixes for the respective time units:</para>
243 <term><varname>s</varname></term>
244 <term><varname>min</varname></term>
245 <term><varname>h</varname></term>
246 <term><varname>d</varname></term>
247 <term><varname>w</varname></term>
248 <term><varname>ms</varname></term>
249 <term><varname>m</varname></term>
250 <term><varname>us</varname></term></varlistentry>
253 <para>If multiple integers and units are specified the time
254 values are summed up.</para>
256 <para>The age field only applies to lines starting with
257 d, D and x. If omitted or set to - no automatic clean-up
262 <title>Argument</title>
264 <para>For L lines determines the destination
265 path of the symlink. For c, b determines the
266 major/minor of the device node, with major and
267 minor formatted as integers, separated by :,
268 e.g. "1:3". For f, F, w may be used to specify
269 a short string that is written to the file,
270 suffixed by a newline. Ignored for all other
277 <title>Example</title>
279 <title>/etc/tmpfiles.d/screen.conf example</title>
280 <para><command>screen</command> needs two directories created at boot with specific modes and ownership.</para>
282 <programlisting>d /var/run/screens 1777 root root 10d
283 d /var/run/uscreens 0755 root root 10d12h</programlisting>
288 <title>See Also</title>
290 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
291 <citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>