mirror of
https://git.proxmox.com/git/systemd
synced 2025-06-03 15:55:00 +00:00
295 lines
28 KiB
HTML
295 lines
28 KiB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>tmpfiles.d</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
|
||
a.headerlink {
|
||
color: #c60f0f;
|
||
font-size: 0.8em;
|
||
padding: 0 4px 0 4px;
|
||
text-decoration: none;
|
||
visibility: hidden;
|
||
}
|
||
|
||
a.headerlink:hover {
|
||
background-color: #c60f0f;
|
||
color: white;
|
||
}
|
||
|
||
h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
|
||
visibility: visible;
|
||
}
|
||
</style><a href="index.html">Index </a>·
|
||
<a href="systemd.directives.html">Directives </a>·
|
||
<a href="../python-systemd/index.html">Python </a>·
|
||
<a href="../libudev/index.html">libudev </a>·
|
||
<a href="../libudev/index.html">gudev </a><span style="float:right">systemd 217</span><hr><div class="refentry"><a name="tmpfiles.d"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>tmpfiles.d — Configuration for creation, deletion and
|
||
cleaning of volatile and temporary files</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><p><code class="filename">/etc/tmpfiles.d/*.conf</code></p><p><code class="filename">/run/tmpfiles.d/*.conf</code></p><p><code class="filename">/usr/lib/tmpfiles.d/*.conf</code></p></div><div class="refsect1"><a name="idm214198140992"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description">¶</a></h2><p><span class="command"><strong>systemd-tmpfiles</strong></span> uses the
|
||
configuration files from the above directories to describe the
|
||
creation, cleaning and removal of volatile and
|
||
temporary files and directories which usually reside
|
||
in directories such as <code class="filename">/run</code>
|
||
or <code class="filename">/tmp</code>.</p><p>Volatile and temporary files and directories are
|
||
those located in <code class="filename">/run</code> (and its
|
||
alias <code class="filename">/var/run</code>),
|
||
<code class="filename">/tmp</code>,
|
||
<code class="filename">/var/tmp</code>, the API file systems
|
||
such as <code class="filename">/sys</code> or
|
||
<code class="filename">/proc</code>, as well as some other
|
||
directories below <code class="filename">/var</code>.</p><p>System daemons frequently require private
|
||
runtime directories below <code class="filename">/run</code> to
|
||
place communication sockets and similar in. For these,
|
||
consider declaring them in their unit files using
|
||
<code class="varname">RuntimeDirectory=</code>
|
||
(see <a href="systemd.exec.html"><span class="citerefentry"><span class="refentrytitle">systemd.exec</span>(5)</span></a> for details),
|
||
if this is feasible.</p></div><div class="refsect1"><a name="idm214198129728"></a><h2 id="Configuration Format">Configuration Format<a class="headerlink" title="Permalink to this headline" href="#Configuration%20Format">¶</a></h2><p>Each configuration file shall be named in the
|
||
style of
|
||
<code class="filename"><em class="replaceable"><code>package</code></em>.conf</code>
|
||
or
|
||
<code class="filename"><em class="replaceable"><code>package</code></em>-<em class="replaceable"><code>part</code></em>.conf</code>.
|
||
The second variant should be used when it is desirable
|
||
to make it easy to override just this part of
|
||
configuration.</p><p>Files in <code class="filename">/etc/tmpfiles.d</code>
|
||
override files with the same name in
|
||
<code class="filename">/usr/lib/tmpfiles.d</code> and
|
||
<code class="filename">/run/tmpfiles.d</code>. Files in
|
||
<code class="filename">/run/tmpfiles.d</code> override files
|
||
with the same name in
|
||
<code class="filename">/usr/lib/tmpfiles.d</code>. Packages
|
||
should install their configuration files in
|
||
<code class="filename">/usr/lib/tmpfiles.d</code>. Files in
|
||
<code class="filename">/etc/tmpfiles.d</code> are reserved for
|
||
the local administrator, who may use this logic to
|
||
override the configuration files installed by vendor
|
||
packages. All configuration files are sorted by their
|
||
filename in lexicographic order, regardless of which
|
||
of the directories they reside in. If multiple files
|
||
specify the same path, the entry in the file with the
|
||
lexicographically earliest name will be applied, all
|
||
all other conflicting entries will be logged as
|
||
errors. When two lines are prefix and suffix of each
|
||
other, then the prefix is always processed first, the
|
||
suffix later. Otherwise, the files/directories are
|
||
processed in the order they are listed.</p><p>If the administrator wants to disable a
|
||
configuration file supplied by the vendor, the
|
||
recommended way is to place a symlink to
|
||
<code class="filename">/dev/null</code> in
|
||
<code class="filename">/etc/tmpfiles.d/</code> bearing the
|
||
same filename.</p><p>The configuration format is one line per path
|
||
containing type, path, mode, ownership, age, and argument
|
||
fields:</p><pre class="programlisting">#Type Path Mode UID GID Age Argument
|
||
d /run/user 0755 root root 10d -
|
||
L /tmp/foobar - - - - /dev/null</pre><div class="refsect2"><a name="idm214202069296"></a><h3 id="Type">Type<a class="headerlink" title="Permalink to this headline" href="#Type">¶</a></h3><p>The type consists of a single letter and
|
||
optionally an exclamation mark.</p><p>The following line types are understood:</p><div class="variablelist"><dl class="variablelist"><dt id="f"><span class="term"><code class="varname">f</code></span><a class="headerlink" title="Permalink to this term" href="#f">¶</a></dt><dd><p>Create a file if it does not exist yet. If the argument parameter is given, it will be written to the file.</p></dd><dt id="F"><span class="term"><code class="varname">F</code></span><a class="headerlink" title="Permalink to this term" href="#F">¶</a></dt><dd><p>Create or truncate a file. If the argument parameter is given, it will be written to the file.</p></dd><dt id="w"><span class="term"><code class="varname">w</code></span><a class="headerlink" title="Permalink to this term" href="#w">¶</a></dt><dd><p>Write the argument parameter to a file, if the file exists.
|
||
Lines of this type accept shell-style globs in place of normal path
|
||
names. The argument parameter will be written without a trailing
|
||
newline. C-style backslash escapes are interpreted.</p></dd><dt id="d"><span class="term"><code class="varname">d</code></span><a class="headerlink" title="Permalink to this term" href="#d">¶</a></dt><dd><p>Create a directory if it does not exist yet.</p></dd><dt id="D"><span class="term"><code class="varname">D</code></span><a class="headerlink" title="Permalink to this term" href="#D">¶</a></dt><dd><p>Create or empty a directory.</p></dd><dt id="p"><span class="term"><code class="varname">p</code>, </span><span class="term"><code class="varname">p+</code></span><a class="headerlink" title="Permalink to this term" href="#p">¶</a></dt><dd><p>Create a named
|
||
pipe (FIFO) if it does not
|
||
exist yet. If suffixed with
|
||
<code class="varname">+</code> and a
|
||
file already exists where the
|
||
pipe is to be created, it will
|
||
be removed and be replaced by
|
||
the pipe.</p></dd><dt id="L"><span class="term"><code class="varname">L</code>, </span><span class="term"><code class="varname">L+</code></span><a class="headerlink" title="Permalink to this term" href="#L">¶</a></dt><dd><p>Create a
|
||
symlink if it does not exist
|
||
yet. If suffixed with
|
||
<code class="varname">+</code> and a
|
||
file already exists where the
|
||
symlink is to be created, it
|
||
will be removed and be
|
||
replaced by the
|
||
symlink. If the argument is omitted,
|
||
symlinks to files with the same name
|
||
residing in the directory
|
||
<code class="filename">/usr/share/factory/</code>
|
||
are created.</p></dd><dt id="c"><span class="term"><code class="varname">c</code>, </span><span class="term"><code class="varname">c+</code></span><a class="headerlink" title="Permalink to this term" href="#c">¶</a></dt><dd><p>Create a
|
||
character device node if it
|
||
does not exist yet. If
|
||
suffixed with
|
||
<code class="varname">+</code> and a
|
||
file already exists where the
|
||
device node is to be created,
|
||
it will be removed and be
|
||
replaced by the device
|
||
node. It is recommended to suffix this
|
||
entry with an exclamation mark to only
|
||
create static device nodes at boot,
|
||
as udev will not manage static device
|
||
nodes that are created at runtime.
|
||
</p></dd><dt id="b"><span class="term"><code class="varname">b</code>, </span><span class="term"><code class="varname">b+</code></span><a class="headerlink" title="Permalink to this term" href="#b">¶</a></dt><dd><p>Create a block
|
||
device node if it does not
|
||
exist yet. If suffixed with
|
||
<code class="varname">+</code> and a
|
||
file already exists where the
|
||
device node is to be created,
|
||
it will be removed and be
|
||
replaced by the device
|
||
node. It is recommended to suffix this
|
||
entry with an exclamation mark to only
|
||
create static device nodes at boot,
|
||
as udev will not manage static device
|
||
nodes that are created at runtime.
|
||
</p></dd><dt id="C"><span class="term"><code class="varname">C</code></span><a class="headerlink" title="Permalink to this term" href="#C">¶</a></dt><dd><p>Recursively
|
||
copy a file or directory, if
|
||
the destination files or
|
||
directories do not exist
|
||
yet. Note that this command
|
||
will not descend into
|
||
subdirectories if the
|
||
destination directory already
|
||
exists. Instead, the entire
|
||
copy operation is
|
||
skipped. If the argument is omitted,
|
||
files from the source directory
|
||
<code class="filename">/usr/share/factory/</code>
|
||
with the same name are copied.</p></dd><dt id="x"><span class="term"><code class="varname">x</code></span><a class="headerlink" title="Permalink to this term" href="#x">¶</a></dt><dd><p>Ignore a path
|
||
during cleaning. Use this type
|
||
to exclude paths from clean-up
|
||
as controlled with the Age
|
||
parameter. Note that lines of
|
||
this type do not influence the
|
||
effect of <code class="varname">r</code>
|
||
or <code class="varname">R</code> lines.
|
||
Lines of this type accept
|
||
shell-style globs in place of
|
||
normal path names.
|
||
</p></dd><dt id="X"><span class="term"><code class="varname">X</code></span><a class="headerlink" title="Permalink to this term" href="#X">¶</a></dt><dd><p>Ignore a path
|
||
during cleaning. Use this type
|
||
to exclude paths from clean-up
|
||
as controlled with the Age
|
||
parameter. Unlike
|
||
<code class="varname">x</code>, this
|
||
parameter will not exclude the
|
||
content if path is a
|
||
directory, but only directory
|
||
itself. Note that lines of
|
||
this type do not influence the
|
||
effect of <code class="varname">r</code>
|
||
or <code class="varname">R</code> lines.
|
||
Lines of this type accept
|
||
shell-style globs in place of
|
||
normal path names.
|
||
</p></dd><dt id="r"><span class="term"><code class="varname">r</code></span><a class="headerlink" title="Permalink to this term" href="#r">¶</a></dt><dd><p>Remove a file
|
||
or directory if it exists.
|
||
This may not be used to remove
|
||
non-empty directories, use
|
||
<code class="varname">R</code> for that.
|
||
Lines of this type accept
|
||
shell-style globs in place of
|
||
normal path
|
||
names.</p></dd><dt id="R"><span class="term"><code class="varname">R</code></span><a class="headerlink" title="Permalink to this term" href="#R">¶</a></dt><dd><p>Recursively
|
||
remove a path and all its
|
||
subdirectories (if it is a
|
||
directory). Lines of this type
|
||
accept shell-style globs in
|
||
place of normal path
|
||
names.</p></dd><dt id="z"><span class="term"><code class="varname">z</code></span><a class="headerlink" title="Permalink to this term" href="#z">¶</a></dt><dd><p>Adjust the
|
||
access mode, group and user,
|
||
and restore the SELinux security
|
||
context of a file or directory,
|
||
if it exists. Lines of this
|
||
type accept shell-style globs
|
||
in place of normal path names.
|
||
</p></dd><dt id="Z"><span class="term"><code class="varname">Z</code></span><a class="headerlink" title="Permalink to this term" href="#Z">¶</a></dt><dd><p>Recursively
|
||
set the access mode, group and
|
||
user, and restore the SELinux
|
||
security context of a file or
|
||
directory if it exists, as
|
||
well as of its subdirectories
|
||
and the files contained
|
||
therein (if applicable). Lines
|
||
of this type accept
|
||
shell-style globs in place of
|
||
normal path
|
||
names.</p></dd></dl></div><p>If the exclamation mark is used, this
|
||
line is only safe of execute during boot, and
|
||
can break a running system. Lines without the
|
||
exclamation mark are presumed to be safe to
|
||
execute at any time, e.g. on package upgrades.
|
||
<span class="command"><strong>systemd-tmpfiles</strong></span> will
|
||
execute line with an exclamation mark only if
|
||
option <code class="option">--boot</code> is given.
|
||
</p><p>For example:
|
||
</p><pre class="programlisting"># Make sure these are created by default so that nobody else can
|
||
d /tmp/.X11-unix 1777 root root 10d
|
||
|
||
# Unlink the X11 lock files
|
||
r! /tmp/.X[0-9]*-lock</pre><p>
|
||
The second line in contrast to the first one
|
||
would break a running system, and will only be
|
||
executed with <code class="option">--boot</code>.</p></div><div class="refsect2"><a name="idm214197043056"></a><h3 id="Path">Path<a class="headerlink" title="Permalink to this headline" href="#Path">¶</a></h3><p>The file system path specification supports simple specifier
|
||
expansion. The following expansions are
|
||
understood:</p><div class="table"><a name="idm214197041856"></a><p class="title"><b>Table 1. Specifiers available</b></p><div class="table-contents"><table summary="Specifiers available" border="1"><colgroup><col align="left" class="spec"><col align="left" class="mean"><col align="left" class="detail"></colgroup><thead><tr><th align="left">Specifier</th><th align="left">Meaning</th><th align="left">Details</th></tr></thead><tbody><tr><td align="left">"<code class="literal">%m</code>"</td><td align="left">Machine ID</td><td align="left">The machine ID of the running system, formatted as string. See <a href="machine-id.html"><span class="citerefentry"><span class="refentrytitle">machine-id</span>(5)</span></a> for more information.</td></tr><tr><td align="left">"<code class="literal">%b</code>"</td><td align="left">Boot ID</td><td align="left">The boot ID of the running system, formatted as string. See <a href="http://man7.org/linux/man-pages/man4/random.4.html"><span class="citerefentry"><span class="refentrytitle">random</span>(4)</span></a> for more information.</td></tr><tr><td align="left">"<code class="literal">%H</code>"</td><td align="left">Host name</td><td align="left">The hostname of the running system.</td></tr><tr><td align="left">"<code class="literal">%v</code>"</td><td align="left">Kernel release</td><td align="left">Identical to <span class="command"><strong>uname -r</strong></span> output.</td></tr><tr><td align="left">"<code class="literal">%%</code>"</td><td align="left">Escaped %</td><td align="left">Single percent sign.</td></tr></tbody></table></div></div><br class="table-break"></div><div class="refsect2"><a name="idm214197024048"></a><h3 id="Mode">Mode<a class="headerlink" title="Permalink to this headline" href="#Mode">¶</a></h3><p>The file access mode to use when
|
||
creating this file or directory. If omitted or
|
||
when set to -, the default is used: 0755 for
|
||
directories, 0644 for all other file objects.
|
||
For <code class="varname">z</code>, <code class="varname">Z</code>
|
||
lines, if omitted or when set to
|
||
"<code class="literal">-</code>", the file access mode
|
||
will not be modified. This parameter is
|
||
ignored for <code class="varname">x</code>,
|
||
<code class="varname">r</code>, <code class="varname">R</code>,
|
||
<code class="varname">L</code> lines.</p><p>Optionally, if prefixed with
|
||
"<code class="literal">~</code>", the access mode is masked
|
||
based on the already set access bits for
|
||
existing file or directories: if the existing
|
||
file has all executable bits unset, all
|
||
executable bits are removed from the new
|
||
access mode, too. Similarly, if all read bits
|
||
are removed from the old access mode, they will
|
||
be removed from the new access mode too, and
|
||
if all write bits are removed, they will be
|
||
removed from the new access mode too. In
|
||
addition, the sticky/SUID/SGID bit is removed unless
|
||
applied to a directory. This
|
||
functionality is particularly useful in
|
||
conjunction with <code class="varname">Z</code>.</p></div><div class="refsect2"><a name="idm214197017168"></a><h3 id="UID, GID">UID, GID<a class="headerlink" title="Permalink to this headline" href="#UID,%20GID">¶</a></h3><p>The user and group to use for this file
|
||
or directory. This may either be a numeric
|
||
user/group ID or a user or group name. If
|
||
omitted or when set to "<code class="literal">-</code>",
|
||
the default 0 (root) is used. For
|
||
<code class="varname">z</code>, <code class="varname">Z</code>
|
||
lines, when omitted or when set to -, the file
|
||
ownership will not be modified. These
|
||
parameters are ignored for
|
||
<code class="varname">x</code>, <code class="varname">r</code>,
|
||
<code class="varname">R</code>, <code class="varname">L</code>
|
||
lines.</p></div><div class="refsect2"><a name="idm214197012528"></a><h3 id="Age">Age<a class="headerlink" title="Permalink to this headline" href="#Age">¶</a></h3><p>The date field, when set, is used to
|
||
decide what files to delete when cleaning. If
|
||
a file or directory is older than the current
|
||
time minus the age field, it is deleted. The
|
||
field format is a series of integers each
|
||
followed by one of the following
|
||
postfixes for the respective time units:</p><div class="variablelist"><dl class="variablelist"><dt id="s"><span class="term"><code class="varname">s</code>, </span><span class="term"><code class="varname">min</code>, </span><span class="term"><code class="varname">h</code>, </span><span class="term"><code class="varname">d</code>, </span><span class="term"><code class="varname">w</code>, </span><span class="term"><code class="varname">ms</code>, </span><span class="term"><code class="varname">m</code>, </span><span class="term"><code class="varname">us</code></span><a class="headerlink" title="Permalink to this term" href="#s">¶</a></dt><dd></dd></dl></div><p>If multiple integers and units are specified, the time
|
||
values are summed up. If an integer is given without a unit,
|
||
s is assumed.
|
||
</p><p>When the age is set to zero, the files are cleaned
|
||
unconditionally.</p><p>The age field only applies to lines
|
||
starting with <code class="varname">d</code>,
|
||
<code class="varname">D</code>, and
|
||
<code class="varname">x</code>. If omitted or set to
|
||
"<code class="literal">-</code>", no automatic clean-up is
|
||
done.</p><p>If the age field starts with a tilde
|
||
character "<code class="literal">~</code>", the clean-up
|
||
is only applied to files and directories one
|
||
level inside the directory specified, but not
|
||
the files and directories immediately inside
|
||
it.</p></div><div class="refsect2"><a name="idm214197001392"></a><h3 id="Argument">Argument<a class="headerlink" title="Permalink to this headline" href="#Argument">¶</a></h3><p>For <code class="varname">L</code> lines
|
||
determines the destination path of the
|
||
symlink. For <code class="varname">c</code>,
|
||
<code class="varname">b</code> determines the
|
||
major/minor of the device node, with major and
|
||
minor formatted as integers, separated by
|
||
"<code class="literal">:</code>", e.g.
|
||
"<code class="literal">1:3</code>". For
|
||
<code class="varname">f</code>, <code class="varname">F</code>,
|
||
and <code class="varname">w</code> may be used to
|
||
specify a short string that is written to the
|
||
file, suffixed by a newline. For
|
||
<code class="varname">C</code>, specifies the source file
|
||
or directory. Ignored for all other
|
||
lines.</p></div></div><div class="refsect1"><a name="idm214196995552"></a><h2 id="Example">Example<a class="headerlink" title="Permalink to this headline" href="#Example">¶</a></h2><div class="example"><a name="idm214196994912"></a><p class="title"><b>Example 1. /etc/tmpfiles.d/screen.conf example</b></p><div class="example-contents"><p><span class="command"><strong>screen</strong></span> needs two directories created at boot with specific modes and ownership.</p><pre class="programlisting">d /run/screens 1777 root root 10d
|
||
d /run/uscreens 0755 root root 10d12h</pre></div></div><br class="example-break"><div class="example"><a name="idm214196992448"></a><p class="title"><b>Example 2. /etc/tmpfiles.d/abrt.conf example</b></p><div class="example-contents"><p><span class="command"><strong>abrt</strong></span> needs a directory created at boot with specific mode and ownership and its content should be preserved.</p><pre class="programlisting">d /var/tmp/abrt 0755 abrt abrt
|
||
x /var/tmp/abrt/*</pre></div></div><br class="example-break"></div><div class="refsect1"><a name="idm214196989920"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p>
|
||
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
|
||
<a href="systemd-tmpfiles.html"><span class="citerefentry"><span class="refentrytitle">systemd-tmpfiles</span>(8)</span></a>,
|
||
<a href="systemd-delta.html"><span class="citerefentry"><span class="refentrytitle">systemd-delta</span>(1)</span></a>,
|
||
<a href="systemd.exec.html"><span class="citerefentry"><span class="refentrytitle">systemd.exec</span>(5)</span></a>
|
||
</p></div></div></body></html>
|