]>
Commit | Line | Data |
---|---|---|
522d4a49 | 1 | <?xml version='1.0'?> <!--*-nxml-*--> |
3a54a157 | 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
eea10b26 | 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
db9ecf05 | 4 | <!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
522d4a49 | 5 | |
dfdebb1b | 6 | <refentry id="systemd-tmpfiles" |
798d3a52 ZJS |
7 | xmlns:xi="http://www.w3.org/2001/XInclude"> |
8 | ||
9 | <refentryinfo> | |
10 | <title>systemd-tmpfiles</title> | |
11 | <productname>systemd</productname> | |
798d3a52 ZJS |
12 | </refentryinfo> |
13 | ||
14 | <refmeta> | |
15 | <refentrytitle>systemd-tmpfiles</refentrytitle> | |
16 | <manvolnum>8</manvolnum> | |
17 | </refmeta> | |
18 | ||
19 | <refnamediv> | |
20 | <refname>systemd-tmpfiles</refname> | |
21 | <refname>systemd-tmpfiles-setup.service</refname> | |
bb7f485f | 22 | <refname>systemd-tmpfiles-setup-dev-early.service</refname> |
798d3a52 ZJS |
23 | <refname>systemd-tmpfiles-setup-dev.service</refname> |
24 | <refname>systemd-tmpfiles-clean.service</refname> | |
25 | <refname>systemd-tmpfiles-clean.timer</refname> | |
26 | <refpurpose>Creates, deletes and cleans up volatile | |
27 | and temporary files and directories</refpurpose> | |
28 | </refnamediv> | |
29 | ||
30 | <refsynopsisdiv> | |
31 | <cmdsynopsis> | |
32 | <command>systemd-tmpfiles</command> | |
33 | <arg choice="opt" rep="repeat">OPTIONS</arg> | |
34 | <arg choice="opt" rep="repeat"><replaceable>CONFIGFILE</replaceable></arg> | |
35 | </cmdsynopsis> | |
36 | ||
cfdda37c | 37 | <para>System units: |
73e97bb0 ZJS |
38 | <simplelist> |
39 | <member><filename>systemd-tmpfiles-setup.service</filename></member> | |
40 | <member><filename>systemd-tmpfiles-setup-dev-early.service</filename></member> | |
41 | <member><filename>systemd-tmpfiles-setup-dev.service</filename></member> | |
42 | <member><filename>systemd-tmpfiles-clean.service</filename></member> | |
43 | <member><filename>systemd-tmpfiles-clean.timer</filename></member> | |
44 | </simplelist> | |
45 | </para> | |
cfdda37c ZJS |
46 | |
47 | <para>User units: | |
73e97bb0 ZJS |
48 | <simplelist> |
49 | <member><filename>systemd-tmpfiles-setup.service</filename></member> | |
50 | <member><filename>systemd-tmpfiles-clean.service</filename></member> | |
51 | <member><filename>systemd-tmpfiles-clean.timer</filename></member> | |
52 | </simplelist> | |
53 | </para> | |
798d3a52 ZJS |
54 | </refsynopsisdiv> |
55 | ||
56 | <refsect1> | |
57 | <title>Description</title> | |
58 | ||
aa2e348d ZJS |
59 | <para><command>systemd-tmpfiles</command> creates, deletes, and cleans up volatile and temporary files |
60 | and directories, using the configuration file format and location specified in | |
61 | <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>. It must | |
62 | be invoked with one or more options <option>--create</option>, <option>--remove</option>, and | |
63 | <option>--clean</option>, to select the respective subset of operations.</para> | |
798d3a52 | 64 | |
aa2e348d ZJS |
65 | <para>By default, directives from all configuration files are applied. When invoked with |
66 | <option>--replace=<replaceable>PATH</replaceable></option>, arguments specified on the command line are | |
67 | used instead of the configuration file <replaceable>PATH</replaceable>. Otherwise, if one or more | |
68 | absolute filenames are passed on the command line, only the directives in these files are applied. If | |
69 | <literal>-</literal> is specified instead of a filename, directives are read from standard input. If only | |
70 | the basename of a configuration file is specified, all configuration directories as specified in | |
71 | <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> are | |
72 | searched for a matching file and the file found that has the highest priority is executed.</para> | |
72703632 ZJS |
73 | |
74 | <para>System services (<filename>systemd-tmpfiles-setup.service</filename>, | |
bb7f485f | 75 | <filename>systemd-tmpfiles-setup-dev-early.service</filename>, |
72703632 ZJS |
76 | <filename>systemd-tmpfiles-setup-dev.service</filename>, |
77 | <filename>systemd-tmpfiles-clean.service</filename>) invoke <command>systemd-tmpfiles</command> to create | |
78 | system files and to perform system wide cleanup. Those services read administrator-controlled | |
79 | configuration files in <filename>tmpfiles.d/</filename> directories. User services | |
80 | (<filename>systemd-tmpfiles-setup.service</filename>, | |
81 | <filename>systemd-tmpfiles-clean.service</filename>) also invoke <command>systemd-tmpfiles</command>, but | |
82 | it reads a separate set of files, which includes user-controlled files under | |
83 | <filename>~/.config/user-tmpfiles.d/</filename> and <filename>~/.local/share/user-tmpfiles.d/</filename>, | |
c2892a24 | 84 | and administrator-controlled files under <filename>/usr/share/user-tmpfiles.d/</filename>. Users may use |
72703632 ZJS |
85 | this to create and clean up files under their control, but the system instance performs global cleanup |
86 | and is not influenced by user configuration. Note that this means a time-based cleanup configured in the | |
3b121157 ZJS |
87 | system instance, such as the one typically configured for <filename>/tmp/</filename>, will thus also |
88 | affect files created by the user instance if they are placed in <filename>/tmp/</filename>, even if the | |
72703632 | 89 | user instance's time-based cleanup is turned off.</para> |
36f57e02 | 90 | |
aa2e348d ZJS |
91 | <para>To re-apply settings after configuration has been modified, simply restart |
92 | <filename>systemd-tmpfiles-clean.service</filename>, which will apply any settings which can be safely | |
93 | executed at runtime. To debug <command>systemd-tmpfiles</command>, it may be useful to invoke it | |
94 | directly from the command line with increased log level (see <varname>$SYSTEMD_LOG_LEVEL</varname> | |
95 | below).</para> | |
798d3a52 ZJS |
96 | </refsect1> |
97 | ||
98 | <refsect1> | |
99 | <title>Options</title> | |
100 | ||
101 | <para>The following options are understood:</para> | |
102 | ||
103 | <variablelist> | |
104 | <varlistentry> | |
105 | <term><option>--create</option></term> | |
106 | <listitem><para>If this option is passed, all files and | |
107 | directories marked with | |
108 | <varname>f</varname>, | |
109 | <varname>F</varname>, | |
110 | <varname>w</varname>, | |
111 | <varname>d</varname>, | |
112 | <varname>D</varname>, | |
113 | <varname>v</varname>, | |
114 | <varname>p</varname>, | |
115 | <varname>L</varname>, | |
116 | <varname>c</varname>, | |
117 | <varname>b</varname>, | |
118 | <varname>m</varname> | |
119 | in the configuration files are created or written to. Files | |
120 | and directories marked with | |
121 | <varname>z</varname>, | |
122 | <varname>Z</varname>, | |
123 | <varname>t</varname>, | |
124 | <varname>T</varname>, | |
125 | <varname>a</varname>, and | |
126 | <varname>A</varname> have their ownership, access mode and | |
f2b5ca0e | 127 | security labels set.</para></listitem> |
798d3a52 ZJS |
128 | </varlistentry> |
129 | ||
130 | <varlistentry> | |
131 | <term><option>--clean</option></term> | |
132 | <listitem><para>If this option is passed, all files and | |
133 | directories with an age parameter configured will be cleaned | |
134 | up.</para></listitem> | |
135 | </varlistentry> | |
136 | ||
137 | <varlistentry> | |
138 | <term><option>--remove</option></term> | |
139 | <listitem><para>If this option is passed, the contents of | |
140 | directories marked with <varname>D</varname> or | |
141 | <varname>R</varname>, and files or directories themselves | |
142 | marked with <varname>r</varname> or <varname>R</varname> are | |
65e179a1 DDM |
143 | removed unless an exclusive or shared BSD lock is taken on them (see <citerefentry |
144 | project='man-pages'><refentrytitle>flock</refentrytitle><manvolnum>2</manvolnum></citerefentry>). | |
145 | </para></listitem> | |
798d3a52 | 146 | </varlistentry> |
d9daae55 | 147 | |
81a18380 LB |
148 | <varlistentry> |
149 | <term><option>--purge</option></term> | |
150 | <listitem><para>If this option is passed, all files and directories created by a | |
151 | <filename>tmpfiles.d/</filename> entry will be deleted.</para> | |
152 | ||
153 | <xi:include href="version-info.xml" xpointer="v256"/></listitem> | |
154 | </varlistentry> | |
155 | ||
f2b5ca0e ZJS |
156 | <varlistentry> |
157 | <term><option>--user</option></term> | |
158 | <listitem><para>Execute "user" configuration, i.e. <filename>tmpfiles.d</filename> | |
ec07c3c8 AK |
159 | files in user configuration directories.</para> |
160 | ||
161 | <xi:include href="version-info.xml" xpointer="v236"/></listitem> | |
f2b5ca0e ZJS |
162 | </varlistentry> |
163 | ||
798d3a52 ZJS |
164 | <varlistentry> |
165 | <term><option>--boot</option></term> | |
a3256ea8 ZJS |
166 | <listitem><para>Also execute lines with an exclamation mark. Lines that are not safe to be executed |
167 | on a running system may be marked in this way. <command>systemd-tmpfiles</command> is executed in | |
168 | early boot with <option>--boot</option> specified and will execute those lines. When invoked again | |
ec07c3c8 AK |
169 | later, it should be called without <option>--boot</option>.</para> |
170 | ||
171 | <xi:include href="version-info.xml" xpointer="v209"/></listitem> | |
798d3a52 | 172 | </varlistentry> |
d9daae55 | 173 | |
e0ea6af3 ZJS |
174 | <varlistentry> |
175 | <term><option>--graceful</option></term> | |
176 | <listitem><para>Ignore configuration lines pertaining to unknown users or groups. This option is | |
ec07c3c8 AK |
177 | intended to be used in early boot before all users or groups have been created.</para> |
178 | ||
179 | <xi:include href="version-info.xml" xpointer="v254"/></listitem> | |
e0ea6af3 ZJS |
180 | </varlistentry> |
181 | ||
798d3a52 ZJS |
182 | <varlistentry> |
183 | <term><option>--prefix=<replaceable>path</replaceable></option></term> | |
184 | <listitem><para>Only apply rules with paths that start with | |
185 | the specified prefix. This option can be specified multiple | |
ec07c3c8 AK |
186 | times.</para> |
187 | ||
188 | <xi:include href="version-info.xml" xpointer="v212"/></listitem> | |
798d3a52 | 189 | </varlistentry> |
dd04fb32 | 190 | |
798d3a52 ZJS |
191 | <varlistentry> |
192 | <term><option>--exclude-prefix=<replaceable>path</replaceable></option></term> | |
193 | <listitem><para>Ignore rules with paths that start with the | |
194 | specified prefix. This option can be specified multiple | |
ec07c3c8 AK |
195 | times.</para> |
196 | ||
aefdc112 | 197 | <xi:include href="version-info.xml" xpointer="v207"/></listitem> |
798d3a52 | 198 | </varlistentry> |
3e54b900 | 199 | |
dd04fb32 LP |
200 | <varlistentry> |
201 | <term><option>-E</option></term> | |
202 | <listitem><para>A shortcut for <literal>--exclude-prefix=/dev --exclude-prefix=/proc | |
203 | --exclude-prefix=/run --exclude-prefix=/sys</literal>, i.e. exclude the hierarchies typically backed | |
204 | by virtual or memory file systems. This is useful in combination with <option>--root=</option>, if | |
205 | the specified directory tree contains an OS tree without these virtual/memory file systems mounted | |
206 | in, as it is typically not desirable to create any files and directories below these subdirectories | |
ec07c3c8 AK |
207 | if they are supposed to be overmounted during runtime.</para> |
208 | ||
209 | <xi:include href="version-info.xml" xpointer="v247"/></listitem> | |
dd04fb32 LP |
210 | </varlistentry> |
211 | ||
798d3a52 ZJS |
212 | <varlistentry> |
213 | <term><option>--root=<replaceable>root</replaceable></option></term> | |
3e54b900 LP |
214 | <listitem><para>Takes a directory path as an argument. All paths will be prefixed with the given alternate |
215 | <replaceable>root</replaceable> path, including config search paths.</para> | |
216 | ||
77a3cec0 LP |
217 | <para>When this option is used, the libc Name Service Switch (NSS) is bypassed for resolving users |
218 | and groups. Instead the files <filename>/etc/passwd</filename> and <filename>/etc/group</filename> | |
219 | inside the alternate root are read directly. This means that users/groups not listed in these files | |
dd04fb32 LP |
220 | will not be resolved, i.e. LDAP NIS and other complex databases are not considered.</para> |
221 | ||
222 | <para>Consider combining this with <option>-E</option> to ensure the invocation does not create files | |
223 | or directories below mount points in the OS image operated on that are typically overmounted during | |
ec07c3c8 AK |
224 | runtime.</para> |
225 | ||
226 | <xi:include href="version-info.xml" xpointer="v212"/></listitem> | |
798d3a52 ZJS |
227 | </varlistentry> |
228 | ||
71b1d2de LP |
229 | <varlistentry> |
230 | <term><option>--image=<replaceable>image</replaceable></option></term> | |
231 | ||
232 | <listitem><para>Takes a path to a disk image file or block device node. If specified all operations | |
233 | are applied to file system in the indicated disk image. This is similar to <option>--root=</option> | |
234 | but operates on file systems stored in disk images or block devices. The disk image should either | |
235 | contain just a file system or a set of file systems within a GPT partition table, following the | |
db811444 | 236 | <ulink url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">Discoverable Partitions |
71b1d2de LP |
237 | Specification</ulink>. For further information on supported disk images, see |
238 | <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s | |
239 | switch of the same name.</para> | |
240 | ||
ec07c3c8 AK |
241 | <para>Implies <option>-E</option>.</para> |
242 | ||
243 | <xi:include href="version-info.xml" xpointer="v247"/></listitem> | |
71b1d2de LP |
244 | </varlistentry> |
245 | ||
9ea81191 LP |
246 | <xi:include href="standard-options.xml" xpointer="image-policy-open" /> |
247 | ||
a6d8474f ZJS |
248 | <varlistentry> |
249 | <term><option>--replace=<replaceable>PATH</replaceable></option></term> | |
ba669952 | 250 | <listitem><para>When this option is given, one or more positional arguments |
a6d8474f ZJS |
251 | must be specified. All configuration files found in the directories listed in |
252 | <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
253 | will be read, and the configuration given on the command line will be | |
254 | handled instead of and with the same priority as the configuration file | |
255 | <replaceable>PATH</replaceable>.</para> | |
256 | ||
257 | <para>This option is intended to be used when package installation scripts | |
258 | are running and files belonging to that package are not yet available on | |
259 | disk, so their contents must be given on the command line, but the admin | |
260 | configuration might already exist and should be given higher priority. | |
ec07c3c8 AK |
261 | </para> |
262 | ||
263 | <xi:include href="version-info.xml" xpointer="v238"/></listitem> | |
a6d8474f ZJS |
264 | </varlistentry> |
265 | ||
ceaaeb9b | 266 | <xi:include href="standard-options.xml" xpointer="cat-config" /> |
1be6a5db | 267 | <xi:include href="standard-options.xml" xpointer="tldr" /> |
dcd5c891 | 268 | <xi:include href="standard-options.xml" xpointer="no-pager" /> |
798d3a52 ZJS |
269 | <xi:include href="standard-options.xml" xpointer="help" /> |
270 | <xi:include href="standard-options.xml" xpointer="version" /> | |
271 | </variablelist> | |
272 | ||
bdee3f55 | 273 | <para>It is possible to combine <option>--create</option>, <option>--clean</option>, and <option>--remove</option> |
72703632 | 274 | in one invocation (in which case removal and cleanup are executed before creation of new files). For example, |
bdee3f55 | 275 | during boot the following command line is executed to ensure that all temporary and volatile directories are |
798d3a52 ZJS |
276 | removed and created according to the configuration file:</para> |
277 | ||
278 | <programlisting>systemd-tmpfiles --remove --create</programlisting> | |
798d3a52 ZJS |
279 | </refsect1> |
280 | ||
1d77721f LP |
281 | <refsect1> |
282 | <title>Credentials</title> | |
283 | ||
284 | <para><command>systemd-tmpfiles</command> supports the service credentials logic as implemented by | |
bbfb25f4 DDM |
285 | <varname>ImportCredential=</varname>/<varname>LoadCredential=</varname>/<varname>SetCredential=</varname> |
286 | (see <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>1</manvolnum></citerefentry> for | |
1d77721f LP |
287 | details). The following credentials are used when passed in:</para> |
288 | ||
8914f7e8 | 289 | <variablelist class='system-credentials'> |
1d77721f | 290 | <varlistentry> |
8914f7e8 | 291 | <term><varname>tmpfiles.extra</varname></term> |
1d77721f LP |
292 | |
293 | <listitem><para> The contents of this credential may contain additional lines to operate on. The | |
294 | credential contents should follow the same format as any other <filename>tmpfiles.d/</filename> | |
295 | drop-in configuration file. If this credential is passed it is processed after all of the drop-in | |
296 | files read from the file system. The lines in the credential can hence augment existing lines of the | |
ec07c3c8 AK |
297 | OS, but not override them.</para> |
298 | ||
299 | <xi:include href="version-info.xml" xpointer="v252"/></listitem> | |
1d77721f LP |
300 | </varlistentry> |
301 | </variablelist> | |
302 | ||
303 | <para>Note that by default the <filename>systemd-tmpfiles-setup.service</filename> unit file (and related | |
304 | unit files) is set up to inherit the <literal>tmpfiles.extra</literal> credential from the service | |
305 | manager.</para> | |
306 | </refsect1> | |
307 | ||
36f57e02 ZJS |
308 | <refsect1> |
309 | <title>Environment</title> | |
310 | ||
311 | <variablelist class='environment-variables'> | |
312 | <xi:include href="common-variables.xml" xpointer="log-level" /> | |
313 | <xi:include href="common-variables.xml" xpointer="log-color" /> | |
314 | <xi:include href="common-variables.xml" xpointer="log-time" /> | |
315 | <xi:include href="common-variables.xml" xpointer="log-location" /> | |
316 | <xi:include href="common-variables.xml" xpointer="log-target" /> | |
317 | <xi:include href="common-variables.xml" xpointer="pager" /> | |
318 | <xi:include href="common-variables.xml" xpointer="less" /> | |
319 | <xi:include href="common-variables.xml" xpointer="lesscharset" /> | |
320 | <xi:include href="common-variables.xml" xpointer="lesssecure" /> | |
321 | <xi:include href="common-variables.xml" xpointer="colors" /> | |
322 | <xi:include href="common-variables.xml" xpointer="urlify" /> | |
323 | </variablelist> | |
324 | </refsect1> | |
325 | ||
798d3a52 ZJS |
326 | <refsect1> |
327 | <title>Unprivileged --cleanup operation</title> | |
328 | ||
329 | <para><command>systemd-tmpfiles</command> tries to avoid changing | |
330 | the access and modification times on the directories it accesses, | |
3c84514d | 331 | which requires <constant>CAP_FOWNER</constant> privileges. When |
798d3a52 ZJS |
332 | running as non-root, directories which are checked for files to |
333 | clean up will have their access time bumped, which might prevent | |
334 | their cleanup. | |
335 | </para> | |
336 | </refsect1> | |
337 | ||
338 | <refsect1> | |
339 | <title>Exit status</title> | |
340 | ||
b88ba6c7 ZJS |
341 | <para>On success, 0 is returned. If the configuration was syntactically invalid (syntax errors, missing |
342 | arguments, …), so some lines had to be ignored, but no other errors occurred, <constant>65</constant> is | |
343 | returned (<constant>EX_DATAERR</constant> from <filename>/usr/include/sysexits.h</filename>). If the | |
344 | configuration was syntactically valid, but could not be executed (lack of permissions, creation of files | |
345 | in missing directories, invalid contents when writing to <filename>/sys/</filename> values, …), | |
346 | <constant>73</constant> is returned (<constant>EX_CANTCREAT</constant> from | |
347 | <filename>/usr/include/sysexits.h</filename>). Otherwise, <constant>1</constant> is returned | |
348 | (<constant>EXIT_FAILURE</constant> from <filename>/usr/include/stdlib.h</filename>).</para> | |
349 | ||
350 | <para>Note: when creating items, if the target already exists, but is of the wrong type or otherwise does | |
351 | not match the requested state, and forced operation has not been requested with <literal>+</literal>, | |
352 | a message is emitted, but the failure is otherwise ignored.</para> | |
798d3a52 ZJS |
353 | </refsect1> |
354 | ||
355 | <refsect1> | |
356 | <title>See Also</title> | |
13a69c12 DT |
357 | <para><simplelist type="inline"> |
358 | <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> | |
359 | <member><citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> | |
360 | </simplelist></para> | |
798d3a52 | 361 | </refsect1> |
522d4a49 LP |
362 | |
363 | </refentry> |