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>.
71 Files in <filename>/etc/</filename> overwrite
72 files with the same name in <filename>/usr/lib/</filename>.
73 Files in <filename>/run</filename> overwrite files with
74 the same name in <filename>/etc/</filename> and
75 <filename>/usr/lib/</filename>. Packages should install their
76 configuration files in <filename>/usr/lib/</filename>, files
77 in <filename>/etc/</filename> are reserved for the local
78 administration, which possibly decides to overwrite the
79 configurations installed from packages. All files are sorted
80 by filename in alphabetical order, regardless in which of the
81 directories they reside, to ensure that a specific
82 configuration file takes precedence over another file with
83 an alphabetically later name.</para>
85 <para>The configuration format is one line per path
86 containing action, mode, ownership and age
89 <programlisting>Type Path Mode UID GID Age
90 d /run/user 0755 root root 10d</programlisting>
96 <term><varname>f</varname></term>
97 <listitem><para>Create a file if it doesn't exist yet</para></listitem>
101 <term><varname>F</varname></term>
102 <listitem><para>Create or truncate a file</para></listitem>
106 <term><varname>d</varname></term>
107 <listitem><para>Create a directory if it doesn't exist yet</para></listitem>
111 <term><varname>D</varname></term>
112 <listitem><para>Create or empty a directory</para></listitem>
116 <term><varname>p</varname></term>
117 <listitem><para>Create a named pipe (FIFO) if it doesn't exist yet</para></listitem>
121 <term><varname>x</varname></term>
122 <listitem><para>Ignore a path
123 during cleaning. Use this type
124 to exclude paths from clean-up
125 as controlled with the Age
126 parameter. Note that lines of
127 this type do not influence the
128 effect of r or R lines. Lines
130 shell-style globs in place of
132 names.</para></listitem>
136 <term><varname>r</varname></term>
137 <listitem><para>Remove a file
139 exists. This may not be used
141 directories, use R for
142 that. Lines of this type
143 accept shell-style globs in
145 names.</para></listitem>
149 <term><varname>R</varname></term>
150 <listitem><para>Recursively
151 remove a path and all its
152 subdirectories (if it is a
153 directory). Lines of this type
154 accept shell-style globs in
156 names.</para></listitem>
160 <term><varname>z</varname></term>
161 <listitem><para>Set ownership, access
162 mode and relabel security context of
163 a file or directory if it exists.
164 Lines of this type accept shell-style
165 globs in place of normal path names.
170 <term><varname>Z</varname></term>
171 <listitem><para>Recursively set
172 ownership, access mode and relabel
173 security context of a path and
174 all its subdirectories (if it is a
175 directory). Lines of this type accept
176 shell-style globs in place of normal
177 path names.</para></listitem>
185 <para>The file access mode to use when
186 creating this file or directory. If omitted or
187 when set to - the default is used: 0755 for
188 directories, 0644 for files. For z, Z lines
189 if omitted or when set to - the file access mode will
190 not be modified. This parameter is ignored for x, r, R
195 <title>UID, GID</title>
197 <para>The user and group to use for this file
198 or directory. This may either be a numeric
199 user/group ID or a user or group name. If
200 omitted or when set to - the default 0 (root)
201 is used. For z, Z lines when omitted or when set to -
202 the file ownership will not be modified.
203 These parameters are ignored for x, r, R lines.</para>
208 <para>The date field, when set, is used to
209 decide what files to delete when cleaning. If
210 a file or directory is older than the current
211 time minus the age field it is deleted. The
212 field format is a series of integers each
213 followed by one of the following
214 postfixes for the respective time units:</para>
218 <term><varname>s</varname></term>
219 <term><varname>min</varname></term>
220 <term><varname>h</varname></term>
221 <term><varname>d</varname></term>
222 <term><varname>w</varname></term>
223 <term><varname>ms</varname></term>
224 <term><varname>m</varname></term>
225 <term><varname>us</varname></term></varlistentry>
228 <para>If multiple integers and units are specified the time
229 values are summed up.</para>
231 <para>The age field only applies to lines starting with
232 d, D and x. If omitted or set to - no automatic clean-up
239 <title>Example</title>
241 <title>/etc/tmpfiles.d/screen.conf example</title>
242 <para><command>screen</command> needs two directories created at boot with specific modes and ownership.</para>
244 <programlisting>d /var/run/screens 1777 root root 10d
245 d /var/run/uscreens 0755 root root 10d12h</programlisting>
250 <title>See Also</title>
252 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
253 <citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>