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