systemd/man/systemd.unit.html
2015-02-17 11:22:16 +01:00

812 lines
74 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>systemd.unit</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 219</span><hr><div class="refentry"><a name="systemd.unit"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>systemd.unit — Unit configuration</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><p><code class="filename"><em class="replaceable"><code>service</code></em>.service</code>,
<code class="filename"><em class="replaceable"><code>socket</code></em>.socket</code>,
<code class="filename"><em class="replaceable"><code>device</code></em>.device</code>,
<code class="filename"><em class="replaceable"><code>mount</code></em>.mount</code>,
<code class="filename"><em class="replaceable"><code>automount</code></em>.automount</code>,
<code class="filename"><em class="replaceable"><code>swap</code></em>.swap</code>,
<code class="filename"><em class="replaceable"><code>target</code></em>.target</code>,
<code class="filename"><em class="replaceable"><code>path</code></em>.path</code>,
<code class="filename"><em class="replaceable"><code>timer</code></em>.timer</code>,
<code class="filename"><em class="replaceable"><code>snapshot</code></em>.snapshot</code>,
<code class="filename"><em class="replaceable"><code>slice</code></em>.slice</code>,
<code class="filename"><em class="replaceable"><code>scope</code></em>.scope</code></p><div class="literallayout"><p><code class="filename">/etc/systemd/system/*</code><br>
<code class="filename">/run/systemd/system/*</code><br>
<code class="filename">/usr/lib/systemd/system/*</code><br>
<code class="filename">...</code><br>
    </p></div><div class="literallayout"><p><code class="filename">$XDG_CONFIG_HOME/systemd/user/*</code><br>
<code class="filename">$HOME/.config/systemd/user/*</code><br>
<code class="filename">/etc/systemd/user/*</code><br>
<code class="filename">$XDG_RUNTIME_DIR/systemd/user/*</code><br>
<code class="filename">/run/systemd/user/*</code><br>
<code class="filename">$XDG_DATA_HOME/systemd/user/*</code><br>
<code class="filename">$HOME/.local/share/systemd/user/*</code><br>
<code class="filename">/usr/lib/systemd/user/*</code><br>
<code class="filename">...</code><br>
    </p></div></div><div class="refsect1"><a name="idm139858338014656"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description"></a></h2><p>A unit configuration file encodes information about a
service, a socket, a device, a mount point, an automount point, a
swap file or partition, a start-up target, a watched file system
path, a timer controlled and supervised by
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
a temporary system state snapshot, a resource management slice or
a group of externally created processes. The syntax is inspired by
<a class="ulink" href="http://standards.freedesktop.org/desktop-entry-spec/latest/" target="_top">XDG
Desktop Entry Specification</a> <code class="filename">.desktop</code>
files, which are in turn inspired by Microsoft Windows
<code class="filename">.ini</code> files.</p><p>This man page lists the common configuration options of all
the unit types. These options need to be configured in the [Unit]
or [Install] sections of the unit files.</p><p>In addition to the generic [Unit] and [Install] sections
described here, each unit may have a type-specific section, e.g.
[Service] for a service unit. See the respective man pages for
more information:
<a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>,
<a href="systemd.socket.html"><span class="citerefentry"><span class="refentrytitle">systemd.socket</span>(5)</span></a>,
<a href="systemd.device.html"><span class="citerefentry"><span class="refentrytitle">systemd.device</span>(5)</span></a>,
<a href="systemd.mount.html"><span class="citerefentry"><span class="refentrytitle">systemd.mount</span>(5)</span></a>,
<a href="systemd.automount.html"><span class="citerefentry"><span class="refentrytitle">systemd.automount</span>(5)</span></a>,
<a href="systemd.swap.html"><span class="citerefentry"><span class="refentrytitle">systemd.swap</span>(5)</span></a>,
<a href="systemd.target.html"><span class="citerefentry"><span class="refentrytitle">systemd.target</span>(5)</span></a>,
<a href="systemd.path.html"><span class="citerefentry"><span class="refentrytitle">systemd.path</span>(5)</span></a>,
<a href="systemd.timer.html"><span class="citerefentry"><span class="refentrytitle">systemd.timer</span>(5)</span></a>,
<a href="systemd.snapshot.html"><span class="citerefentry"><span class="refentrytitle">systemd.snapshot</span>(5)</span></a>.
<a href="systemd.slice.html"><span class="citerefentry"><span class="refentrytitle">systemd.slice</span>(5)</span></a>.
<a href="systemd.scope.html"><span class="citerefentry"><span class="refentrytitle">systemd.scope</span>(5)</span></a>.
</p><p>Various settings are allowed to be specified more than once,
in which case the interpretation depends on the setting. Often,
multiple settings form a list, and setting to an empty value
"resets", which means that previous assignments are ignored. When
this is allowed, it is mentioned in the description of the
setting. Note that using multiple assignments to the same value
makes the unit file incompatible with parsers for the XDG
<code class="filename">.desktop</code> file format.</p><p>Unit files are loaded from a set of paths determined during
compilation, described in the next section.</p><p>Unit files may contain additional options on top of those
listed here. If systemd encounters an unknown option, it will
write a warning log message but continue loading the unit. If an
option or section name is prefixed with <code class="option">X-</code>, it is
ignored completely by systemd. Options within an ignored section
do not need the prefix. Applications may use this to include
additional information in the unit files.</p><p>Boolean arguments used in unit files can be written in
various formats. For positive settings the strings
<code class="option">1</code>, <code class="option">yes</code>, <code class="option">true</code>
and <code class="option">on</code> are equivalent. For negative settings, the
strings <code class="option">0</code>, <code class="option">no</code>,
<code class="option">false</code> and <code class="option">off</code> are
equivalent.</p><p>Time span values encoded in unit files can be written in
various formats. A stand-alone number specifies a time in seconds.
If suffixed with a time unit, the unit is honored. A concatenation
of multiple values with units is supported, in which case the
values are added up. Example: "50" refers to 50 seconds; "2min
200ms" refers to 2 minutes plus 200 milliseconds, i.e. 120200ms.
The following time units are understood: s, min, h, d, w, ms, us.
For details see
<a href="systemd.time.html"><span class="citerefentry"><span class="refentrytitle">systemd.time</span>(7)</span></a>.</p><p>Empty lines and lines starting with # or ; are
ignored. This may be used for commenting. Lines ending
in a backslash are concatenated with the following
line while reading and the backslash is replaced by a
space character. This may be used to wrap long lines.</p><p>Along with a unit file <code class="filename">foo.service</code>, the
directory <code class="filename">foo.service.wants/</code> may exist. All
unit files symlinked from such a directory are implicitly added as
dependencies of type <code class="varname">Wants=</code> to the unit. This
is useful to hook units into the start-up of other units, without
having to modify their unit files. For details about the semantics
of <code class="varname">Wants=</code>, see below. The preferred way to
create symlinks in the <code class="filename">.wants/</code> directory of a
unit file is with the <span class="command"><strong>enable</strong></span> command of the
<a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>
tool which reads information from the [Install] section of unit
files (see below). A similar functionality exists for
<code class="varname">Requires=</code> type dependencies as well, the
directory suffix is <code class="filename">.requires/</code> in this
case.</p><p>Along with a unit file <code class="filename">foo.service</code>, a
directory <code class="filename">foo.service.d/</code> may exist. All files
with the suffix "<code class="literal">.conf</code>" from this directory will
be parsed after the file itself is parsed. This is useful to alter
or add configuration settings to a unit, without having to modify
their unit files. Make sure that the file that is included has the
appropriate section headers before any directive. Note that for
instanced units this logic will first look for the instance
"<code class="literal">.d/</code>" subdirectory and read its
"<code class="literal">.conf</code>" files, followed by the template
"<code class="literal">.d/</code>" subdirectory and reads its
"<code class="literal">.conf</code>" files.</p><p>Note that while systemd offers a flexible dependency system
between units it is recommended to use this functionality only
sparingly and instead rely on techniques such as bus-based or
socket-based activation which make dependencies implicit,
resulting in a both simpler and more flexible system.</p><p>Some unit names reflect paths existing in the file system
namespace. Example: a device unit
<code class="filename">dev-sda.device</code> refers to a device with the
device node <code class="filename">/dev/sda</code> in the
file system namespace. If this applies, a special way to escape
the path name is used, so that the result is usable as part of a
filename. Basically, given a path, "/" is replaced by "-" and all
other characters which are not ASCII alphanumerics are replaced by
C-style "\x2d" escapes (except that "_" is never replaced and "."
is only replaced when it would be the first character in the
escaped path). The root directory "/" is encoded as single dash,
while otherwise the initial and ending "/" are removed from all
paths during transformation. This escaping is reversible. Properly
escaped paths can be generated using the
<a href="systemd-escape.html"><span class="citerefentry"><span class="refentrytitle">systemd-escape</span>(1)</span></a>
command.</p><p>Optionally, units may be instantiated from a
template file at runtime. This allows creation of
multiple units from a single configuration file. If
systemd looks for a unit configuration file, it will
first search for the literal unit name in the
file system. If that yields no success and the unit
name contains an "<code class="literal">@</code>" character, systemd will look for a
unit template that shares the same name but with the
instance string (i.e. the part between the "<code class="literal">@</code>" character
and the suffix) removed. Example: if a service
<code class="filename">getty@tty3.service</code> is requested
and no file by that name is found, systemd will look
for <code class="filename">getty@.service</code> and
instantiate a service from that configuration file if
it is found.</p><p>To refer to the instance string from within the
configuration file you may use the special "<code class="literal">%i</code>"
specifier in many of the configuration options. See below for
details.</p><p>If a unit file is empty (i.e. has the file size 0) or is
symlinked to <code class="filename">/dev/null</code>, its configuration
will not be loaded and it appears with a load state of
"<code class="literal">masked</code>", and cannot be activated. Use this as an
effective way to fully disable a unit, making it impossible to
start it even manually.</p><p>The unit file format is covered by the
<a class="ulink" href="http://www.freedesktop.org/wiki/Software/systemd/InterfaceStabilityPromise" target="_top">Interface
Stability Promise</a>.</p></div><div class="refsect1"><a name="idm139858333009952"></a><h2 id="Unit Load Path">Unit Load Path<a class="headerlink" title="Permalink to this headline" href="#Unit%20Load%20Path"></a></h2><p>Unit files are loaded from a set of paths determined during
compilation, described in the two tables below. Unit files found
in directories listed earlier override files with the same name in
directories lower in the list.</p><p>When systemd is running in user mode
(<code class="option">--user</code>) and the variable
<code class="varname">$SYSTEMD_UNIT_PATH</code> is set, the contents of this
variable overrides the unit load path. If
<code class="varname">$SYSTEMD_UNIT_PATH</code> ends with an empty component
("<code class="literal">:</code>"), the usual unit load path will be appended
to the contents of the variable.</p><div class="table"><a name="idm139858333006512"></a><p class="title"><b>Table 1. 
Load path when running in system mode (<code class="option">--system</code>).
</b></p><div class="table-contents"><table summary="
Load path when running in system mode (--system).
" border="1"><colgroup><col class="path"><col class="expl"></colgroup><thead><tr><th>Path</th><th>Description</th></tr></thead><tbody><tr><td><code class="filename">/etc/systemd/system</code></td><td>Local configuration</td></tr><tr><td><code class="filename">/run/systemd/system</code></td><td>Runtime units</td></tr><tr><td><code class="filename">/usr/lib/systemd/system</code></td><td>Units of installed packages</td></tr></tbody></table></div></div><br class="table-break"><div class="table"><a name="idm139858332997264"></a><p class="title"><b>Table 2. 
Load path when running in user mode (<code class="option">--user</code>).
</b></p><div class="table-contents"><table summary="
Load path when running in user mode (--user).
" border="1"><colgroup><col class="path"><col class="expl"></colgroup><thead><tr><th>Path</th><th>Description</th></tr></thead><tbody><tr><td><code class="filename">$XDG_CONFIG_HOME/systemd/user</code></td><td>User configuration (only used when $XDG_CONFIG_HOME is set)</td></tr><tr><td><code class="filename">$HOME/.config/systemd/user</code></td><td>User configuration (only used when $XDG_CONFIG_HOME is not set)</td></tr><tr><td><code class="filename">/etc/systemd/user</code></td><td>Local configuration</td></tr><tr><td><code class="filename">$XDG_RUNTIME_DIR/systemd/user</code></td><td>Runtime units (only used when $XDG_RUNTIME_DIR is set)</td></tr><tr><td><code class="filename">/run/systemd/user</code></td><td>Runtime units</td></tr><tr><td><code class="filename">$XDG_DATA_HOME/systemd/user</code></td><td>Units of packages that have been installed in the home directory (only used when $XDG_DATA_HOME is set)</td></tr><tr><td><code class="filename">$HOME/.local/share/systemd/user</code></td><td>Units of packages that have been installed in the home directory (only used when $XDG_DATA_HOME is not set)</td></tr><tr><td><code class="filename">/usr/lib/systemd/user</code></td><td>Units of packages that have been installed system-wide</td></tr></tbody></table></div></div><br class="table-break"><p>Additional units might be loaded into systemd ("linked")
from directories not on the unit load path. See the
<span class="command"><strong>link</strong></span> command for
<a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>.
Also, some units are dynamically created via generators <a class="ulink" href="http://www.freedesktop.org/wiki/Software/systemd/Generators/" target="_top">Generators</a>.
</p></div><div class="refsect1"><a name="idm139858332977440"></a><h2 id="[Unit] Section Options">[Unit] Section Options<a class="headerlink" title="Permalink to this headline" href="#%5BUnit%5D%20Section%20Options"></a></h2><p>Unit file may include a [Unit] section, which carries
generic information about the unit that is not dependent on the
type of unit:</p><div class="variablelist"><dl class="variablelist"><dt id="Description="><span class="term"><code class="varname">Description=</code></span><a class="headerlink" title="Permalink to this term" href="#Description="></a></dt><dd><p>A free-form string describing the unit. This
is intended for use in UIs to show descriptive information
along with the unit name. The description should contain a
name that means something to the end user. "<code class="literal">Apache2
Web Server</code>" is a good example. Bad examples are
"<code class="literal">high-performance light-weight HTTP server</code>"
(too generic) or "<code class="literal">Apache2</code>" (too specific and
meaningless for people who do not know
Apache).</p></dd><dt id="Documentation="><span class="term"><code class="varname">Documentation=</code></span><a class="headerlink" title="Permalink to this term" href="#Documentation="></a></dt><dd><p>A space-separated list of URIs referencing
documentation for this unit or its configuration. Accepted are
only URIs of the types "<code class="literal">http://</code>",
"<code class="literal">https://</code>", "<code class="literal">file:</code>",
"<code class="literal">info:</code>", "<code class="literal">man:</code>". For more
information about the syntax of these URIs, see <a href="http://man7.org/linux/man-pages/man7/uri.7.html"><span class="citerefentry"><span class="refentrytitle">uri</span>(7)</span></a>.
The URIs should be listed in order of relevance, starting with
the most relevant. It is a good idea to first reference
documentation that explains what the unit's purpose is,
followed by how it is configured, followed by any other
related documentation. This option may be specified more than
once, in which case the specified list of URIs is merged. If
the empty string is assigned to this option, the list is reset
and all prior assignments will have no
effect.</p></dd><dt id="Requires="><span class="term"><code class="varname">Requires=</code></span><a class="headerlink" title="Permalink to this term" href="#Requires="></a></dt><dd><p>Configures requirement dependencies on other
units. If this unit gets activated, the units listed here will
be activated as well. If one of the other units gets
deactivated or its activation fails, this unit will be
deactivated. This option may be specified more than once or
multiple space-separated units may be specified in one option
in which case requirement dependencies for all listed names
will be created. Note that requirement dependencies do not
influence the order in which services are started or stopped.
This has to be configured independently with the
<code class="varname">After=</code> or <code class="varname">Before=</code>
options. If a unit <code class="filename">foo.service</code> requires a
unit <code class="filename">bar.service</code> as configured with
<code class="varname">Requires=</code> and no ordering is configured
with <code class="varname">After=</code> or <code class="varname">Before=</code>,
then both units will be started simultaneously and without any
delay between them if <code class="filename">foo.service</code> is
activated. Often it is a better choice to use
<code class="varname">Wants=</code> instead of
<code class="varname">Requires=</code> in order to achieve a system that
is more robust when dealing with failing services.</p><p>Note that dependencies of this type may also be
configured outside of the unit configuration file by adding a
symlink to a <code class="filename">.requires/</code> directory
accompanying the unit file. For details see
above.</p></dd><dt id="RequiresOverridable="><span class="term"><code class="varname">RequiresOverridable=</code></span><a class="headerlink" title="Permalink to this term" href="#RequiresOverridable="></a></dt><dd><p>Similar to <code class="varname">Requires=</code>.
Dependencies listed in <code class="varname">RequiresOverridable=</code>
which cannot be fulfilled or fail to start are ignored if the
startup was explicitly requested by the user. If the start-up
was pulled in indirectly by some dependency or automatic
start-up of units that is not requested by the user, this
dependency must be fulfilled and otherwise the transaction
fails. Hence, this option may be used to configure
dependencies that are normally honored unless the user
explicitly starts up the unit, in which case whether they
failed or not is irrelevant.</p></dd><dt id="Requisite="><span class="term"><code class="varname">Requisite=</code>, </span><span class="term"><code class="varname">RequisiteOverridable=</code></span><a class="headerlink" title="Permalink to this term" href="#Requisite="></a></dt><dd><p>Similar to <code class="varname">Requires=</code> and
<code class="varname">RequiresOverridable=</code>, respectively.
However, if the units listed here are not started already,
they will not be started and the transaction will fail
immediately. </p></dd><dt id="Wants="><span class="term"><code class="varname">Wants=</code></span><a class="headerlink" title="Permalink to this term" href="#Wants="></a></dt><dd><p>A weaker version of
<code class="varname">Requires=</code>. Units listed in this option will
be started if the configuring unit is. However, if the listed
units fail to start or cannot be added to the transaction,
this has no impact on the validity of the transaction as a
whole. This is the recommended way to hook start-up of one
unit to the start-up of another unit.</p><p>Note that dependencies of this type may also be
configured outside of the unit configuration file by adding
symlinks to a <code class="filename">.wants/</code> directory
accompanying the unit file. For details, see
above.</p></dd><dt id="BindsTo="><span class="term"><code class="varname">BindsTo=</code></span><a class="headerlink" title="Permalink to this term" href="#BindsTo="></a></dt><dd><p>Configures requirement dependencies, very
similar in style to <code class="varname">Requires=</code>, however in
addition to this behavior, it also declares that this unit is
stopped when any of the units listed suddenly disappears.
Units can suddenly, unexpectedly disappear if a service
terminates on its own choice, a device is unplugged or a mount
point unmounted without involvement of
systemd.</p></dd><dt id="PartOf="><span class="term"><code class="varname">PartOf=</code></span><a class="headerlink" title="Permalink to this term" href="#PartOf="></a></dt><dd><p>Configures dependencies similar to
<code class="varname">Requires=</code>, but limited to stopping and
restarting of units. When systemd stops or restarts the units
listed here, the action is propagated to this unit. Note that
this is a one-way dependency — changes to this unit do not
affect the listed units. </p></dd><dt id="Conflicts="><span class="term"><code class="varname">Conflicts=</code></span><a class="headerlink" title="Permalink to this term" href="#Conflicts="></a></dt><dd><p>A space-separated list of unit names.
Configures negative requirement dependencies. If a unit has a
<code class="varname">Conflicts=</code> setting on another unit,
starting the former will stop the latter and vice versa. Note
that this setting is independent of and orthogonal to the
<code class="varname">After=</code> and <code class="varname">Before=</code>
ordering dependencies.</p><p>If a unit A that conflicts with a unit B is scheduled to
be started at the same time as B, the transaction will either
fail (in case both are required part of the transaction) or be
modified to be fixed (in case one or both jobs are not a
required part of the transaction). In the latter case, the job
that is not the required will be removed, or in case both are
not required, the unit that conflicts will be started and the
unit that is conflicted is stopped.</p></dd><dt id="Before="><span class="term"><code class="varname">Before=</code>, </span><span class="term"><code class="varname">After=</code></span><a class="headerlink" title="Permalink to this term" href="#Before="></a></dt><dd><p>A space-separated list of unit names.
Configures ordering dependencies between units. If a unit
<code class="filename">foo.service</code> contains a setting
<code class="option">Before=bar.service</code> and both units are being
started, <code class="filename">bar.service</code>'s start-up is
delayed until <code class="filename">foo.service</code> is started up.
Note that this setting is independent of and orthogonal to the
requirement dependencies as configured by
<code class="varname">Requires=</code>. It is a common pattern to
include a unit name in both the <code class="varname">After=</code> and
<code class="varname">Requires=</code> option, in which case the unit
listed will be started before the unit that is configured with
these options. This option may be specified more than once, in
which case ordering dependencies for all listed names are
created. <code class="varname">After=</code> is the inverse of
<code class="varname">Before=</code>, i.e. while
<code class="varname">After=</code> ensures that the configured unit is
started after the listed unit finished starting up,
<code class="varname">Before=</code> ensures the opposite, i.e. that the
configured unit is fully started up before the listed unit is
started. Note that when two units with an ordering dependency
between them are shut down, the inverse of the start-up order
is applied. i.e. if a unit is configured with
<code class="varname">After=</code> on another unit, the former is
stopped before the latter if both are shut down. If one unit
with an ordering dependency on another unit is shut down while
the latter is started up, the shut down is ordered before the
start-up regardless of whether the ordering dependency is
actually of type <code class="varname">After=</code> or
<code class="varname">Before=</code>. If two units have no ordering
dependencies between them, they are shut down or started up
simultaneously, and no ordering takes place.
</p></dd><dt id="OnFailure="><span class="term"><code class="varname">OnFailure=</code></span><a class="headerlink" title="Permalink to this term" href="#OnFailure="></a></dt><dd><p>A space-separated list of one or more units
that are activated when this unit enters the
"<code class="literal">failed</code>" state.</p></dd><dt id="PropagatesReloadTo="><span class="term"><code class="varname">PropagatesReloadTo=</code>, </span><span class="term"><code class="varname">ReloadPropagatedFrom=</code></span><a class="headerlink" title="Permalink to this term" href="#PropagatesReloadTo="></a></dt><dd><p>A space-separated list of one or more units
where reload requests on this unit will be propagated to, or
reload requests on the other unit will be propagated to this
unit, respectively. Issuing a reload request on a unit will
automatically also enqueue a reload request on all units that
the reload request shall be propagated to via these two
settings.</p></dd><dt id="JoinsNamespaceOf="><span class="term"><code class="varname">JoinsNamespaceOf=</code></span><a class="headerlink" title="Permalink to this term" href="#JoinsNamespaceOf="></a></dt><dd><p>For units that start processes (such as
service units), lists one or more other units whose network
and/or temporary file namespace to join. This only applies to
unit types which support the
<code class="varname">PrivateNetwork=</code> and
<code class="varname">PrivateTmp=</code> directives (see
<a href="systemd.exec.html"><span class="citerefentry"><span class="refentrytitle">systemd.exec</span>(5)</span></a>
for details). If a unit that has this setting set is started,
its processes will see the same <code class="filename">/tmp</code>,
<code class="filename">/tmp/var</code> and network namespace as one
listed unit that is started. If multiple listed units are
already started, it is not defined which namespace is joined.
Note that this setting only has an effect if
<code class="varname">PrivateNetwork=</code> and/or
<code class="varname">PrivateTmp=</code> is enabled for both the unit
that joins the namespace and the unit whose namespace is
joined.</p></dd><dt id="RequiresMountsFor="><span class="term"><code class="varname">RequiresMountsFor=</code></span><a class="headerlink" title="Permalink to this term" href="#RequiresMountsFor="></a></dt><dd><p>Takes a space-separated list of absolute
paths. Automatically adds dependencies of type
<code class="varname">Requires=</code> and <code class="varname">After=</code> for
all mount units required to access the specified path.</p><p>Mount points marked with <code class="option">noauto</code> are not
mounted automatically and will be ignored for the purposes of
this option. If such a mount should be a requirement for this
unit, direct dependencies on the mount units may be added
(<code class="varname">Requires=</code> and <code class="varname">After=</code> or
some other combination). </p></dd><dt id="OnFailureJobMode="><span class="term"><code class="varname">OnFailureJobMode=</code></span><a class="headerlink" title="Permalink to this term" href="#OnFailureJobMode="></a></dt><dd><p>Takes a value of
"<code class="literal">fail</code>",
"<code class="literal">replace</code>",
"<code class="literal">replace-irreversibly</code>",
"<code class="literal">isolate</code>",
"<code class="literal">flush</code>",
"<code class="literal">ignore-dependencies</code>" or
"<code class="literal">ignore-requirements</code>". Defaults to
"<code class="literal">replace</code>". Specifies how the units listed in
<code class="varname">OnFailure=</code> will be enqueued. See
<a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>'s
<code class="option">--job-mode=</code> option for details on the
possible values. If this is set to "<code class="literal">isolate</code>",
only a single unit may be listed in
<code class="varname">OnFailure=</code>..</p></dd><dt id="IgnoreOnIsolate="><span class="term"><code class="varname">IgnoreOnIsolate=</code></span><a class="headerlink" title="Permalink to this term" href="#IgnoreOnIsolate="></a></dt><dd><p>Takes a boolean argument. If
<code class="option">true</code>, this unit will not be stopped when
isolating another unit. Defaults to
<code class="option">false</code>.</p></dd><dt id="IgnoreOnSnapshot="><span class="term"><code class="varname">IgnoreOnSnapshot=</code></span><a class="headerlink" title="Permalink to this term" href="#IgnoreOnSnapshot="></a></dt><dd><p>Takes a boolean argument. If
<code class="option">true</code>, this unit will not be included in
snapshots. Defaults to <code class="option">true</code> for device and
snapshot units, <code class="option">false</code> for the
others.</p></dd><dt id="StopWhenUnneeded="><span class="term"><code class="varname">StopWhenUnneeded=</code></span><a class="headerlink" title="Permalink to this term" href="#StopWhenUnneeded="></a></dt><dd><p>Takes a boolean argument. If
<code class="option">true</code>, this unit will be stopped when it is no
longer used. Note that in order to minimize the work to be
executed, systemd will not stop units by default unless they
are conflicting with other units, or the user explicitly
requested their shut down. If this option is set, a unit will
be automatically cleaned up if no other active unit requires
it. Defaults to <code class="option">false</code>.</p></dd><dt id="RefuseManualStart="><span class="term"><code class="varname">RefuseManualStart=</code>, </span><span class="term"><code class="varname">RefuseManualStop=</code></span><a class="headerlink" title="Permalink to this term" href="#RefuseManualStart="></a></dt><dd><p>Takes a boolean argument. If
<code class="option">true</code>, this unit can only be activated or
deactivated indirectly. In this case, explicit start-up or
termination requested by the user is denied, however if it is
started or stopped as a dependency of another unit, start-up
or termination will succeed. This is mostly a safety feature
to ensure that the user does not accidentally activate units
that are not intended to be activated explicitly, and not
accidentally deactivate units that are not intended to be
deactivated. These options default to
<code class="option">false</code>.</p></dd><dt id="AllowIsolate="><span class="term"><code class="varname">AllowIsolate=</code></span><a class="headerlink" title="Permalink to this term" href="#AllowIsolate="></a></dt><dd><p>Takes a boolean argument. If
<code class="option">true</code>, this unit may be used with the
<span class="command"><strong>systemctl isolate</strong></span> command. Otherwise, this
will be refused. It probably is a good idea to leave this
disabled except for target units that shall be used similar to
runlevels in SysV init systems, just as a precaution to avoid
unusable system states. This option defaults to
<code class="option">false</code>.</p></dd><dt id="DefaultDependencies="><span class="term"><code class="varname">DefaultDependencies=</code></span><a class="headerlink" title="Permalink to this term" href="#DefaultDependencies="></a></dt><dd><p>Takes a boolean argument. If
<code class="option">true</code>, (the default), a few default
dependencies will implicitly be created for the unit. The
actual dependencies created depend on the unit type. For
example, for service units, these dependencies ensure that the
service is started only after basic system initialization is
completed and is properly terminated on system shutdown. See
the respective man pages for details. Generally, only services
involved with early boot or late shutdown should set this
option to <code class="option">false</code>. It is highly recommended to
leave this option enabled for the majority of common units. If
set to <code class="option">false</code>, this option does not disable
all implicit dependencies, just non-essential
ones.</p></dd><dt id="JobTimeoutSec="><span class="term"><code class="varname">JobTimeoutSec=</code>, </span><span class="term"><code class="varname">JobTimeoutAction=</code>, </span><span class="term"><code class="varname">JobTimeoutRebootArgument=</code></span><a class="headerlink" title="Permalink to this term" href="#JobTimeoutSec="></a></dt><dd><p>When a job for this unit is queued a time-out
may be configured. If this time limit is reached, the job will
be cancelled, the unit however will not change state or even
enter the "<code class="literal">failed</code>" mode. This value defaults
to 0 (job timeouts disabled), except for device units. NB:
this timeout is independent from any unit-specific timeout
(for example, the timeout set with
<code class="varname">StartTimeoutSec=</code> in service units) as the
job timeout has no effect on the unit itself, only on the job
that might be pending for it. Or in other words: unit-specific
timeouts are useful to abort unit state changes, and revert
them. The job timeout set with this option however is useful
to abort only the job waiting for the unit state to
change.</p><p><code class="varname">JobTimeoutAction=</code>
optionally configures an additional
action to take when the time-out is
hit. It takes the same values as the
per-service
<code class="varname">StartLimitAction=</code>
setting, see
<a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>
for details. Defaults to
<code class="option">none</code>. <code class="varname">JobTimeoutRebootArgument=</code>
configures an optional reboot string
to pass to the
<a href="http://man7.org/linux/man-pages/man2/reboot.2.html"><span class="citerefentry"><span class="refentrytitle">reboot</span>(2)</span></a>
system call.</p></dd><dt id="ConditionArchitecture="><span class="term"><code class="varname">ConditionArchitecture=</code>, </span><span class="term"><code class="varname">ConditionVirtualization=</code>, </span><span class="term"><code class="varname">ConditionHost=</code>, </span><span class="term"><code class="varname">ConditionKernelCommandLine=</code>, </span><span class="term"><code class="varname">ConditionSecurity=</code>, </span><span class="term"><code class="varname">ConditionCapability=</code>, </span><span class="term"><code class="varname">ConditionACPower=</code>, </span><span class="term"><code class="varname">ConditionNeedsUpdate=</code>, </span><span class="term"><code class="varname">ConditionFirstBoot=</code>, </span><span class="term"><code class="varname">ConditionPathExists=</code>, </span><span class="term"><code class="varname">ConditionPathExistsGlob=</code>, </span><span class="term"><code class="varname">ConditionPathIsDirectory=</code>, </span><span class="term"><code class="varname">ConditionPathIsSymbolicLink=</code>, </span><span class="term"><code class="varname">ConditionPathIsMountPoint=</code>, </span><span class="term"><code class="varname">ConditionPathIsReadWrite=</code>, </span><span class="term"><code class="varname">ConditionDirectoryNotEmpty=</code>, </span><span class="term"><code class="varname">ConditionFileNotEmpty=</code>, </span><span class="term"><code class="varname">ConditionFileIsExecutable=</code></span><a class="headerlink" title="Permalink to this term" href="#ConditionArchitecture="></a></dt><dd><p>Before starting a unit verify that the
specified condition is true. If it is not true, the starting
of the unit will be skipped, however all ordering dependencies
of it are still respected. A failing condition will not result
in the unit being moved into a failure state. The condition is
checked at the time the queued start job is to be
executed.</p><p><code class="varname">ConditionArchitecture=</code> may be used to
check whether the system is running on a specific
architecture. Takes one of
<code class="varname">x86</code>,
<code class="varname">x86-64</code>,
<code class="varname">ppc</code>,
<code class="varname">ppc-le</code>,
<code class="varname">ppc64</code>,
<code class="varname">ppc64-le</code>,
<code class="varname">ia64</code>,
<code class="varname">parisc</code>,
<code class="varname">parisc64</code>,
<code class="varname">s390</code>,
<code class="varname">s390x</code>,
<code class="varname">sparc</code>,
<code class="varname">sparc64</code>,
<code class="varname">mips</code>,
<code class="varname">mips-le</code>,
<code class="varname">mips64</code>,
<code class="varname">mips64-le</code>,
<code class="varname">alpha</code>,
<code class="varname">arm</code>,
<code class="varname">arm-be</code>,
<code class="varname">arm64</code>,
<code class="varname">arm64-be</code>,
<code class="varname">sh</code>,
<code class="varname">sh64</code>,
<code class="varname">m86k</code>,
<code class="varname">tilegx</code>,
<code class="varname">cris</code> to test
against a specific architecture. The architecture is
determined from the information returned by
<a href="http://man7.org/linux/man-pages/man2/uname.2.html"><span class="citerefentry"><span class="refentrytitle">uname</span>(2)</span></a>
and is thus subject to
<a href="http://man7.org/linux/man-pages/man2/personality.2.html"><span class="citerefentry"><span class="refentrytitle">personality</span>(2)</span></a>.
Note that a <code class="varname">Personality=</code> setting in the
same unit file has no effect on this condition. A special
architecture name <code class="varname">native</code> is mapped to the
architecture the system manager itself is compiled for. The
test may be negated by prepending an exclamation mark.</p><p><code class="varname">ConditionVirtualization=</code> may be used
to check whether the system is executed in a virtualized
environment and optionally test whether it is a specific
implementation. Takes either boolean value to check if being
executed in any virtualized environment, or one of
<code class="varname">vm</code> and
<code class="varname">container</code> to test against a generic type of
virtualization solution, or one of
<code class="varname">qemu</code>,
<code class="varname">kvm</code>,
<code class="varname">zvm</code>,
<code class="varname">vmware</code>,
<code class="varname">microsoft</code>,
<code class="varname">oracle</code>,
<code class="varname">xen</code>,
<code class="varname">bochs</code>,
<code class="varname">uml</code>,
<code class="varname">openvz</code>,
<code class="varname">lxc</code>,
<code class="varname">lxc-libvirt</code>,
<code class="varname">systemd-nspawn</code>,
<code class="varname">docker</code> to test
against a specific implementation. See
<a href="systemd-detect-virt.html"><span class="citerefentry"><span class="refentrytitle">systemd-detect-virt</span>(1)</span></a>
for a full list of known virtualization technologies and their
identifiers. If multiple virtualization technologies are
nested, only the innermost is considered. The test may be
negated by prepending an exclamation mark.</p><p><code class="varname">ConditionHost=</code> may be used to match
against the hostname or machine ID of the host. This either
takes a hostname string (optionally with shell style globs)
which is tested against the locally set hostname as returned
by
<a href="http://man7.org/linux/man-pages/man2/gethostname.2.html"><span class="citerefentry"><span class="refentrytitle">gethostname</span>(2)</span></a>,
or a machine ID formatted as string (see
<a href="machine-id.html"><span class="citerefentry"><span class="refentrytitle">machine-id</span>(5)</span></a>).
The test may be negated by prepending an exclamation
mark.</p><p><code class="varname">ConditionKernelCommandLine=</code> may be
used to check whether a specific kernel command line option is
set (or if prefixed with the exclamation mark unset). The
argument must either be a single word, or an assignment (i.e.
two words, separated "<code class="literal">=</code>"). In the former case
the kernel command line is searched for the word appearing as
is, or as left hand side of an assignment. In the latter case,
the exact assignment is looked for with right and left hand
side matching.</p><p><code class="varname">ConditionSecurity=</code> may be used to
check whether the given security module is enabled on the
system. Currently the recognized values values are
<code class="varname">selinux</code>,
<code class="varname">apparmor</code>,
<code class="varname">ima</code>,
<code class="varname">smack</code> and
<code class="varname">audit</code>. The test may be negated by
prepending an exclamation mark.</p><p><code class="varname">ConditionCapability=</code> may be used to
check whether the given capability exists in the capability
bounding set of the service manager (i.e. this does not check
whether capability is actually available in the permitted or
effective sets, see
<a href="http://man7.org/linux/man-pages/man7/capabilities.7.html"><span class="citerefentry"><span class="refentrytitle">capabilities</span>(7)</span></a>
for details). Pass a capability name such as
"<code class="literal">CAP_MKNOD</code>", possibly prefixed with an
exclamation mark to negate the check.</p><p><code class="varname">ConditionACPower=</code> may be used to
check whether the system has AC power, or is exclusively
battery powered at the time of activation of the unit. This
takes a boolean argument. If set to <code class="varname">true</code>,
the condition will hold only if at least one AC connector of
the system is connected to a power source, or if no AC
connectors are known. Conversely, if set to
<code class="varname">false</code>, the condition will hold only if
there is at least one AC connector known and all AC connectors
are disconnected from a power source.</p><p><code class="varname">ConditionNeedsUpdate=</code> takes one of
<code class="filename">/var</code> or <code class="filename">/etc</code> as
argument, possibly prefixed with a "<code class="literal">!</code>" (for
inverting the condition). This condition may be used to
conditionalize units on whether the specified directory
requires an update because <code class="filename">/usr</code>'s
modification time is newer than the stamp file
<code class="filename">.updated</code> in the specified directory. This
is useful to implement offline updates of the vendor operating
system resources in <code class="filename">/usr</code> that require
updating of <code class="filename">/etc</code> or
<code class="filename">/var</code> on the next following boot. Units
making use of this condition should order themselves before
<a href="systemd-update-done.service.html"><span class="citerefentry"><span class="refentrytitle">systemd-update-done.service</span>(8)</span></a>,
to make sure they run before the stamp files's modification
time gets reset indicating a completed update.</p><p><code class="varname">ConditionFirstBoot=</code> takes a boolean
argument. This condition may be used to conditionalize units
on whether the system is booting up with an unpopulated
<code class="filename">/etc</code> directory. This may be used to
populate <code class="filename">/etc</code> on the first boot after
factory reset, or when a new system instances boots up for the
first time.</p><p>With <code class="varname">ConditionPathExists=</code> a file
existence condition is checked before a unit is started. If
the specified absolute path name does not exist, the condition
will fail. If the absolute path name passed to
<code class="varname">ConditionPathExists=</code> is prefixed with an
exclamation mark ("<code class="literal">!</code>"), the test is negated,
and the unit is only started if the path does not
exist.</p><p><code class="varname">ConditionPathExistsGlob=</code> is similar
to <code class="varname">ConditionPathExists=</code>, but checks for the
existence of at least one file or directory matching the
specified globbing pattern.</p><p><code class="varname">ConditionPathIsDirectory=</code> is similar
to <code class="varname">ConditionPathExists=</code> but verifies
whether a certain path exists and is a directory.</p><p><code class="varname">ConditionPathIsSymbolicLink=</code> is
similar to <code class="varname">ConditionPathExists=</code> but
verifies whether a certain path exists and is a symbolic
link.</p><p><code class="varname">ConditionPathIsMountPoint=</code> is similar
to <code class="varname">ConditionPathExists=</code> but verifies
whether a certain path exists and is a mount point.</p><p><code class="varname">ConditionPathIsReadWrite=</code> is similar
to <code class="varname">ConditionPathExists=</code> but verifies
whether the underlying file system is readable and writable
(i.e. not mounted read-only).</p><p><code class="varname">ConditionDirectoryNotEmpty=</code> is
similar to <code class="varname">ConditionPathExists=</code> but
verifies whether a certain path exists and is a non-empty
directory.</p><p><code class="varname">ConditionFileNotEmpty=</code> is similar to
<code class="varname">ConditionPathExists=</code> but verifies whether a
certain path exists and refers to a regular file with a
non-zero size.</p><p><code class="varname">ConditionFileIsExecutable=</code> is similar
to <code class="varname">ConditionPathExists=</code> but verifies
whether a certain path exists, is a regular file and marked
executable.</p><p>If multiple conditions are specified, the unit will be
executed if all of them apply (i.e. a logical AND is applied).
Condition checks can be prefixed with a pipe symbol (|) in
which case a condition becomes a triggering condition. If at
least one triggering condition is defined for a unit, then the
unit will be executed if at least one of the triggering
conditions apply and all of the non-triggering conditions. If
you prefix an argument with the pipe symbol and an exclamation
mark, the pipe symbol must be passed first, the exclamation
second. Except for
<code class="varname">ConditionPathIsSymbolicLink=</code>, all path
checks follow symlinks. If any of these options is assigned
the empty string, the list of conditions is reset completely,
all previous condition settings (of any kind) will have no
effect.</p></dd><dt id="AssertArchitecture="><span class="term"><code class="varname">AssertArchitecture=</code>, </span><span class="term"><code class="varname">AssertVirtualization=</code>, </span><span class="term"><code class="varname">AssertHost=</code>, </span><span class="term"><code class="varname">AssertKernelCommandLine=</code>, </span><span class="term"><code class="varname">AssertSecurity=</code>, </span><span class="term"><code class="varname">AssertCapability=</code>, </span><span class="term"><code class="varname">AssertACPower=</code>, </span><span class="term"><code class="varname">AssertNeedsUpdate=</code>, </span><span class="term"><code class="varname">AssertFirstBoot=</code>, </span><span class="term"><code class="varname">AssertPathExists=</code>, </span><span class="term"><code class="varname">AssertPathExistsGlob=</code>, </span><span class="term"><code class="varname">AssertPathIsDirectory=</code>, </span><span class="term"><code class="varname">AssertPathIsSymbolicLink=</code>, </span><span class="term"><code class="varname">AssertPathIsMountPoint=</code>, </span><span class="term"><code class="varname">AssertPathIsReadWrite=</code>, </span><span class="term"><code class="varname">AssertDirectoryNotEmpty=</code>, </span><span class="term"><code class="varname">AssertFileNotEmpty=</code>, </span><span class="term"><code class="varname">AssertFileIsExecutable=</code></span><a class="headerlink" title="Permalink to this term" href="#AssertArchitecture="></a></dt><dd><p>Similar to the
<code class="varname">ConditionArchitecture=</code>,
<code class="varname">ConditionVirtualization=</code>, ... condition
settings described above these settings add assertion checks
to the start-up of the unit. However, unlike the conditions
settings any assertion setting that is not met results in
failure of the start job it was triggered
by.</p></dd><dt id="SourcePath="><span class="term"><code class="varname">SourcePath=</code></span><a class="headerlink" title="Permalink to this term" href="#SourcePath="></a></dt><dd><p>A path to a configuration file this unit has
been generated from. This is primarily useful for
implementation of generator tools that convert configuration
from an external configuration file format into native unit
files. This functionality should not be used in normal
units.</p></dd></dl></div></div><div class="refsect1"><a name="idm139858332792880"></a><h2 id="[Install] Section Options">[Install] Section Options<a class="headerlink" title="Permalink to this headline" href="#%5BInstall%5D%20Section%20Options"></a></h2><p>Unit file may include an "<code class="literal">[Install]</code>"
section, which carries installation information for the unit. This
section is not interpreted by
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>
during runtime. It is used exclusively by the
<span class="command"><strong>enable</strong></span> and <span class="command"><strong>disable</strong></span> commands
of the
<a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>
tool during installation of a unit:</p><div class="variablelist"><dl class="variablelist"><dt id="Alias="><span class="term"><code class="varname">Alias=</code></span><a class="headerlink" title="Permalink to this term" href="#Alias="></a></dt><dd><p>A space-separated list of additional names
this unit shall be installed under. The names listed here must
have the same suffix (i.e. type) as the unit file name. This
option may be specified more than once, in which case all
listed names are used. At installation time,
<span class="command"><strong>systemctl enable</strong></span> will create symlinks from
these names to the unit filename.</p></dd><dt id="WantedBy="><span class="term"><code class="varname">WantedBy=</code>, </span><span class="term"><code class="varname">RequiredBy=</code></span><a class="headerlink" title="Permalink to this term" href="#WantedBy="></a></dt><dd><p>This option may be used more than once, or a
space-separated list of unit names may be given. A symbolic
link is created in the <code class="filename">.wants/</code> or
<code class="filename">.requires/</code> directory of each of the
listed units when this unit is installed by <span class="command"><strong>systemctl
enable</strong></span>. This has the effect that a dependency of
type <code class="varname">Wants=</code> or <code class="varname">Requires=</code>
is added from the listed unit to the current unit. The primary
result is that the current unit will be started when the
listed unit is started. See the description of
<code class="varname">Wants=</code> and <code class="varname">Requires=</code> in
the [Unit] section for details.</p><p><span class="command"><strong>WantedBy=foo.service</strong></span> in a service
<code class="filename">bar.service</code> is mostly equivalent to
<span class="command"><strong>Alias=foo.service.wants/bar.service</strong></span> in the
same file. In case of template units, <span class="command"><strong>systemctl
enable</strong></span> must be called with an instance name, and
this instance will be added to the
<code class="filename">.wants/</code> or
<code class="filename">.requires/</code> list of the listed unit. E.g.
<span class="command"><strong>WantedBy=getty.target</strong></span> in a service
<code class="filename">getty@.service</code> will result in
<span class="command"><strong>systemctl enable getty@tty2.service</strong></span>
creating a
<code class="filename">getty.target.wants/getty@tty2.service</code>
link to <code class="filename">getty@.service</code>.
</p></dd><dt id="Also="><span class="term"><code class="varname">Also=</code></span><a class="headerlink" title="Permalink to this term" href="#Also="></a></dt><dd><p>Additional units to install/deinstall when
this unit is installed/deinstalled. If the user requests
installation/deinstallation of a unit with this option
configured, <span class="command"><strong>systemctl enable</strong></span> and
<span class="command"><strong>systemctl disable</strong></span> will automatically
install/uninstall units listed in this option as well.</p><p>This option may be used more than once, or a
space-separated list of unit names may be
given.</p></dd><dt id="DefaultInstance="><span class="term"><code class="varname">DefaultInstance=</code></span><a class="headerlink" title="Permalink to this term" href="#DefaultInstance="></a></dt><dd><p>In template unit files, this specifies for
which instance the unit shall be enabled if the template is
enabled without any explicitly set instance. This option has
no effect in non-template unit files. The specified string
must be usable as instance identifier.</p></dd></dl></div><p>The following specifiers are interpreted in the Install
section: %n, %N, %p, %i, %U, %u, %m, %H, %b, %v. For their meaning
see the next section.
</p></div><div class="refsect1"><a name="idm139858332766272"></a><h2 id="Specifiers">Specifiers<a class="headerlink" title="Permalink to this headline" href="#Specifiers"></a></h2><p>Many settings resolve specifiers which may be used to write
generic unit files referring to runtime or unit parameters that
are replaced when the unit files are loaded. The following
specifiers are understood:</p><div class="table"><a name="idm139858332765008"></a><p class="title"><b>Table 3. Specifiers available in unit files</b></p><div class="table-contents"><table summary="Specifiers available in unit files" 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">%n</code>"</td><td align="left">Full unit name</td><td align="left"> </td></tr><tr><td align="left">"<code class="literal">%N</code>"</td><td align="left">Unescaped full unit name</td><td align="left">Same as "<code class="literal">%n</code>", but with escaping undone</td></tr><tr><td align="left">"<code class="literal">%p</code>"</td><td align="left">Prefix name</td><td align="left">For instantiated units, this refers to the string before the "<code class="literal">@</code>" character of the unit name. For non-instantiated units, this refers to the name of the unit with the type suffix removed.</td></tr><tr><td align="left">"<code class="literal">%P</code>"</td><td align="left">Unescaped prefix name</td><td align="left">Same as "<code class="literal">%p</code>", but with escaping undone</td></tr><tr><td align="left">"<code class="literal">%i</code>"</td><td align="left">Instance name</td><td align="left">For instantiated units: this is the string between the "<code class="literal">@</code>" character and the suffix of the unit name.</td></tr><tr><td align="left">"<code class="literal">%I</code>"</td><td align="left">Unescaped instance name</td><td align="left">Same as "<code class="literal">%i</code>", but with escaping undone</td></tr><tr><td align="left">"<code class="literal">%f</code>"</td><td align="left">Unescaped filename</td><td align="left">This is either the unescaped instance name (if applicable) with <code class="filename">/</code> prepended (if applicable), or the prefix name prepended with <code class="filename">/</code>.</td></tr><tr><td align="left">"<code class="literal">%c</code>"</td><td align="left">Control group path of the unit</td><td align="left">This path does not include the <code class="filename">/sys/fs/cgroup/systemd/</code> prefix.</td></tr><tr><td align="left">"<code class="literal">%r</code>"</td><td align="left">Control group path of the slice the unit is placed in</td><td align="left">This usually maps to the parent cgroup path of "<code class="literal">%c</code>".</td></tr><tr><td align="left">"<code class="literal">%R</code>"</td><td align="left">Root control group path below which slices and units are placed</td><td align="left">For system instances, this resolves to <code class="filename">/</code>, except in containers, where this maps to the container's root control group path.</td></tr><tr><td align="left">"<code class="literal">%t</code>"</td><td align="left">Runtime directory</td><td align="left">This is either <code class="filename">/run</code> (for the system manager) or the path "<code class="literal">$XDG_RUNTIME_DIR</code>" resolves to (for user managers).</td></tr><tr><td align="left">"<code class="literal">%u</code>"</td><td align="left">User name</td><td align="left">This is the name of the configured user of the unit, or (if none is set) the user running the systemd instance.</td></tr><tr><td align="left">"<code class="literal">%U</code>"</td><td align="left">User UID</td><td align="left">This is the numeric UID of the configured user of the unit, or (if none is set) the user running the systemd user instance. Note that this specifier is not available for units run by the systemd system instance (as opposed to those run by a systemd user instance), unless the user has been configured as a numeric UID in the first place or the configured user is the root user.</td></tr><tr><td align="left">"<code class="literal">%h</code>"</td><td align="left">User home directory</td><td align="left">This is the home directory of the configured user of the unit, or (if none is set) the user running the systemd user instance. Similar to "<code class="literal">%U</code>", this specifier is not available for units run by the systemd system instance, unless the configured user is the root user.</td></tr><tr><td align="left">"<code class="literal">%s</code>"</td><td align="left">User shell</td><td align="left">This is the shell of the configured user of the unit, or (if none is set) the user running the systemd user instance. Similar to "<code class="literal">%U</code>", this specifier is not available for units run by the systemd system instance, unless the configured user is the root user.</td></tr><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 at the point in time the unit configuation is loaded.</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">Single percent sign</td><td align="left">Use "<code class="literal">%%</code>" in place of "<code class="literal">%</code>" to specify a single percent sign.</td></tr></tbody></table></div></div><br class="table-break"><p>Please note that specifiers "<code class="literal">%U</code>",
"<code class="literal">%h</code>", "<code class="literal">%s</code>" are mostly useless
when systemd is running in system mode. PID 1 cannot query the
user account database for information, so the specifiers only work
as shortcuts for things which are already specified in a different
way in the unit file. They are fully functional when systemd is
running in <code class="option">--user</code> mode.</p></div><div class="refsect1"><a name="idm139858332703952"></a><h2 id="Examples">Examples<a class="headerlink" title="Permalink to this headline" href="#Examples"></a></h2><div class="example"><a name="idm139858332703312"></a><p class="title"><b>Example 1. Allowing units to be enabled</b></p><div class="example-contents"><p>The following snippet (highlighted) allows a unit (e.g.
<code class="filename">foo.service</code>) to be enabled via
<span class="command"><strong>systemctl enable</strong></span>:</p><pre class="programlisting">[Unit]
Description=Foo
[Service]
ExecStart=/usr/sbin/foo-daemon
<span class="emphasis"><em>[Install]</em></span>
<span class="emphasis"><em>WantedBy=multi-user.target</em></span></pre><p>After running <span class="command"><strong>systemctl enable</strong></span>, a
symlink
<code class="filename">/etc/systemd/system/multi-user.target.wants/foo.service</code>
linking to the actual unit will be created. It tells systemd to
pull in the unit when starting
<code class="filename">multi-user.target</code>. The inverse
<span class="command"><strong>systemctl disable</strong></span> will remove that symlink
again.</p></div></div><br class="example-break"><div class="example"><a name="idm139858332696480"></a><p class="title"><b>Example 2. Overriding vendor settings</b></p><div class="example-contents"><p>There are two methods of overriding vendor settings in
unit files: copying the unit file from
<code class="filename">/usr/lib/systemd/system</code> to
<code class="filename">/etc/systemd/system</code> and modifying the
chosen settings. Alternatively, one can create a directory named
<code class="filename"><em class="replaceable"><code>unit</code></em>.d/</code> within
<code class="filename">/etc/systemd/system</code> and place a drop-in
file <code class="filename"><em class="replaceable"><code>name</code></em>.conf</code>
there that only changes the specific settings one is interested
in. Note that multiple such drop-in files are read if
present.</p><p>The advantage of the first method is that one easily
overrides the complete unit, the vendor unit is not parsed at
all anymore. It has the disadvantage that improvements to the
unit file by the vendor are not automatically incorporated on
updates.</p><p>The advantage of the second method is that one only
overrides the settings one specifically wants, where updates to
the unit by the vendor automatically apply. This has the
disadvantage that some future updates by the vendor might be
incompatible with the local changes.</p><p>Note that for drop-in files, if one wants to remove
entries from a setting that is parsed as a list (and is not a
dependency), such as <code class="varname">ConditionPathExists=</code> (or
e.g. <code class="varname">ExecStart=</code> in service units), one needs
to first clear the list before re-adding all entries except the
one that is to be removed. See below for an example.</p><p>This also applies for user instances of systemd, but with
different locations for the unit files. See the section on unit
load paths for further details.</p><p>Suppose there is a vendor-supplied unit
<code class="filename">/usr/lib/systemd/system/httpd.service</code> with
the following contents:</p><pre class="programlisting">[Unit]
Description=Some HTTP server
After=remote-fs.target sqldb.service
Requires=sqldb.service
AssertPathExists=/srv/webserver
[Service]
Type=notify
ExecStart=/usr/sbin/some-fancy-httpd-server
Nice=5
[Install]
WantedBy=multi-user.target</pre><p>Now one wants to change some settings as an administrator:
firstly, in the local setup, <code class="filename">/srv/webserver</code>
might not exist, because the HTTP server is configured to use
<code class="filename">/srv/www</code> instead. Secondly, the local
configuration makes the HTTP server also depend on a memory
cache service, <code class="filename">memcached.service</code>, that
should be pulled in (<code class="varname">Requires=</code>) and also be
ordered appropriately (<code class="varname">After=</code>). Thirdly, in
order to harden the service a bit more, the administrator would
like to set the <code class="varname">PrivateTmp=</code> setting (see
<a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>
for details). And lastly, the administrator would like to reset
the niceness of the service to its default value of 0.</p><p>The first possibility is to copy the unit file to
<code class="filename">/etc/systemd/system/httpd.service</code> and
change the chosen settings:</p><pre class="programlisting">[Unit]
Description=Some HTTP server
After=remote-fs.target sqldb.service <span class="emphasis"><em>memcached.service</em></span>
Requires=sqldb.service <span class="emphasis"><em>memcached.service</em></span>
AssertPathExists=<span class="emphasis"><em>/srv/www</em></span>
[Service]
Type=notify
ExecStart=/usr/sbin/some-fancy-httpd-server
<span class="emphasis"><em>Nice=0</em></span>
<span class="emphasis"><em>PrivateTmp=yes</em></span>
[Install]
WantedBy=multi-user.target</pre><p>Alternatively, the administrator could create a drop-in
file
<code class="filename">/etc/systemd/system/httpd.service.d/local.conf</code>
with the following contents:</p><pre class="programlisting">[Unit]
After=memcached.service
Requires=memcached.service
# Reset all assertions and then re-add the condition we want
AssertPathExists=
AssertPathExists=/srv/www
[Service]
Nice=0
PrivateTmp=yes</pre><p>Note that dependencies (<code class="varname">After=</code>, etc.)
cannot be reset to an empty list, so dependencies can only be
added in drop-ins. If you want to remove dependencies, you have
to override the entire unit.</p></div></div><br class="example-break"></div><div class="refsect1"><a name="idm139858332674384"></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="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>,
<a href="systemd.special.html"><span class="citerefentry"><span class="refentrytitle">systemd.special</span>(7)</span></a>,
<a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>,
<a href="systemd.socket.html"><span class="citerefentry"><span class="refentrytitle">systemd.socket</span>(5)</span></a>,
<a href="systemd.device.html"><span class="citerefentry"><span class="refentrytitle">systemd.device</span>(5)</span></a>,
<a href="systemd.mount.html"><span class="citerefentry"><span class="refentrytitle">systemd.mount</span>(5)</span></a>,
<a href="systemd.automount.html"><span class="citerefentry"><span class="refentrytitle">systemd.automount</span>(5)</span></a>,
<a href="systemd.swap.html"><span class="citerefentry"><span class="refentrytitle">systemd.swap</span>(5)</span></a>,
<a href="systemd.target.html"><span class="citerefentry"><span class="refentrytitle">systemd.target</span>(5)</span></a>,
<a href="systemd.path.html"><span class="citerefentry"><span class="refentrytitle">systemd.path</span>(5)</span></a>,
<a href="systemd.timer.html"><span class="citerefentry"><span class="refentrytitle">systemd.timer</span>(5)</span></a>,
<a href="systemd.snapshot.html"><span class="citerefentry"><span class="refentrytitle">systemd.snapshot</span>(5)</span></a>,
<a href="systemd.scope.html"><span class="citerefentry"><span class="refentrytitle">systemd.scope</span>(5)</span></a>,
<a href="systemd.slice.html"><span class="citerefentry"><span class="refentrytitle">systemd.slice</span>(5)</span></a>,
<a href="systemd.time.html"><span class="citerefentry"><span class="refentrytitle">systemd.time</span>(7)</span></a>,
<a href="systemd-analyze.html"><span class="citerefentry"><span class="refentrytitle">systemd-analyze</span>(1)</span></a>,
<a href="http://man7.org/linux/man-pages/man7/capabilities.7.html"><span class="citerefentry"><span class="refentrytitle">capabilities</span>(7)</span></a>,
<a href="systemd.directives.html"><span class="citerefentry"><span class="refentrytitle">systemd.directives</span>(7)</span></a>,
<a href="uname.html"><span class="citerefentry"><span class="refentrytitle">uname</span>(1)</span></a>
</p></div></div></body></html>