]>
Commit | Line | Data |
---|---|---|
c129bd5d | 1 | <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*--> |
d1ab0ca0 | 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
798d3a52 | 3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [ |
1a13e31d ZJS |
4 | <!ENTITY % entities SYSTEM "custom-entities.ent" > |
5 | %entities; | |
6 | ]> | |
d1ab0ca0 LP |
7 | |
8 | <!-- | |
572eb058 ZJS |
9 | SPDX-License-Identifier: LGPL-2.1+ |
10 | ||
d1ab0ca0 LP |
11 | This file is part of systemd. |
12 | ||
13 | Copyright 2010 Lennart Poettering | |
d1ab0ca0 LP |
14 | --> |
15 | ||
16 | <refentry id="systemd.unit"> | |
17 | ||
798d3a52 ZJS |
18 | <refentryinfo> |
19 | <title>systemd.unit</title> | |
20 | <productname>systemd</productname> | |
21 | ||
22 | <authorgroup> | |
23 | <author> | |
24 | <contrib>Developer</contrib> | |
25 | <firstname>Lennart</firstname> | |
26 | <surname>Poettering</surname> | |
27 | <email>lennart@poettering.net</email> | |
28 | </author> | |
29 | </authorgroup> | |
30 | </refentryinfo> | |
31 | ||
32 | <refmeta> | |
33 | <refentrytitle>systemd.unit</refentrytitle> | |
34 | <manvolnum>5</manvolnum> | |
35 | </refmeta> | |
36 | ||
37 | <refnamediv> | |
38 | <refname>systemd.unit</refname> | |
39 | <refpurpose>Unit configuration</refpurpose> | |
40 | </refnamediv> | |
41 | ||
42 | <refsynopsisdiv> | |
43 | <para><filename><replaceable>service</replaceable>.service</filename>, | |
44 | <filename><replaceable>socket</replaceable>.socket</filename>, | |
45 | <filename><replaceable>device</replaceable>.device</filename>, | |
46 | <filename><replaceable>mount</replaceable>.mount</filename>, | |
47 | <filename><replaceable>automount</replaceable>.automount</filename>, | |
48 | <filename><replaceable>swap</replaceable>.swap</filename>, | |
49 | <filename><replaceable>target</replaceable>.target</filename>, | |
50 | <filename><replaceable>path</replaceable>.path</filename>, | |
51 | <filename><replaceable>timer</replaceable>.timer</filename>, | |
798d3a52 ZJS |
52 | <filename><replaceable>slice</replaceable>.slice</filename>, |
53 | <filename><replaceable>scope</replaceable>.scope</filename></para> | |
54 | ||
b82f27e7 ZJS |
55 | <para><literallayout><filename>/etc/systemd/system.control/*</filename> |
56 | <filename>/run/systemd/system.control/*</filename> | |
57 | <filename>/run/systemd/transient/*</filename> | |
58 | <filename>/run/systemd/generator.early/*</filename> | |
59 | <filename>/etc/systemd/system/*</filename> | |
13219b7f | 60 | <filename>/run/systemd/system/*</filename> |
b82f27e7 | 61 | <filename>/run/systemd/generator/*</filename> |
f6e1bd2c | 62 | <filename>…</filename> |
b82f27e7 ZJS |
63 | <filename>/usr/lib/systemd/system/*</filename> |
64 | <filename>/run/systemd/generator.late/*</filename> | |
798d3a52 | 65 | </literallayout></para> |
13219b7f | 66 | |
b82f27e7 ZJS |
67 | <para><literallayout><filename>~/.config/systemd/user.control/*</filename> |
68 | <filename>$XDG_RUNTIME_DIR/systemd/user.control/*</filename> | |
69 | <filename>$XDG_RUNTIME_DIR/systemd/transient/*</filename> | |
70 | <filename>$XDG_RUNTIME_DIR/systemd/generator.early/*</filename> | |
71 | <filename>~/.config/systemd/user/*</filename> | |
12b42c76 | 72 | <filename>/etc/systemd/user/*</filename> |
aa08982d | 73 | <filename>$XDG_RUNTIME_DIR/systemd/user/*</filename> |
13219b7f | 74 | <filename>/run/systemd/user/*</filename> |
b82f27e7 | 75 | <filename>$XDG_RUNTIME_DIR/systemd/generator/*</filename> |
f6e1bd2c | 76 | <filename>~/.local/share/systemd/user/*</filename> |
f6e1bd2c | 77 | <filename>…</filename> |
b82f27e7 ZJS |
78 | <filename>/usr/lib/systemd/user/*</filename> |
79 | <filename>$XDG_RUNTIME_DIR/systemd/generator.late/*</filename> | |
798d3a52 ZJS |
80 | </literallayout></para> |
81 | </refsynopsisdiv> | |
82 | ||
83 | <refsect1> | |
84 | <title>Description</title> | |
85 | ||
86 | <para>A unit configuration file encodes information about a | |
87 | service, a socket, a device, a mount point, an automount point, a | |
88 | swap file or partition, a start-up target, a watched file system | |
89 | path, a timer controlled and supervised by | |
90 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
36b4a7ba | 91 | a resource management slice or |
798d3a52 ZJS |
92 | a group of externally created processes. The syntax is inspired by |
93 | <ulink | |
94 | url="http://standards.freedesktop.org/desktop-entry-spec/latest/">XDG | |
95 | Desktop Entry Specification</ulink> <filename>.desktop</filename> | |
96 | files, which are in turn inspired by Microsoft Windows | |
97 | <filename>.ini</filename> files.</para> | |
98 | ||
99 | <para>This man page lists the common configuration options of all | |
100 | the unit types. These options need to be configured in the [Unit] | |
101 | or [Install] sections of the unit files.</para> | |
102 | ||
103 | <para>In addition to the generic [Unit] and [Install] sections | |
104 | described here, each unit may have a type-specific section, e.g. | |
105 | [Service] for a service unit. See the respective man pages for | |
106 | more information: | |
107 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
108 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
109 | <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
110 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
111 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
112 | <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
113 | <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
114 | <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
115 | <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
36b4a7ba | 116 | <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
798d3a52 ZJS |
117 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>. |
118 | </para> | |
119 | ||
120 | <para>Various settings are allowed to be specified more than once, | |
121 | in which case the interpretation depends on the setting. Often, | |
122 | multiple settings form a list, and setting to an empty value | |
123 | "resets", which means that previous assignments are ignored. When | |
124 | this is allowed, it is mentioned in the description of the | |
125 | setting. Note that using multiple assignments to the same value | |
126 | makes the unit file incompatible with parsers for the XDG | |
127 | <filename>.desktop</filename> file format.</para> | |
128 | ||
129 | <para>Unit files are loaded from a set of paths determined during | |
130 | compilation, described in the next section.</para> | |
131 | ||
132 | <para>Unit files may contain additional options on top of those | |
133 | listed here. If systemd encounters an unknown option, it will | |
134 | write a warning log message but continue loading the unit. If an | |
135 | option or section name is prefixed with <option>X-</option>, it is | |
136 | ignored completely by systemd. Options within an ignored section | |
137 | do not need the prefix. Applications may use this to include | |
138 | additional information in the unit files.</para> | |
139 | ||
140 | <para>Boolean arguments used in unit files can be written in | |
141 | various formats. For positive settings the strings | |
142 | <option>1</option>, <option>yes</option>, <option>true</option> | |
143 | and <option>on</option> are equivalent. For negative settings, the | |
144 | strings <option>0</option>, <option>no</option>, | |
145 | <option>false</option> and <option>off</option> are | |
146 | equivalent.</para> | |
147 | ||
bac150e9 ZJS |
148 | <para>Time span values encoded in unit files can be written in various formats. A stand-alone |
149 | number specifies a time in seconds. If suffixed with a time unit, the unit is honored. A | |
150 | concatenation of multiple values with units is supported, in which case the values are added | |
151 | up. Example: <literal>50</literal> refers to 50 seconds; <literal>2min 200ms</literal> refers to | |
152 | 2 minutes and 200 milliseconds, i.e. 120200 ms. The following time units are understood: | |
153 | <literal>s</literal>, <literal>min</literal>, <literal>h</literal>, <literal>d</literal>, | |
d923e42e | 154 | <literal>w</literal>, <literal>ms</literal>, <literal>us</literal>. For details see |
798d3a52 ZJS |
155 | <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para> |
156 | ||
bac150e9 ZJS |
157 | <para>Empty lines and lines starting with <literal>#</literal> or <literal>;</literal> are |
158 | ignored. This may be used for commenting. Lines ending in a backslash are concatenated with the | |
159 | following line while reading and the backslash is replaced by a space character. This may be | |
160 | used to wrap long lines.</para> | |
161 | ||
162 | <para>Units can be aliased (have an alternative name), by creating a symlink from the new name | |
163 | to the existing name in one of the unit search paths. For example, | |
164 | <filename>systemd-networkd.service</filename> has the alias | |
165 | <filename>dbus-org.freedesktop.network1.service</filename>, created during installation as the | |
166 | symlink <filename>/usr/lib/systemd/system/dbus-org.freedesktop.network1.service</filename>. In | |
167 | addition, unit files may specify aliases through the <varname>Alias=</varname> directive in the | |
168 | [Install] section; those aliases are only effective when the unit is enabled. When the unit is | |
169 | enabled, symlinks will be created for those names, and removed when the unit is disabled. For | |
170 | example, <filename>reboot.target</filename> specifies | |
171 | <varname>Alias=ctrl-alt-del.target</varname>, so when enabled it will be invoked whenever | |
172 | CTRL+ALT+DEL is pressed. Alias names may be used in commands like <command>enable</command>, | |
173 | <command>disable</command>, <command>start</command>, <command>stop</command>, | |
174 | <command>status</command>, …, and in unit dependency directives <varname>Wants=</varname>, | |
175 | <varname>Requires=</varname>, <varname>Before=</varname>, <varname>After=</varname>, …, with the | |
176 | limitation that aliases specified through <varname>Alias=</varname> are only effective when the | |
177 | unit is enabled. Aliases cannot be used with the <command>preset</command> command.</para> | |
178 | ||
179 | <para>Along with a unit file <filename>foo.service</filename>, the directory | |
180 | <filename>foo.service.wants/</filename> may exist. All unit files symlinked from such a | |
181 | directory are implicitly added as dependencies of type <varname>Wants=</varname> to the unit. | |
182 | This is useful to hook units into the start-up of other units, without having to modify their | |
183 | unit files. For details about the semantics of <varname>Wants=</varname>, see below. The | |
184 | preferred way to create symlinks in the <filename>.wants/</filename> directory of a unit file is | |
185 | with the <command>enable</command> command of the | |
798d3a52 | 186 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
bac150e9 ZJS |
187 | tool which reads information from the [Install] section of unit files (see below). A similar |
188 | functionality exists for <varname>Requires=</varname> type dependencies as well, the directory | |
189 | suffix is <filename>.requires/</filename> in this case.</para> | |
798d3a52 | 190 | |
be73bb48 | 191 | <para>Along with a unit file <filename>foo.service</filename>, a "drop-in" directory |
bac150e9 ZJS |
192 | <filename>foo.service.d/</filename> may exist. All files with the suffix |
193 | <literal>.conf</literal> from this directory will be parsed after the file itself is | |
194 | parsed. This is useful to alter or add configuration settings for a unit, without having to | |
195 | modify unit files. Each drop-in file must have appropriate section headers. Note that for | |
196 | instantiated units, this logic will first look for the instance <literal>.d/</literal> | |
197 | subdirectory and read its <literal>.conf</literal> files, followed by the template | |
caa45f5b | 198 | <literal>.d/</literal> subdirectory and the <literal>.conf</literal> files there.</para> |
bac150e9 ZJS |
199 | |
200 | <para>In addition to <filename>/etc/systemd/system</filename>, the drop-in <literal>.d</literal> | |
201 | directories for system services can be placed in <filename>/usr/lib/systemd/system</filename> or | |
202 | <filename>/run/systemd/system</filename> directories. Drop-in files in <filename>/etc</filename> | |
203 | take precedence over those in <filename>/run</filename> which in turn take precedence over those | |
204 | in <filename>/usr/lib</filename>. Drop-in files under any of these directories take precedence | |
8331eaab LW |
205 | over unit files wherever located. Multiple drop-in files with different names are applied in |
206 | lexicographic order, regardless of which of the directories they reside in.</para> | |
bac150e9 ZJS |
207 | |
208 | <!-- Note that we do not document .include here, as we consider it mostly obsolete, and want | |
209 | people to use .d/ drop-ins instead. --> | |
798d3a52 | 210 | |
bbe0b4a8 JL |
211 | <para>Note that while systemd offers a flexible dependency system |
212 | between units it is recommended to use this functionality only | |
213 | sparingly and instead rely on techniques such as bus-based or | |
214 | socket-based activation which make dependencies implicit, | |
215 | resulting in a both simpler and more flexible system.</para> | |
216 | ||
798d3a52 ZJS |
217 | <para>Optionally, units may be instantiated from a |
218 | template file at runtime. This allows creation of | |
219 | multiple units from a single configuration file. If | |
220 | systemd looks for a unit configuration file, it will | |
221 | first search for the literal unit name in the | |
222 | file system. If that yields no success and the unit | |
223 | name contains an <literal>@</literal> character, systemd will look for a | |
224 | unit template that shares the same name but with the | |
225 | instance string (i.e. the part between the <literal>@</literal> character | |
226 | and the suffix) removed. Example: if a service | |
227 | <filename>getty@tty3.service</filename> is requested | |
228 | and no file by that name is found, systemd will look | |
229 | for <filename>getty@.service</filename> and | |
230 | instantiate a service from that configuration file if | |
231 | it is found.</para> | |
232 | ||
233 | <para>To refer to the instance string from within the | |
234 | configuration file you may use the special <literal>%i</literal> | |
235 | specifier in many of the configuration options. See below for | |
236 | details.</para> | |
237 | ||
238 | <para>If a unit file is empty (i.e. has the file size 0) or is | |
239 | symlinked to <filename>/dev/null</filename>, its configuration | |
240 | will not be loaded and it appears with a load state of | |
241 | <literal>masked</literal>, and cannot be activated. Use this as an | |
242 | effective way to fully disable a unit, making it impossible to | |
243 | start it even manually.</para> | |
244 | ||
245 | <para>The unit file format is covered by the | |
246 | <ulink | |
28a0ad81 | 247 | url="https://www.freedesktop.org/wiki/Software/systemd/InterfaceStabilityPromise">Interface |
798d3a52 ZJS |
248 | Stability Promise</ulink>.</para> |
249 | ||
250 | </refsect1> | |
251 | ||
2651d037 LP |
252 | <refsect1> |
253 | <title>String Escaping for Inclusion in Unit Names</title> | |
254 | ||
255 | <para>Sometimes it is useful to convert arbitrary strings into unit names. To facilitate this, a method of string | |
256 | escaping is used, in order to map strings containing arbitrary byte values (except NUL) into valid unit names and | |
257 | their restricted character set. A common special case are unit names that reflect paths to objects in the file | |
258 | system hierarchy. Example: a device unit <filename>dev-sda.device</filename> refers to a device with the device | |
259 | node <filename noindex='true'>/dev/sda</filename> in the file system.</para> | |
260 | ||
261 | <para>The escaping algorithm operates as follows: given a string, any <literal>/</literal> character is replaced by | |
262 | <literal>-</literal>, and all other characters which are not ASCII alphanumerics or <literal>_</literal> are | |
263 | replaced by C-style <literal>\x2d</literal> escapes. In addition, <literal>.</literal> is replaced with such a | |
264 | C-style escape when it would appear as the first character in the escaped string.</para> | |
265 | ||
266 | <para>When the input qualifies as absolute file system path, this algorithm is extended slightly: the path to the | |
267 | root directory <literal>/</literal> is encoded as single dash <literal>-</literal>. In addition, any leading, | |
268 | trailing or duplicate <literal>/</literal> characters are removed from the string before transformation. Example: | |
269 | <filename>/foo//bar/baz/</filename> becomes <literal>foo-bar-baz</literal>.</para> | |
270 | ||
271 | <para>This escaping is fully reversible, as long as it is known whether the escaped string was a path (the | |
272 | unescaping results are different for paths and non-path strings). The | |
273 | <citerefentry><refentrytitle>systemd-escape</refentrytitle><manvolnum>1</manvolnum></citerefentry> command may be | |
274 | used to apply and reverse escaping on arbitrary strings. Use <command>systemd-escape --path</command> to escape | |
275 | path strings, and <command>systemd-escape</command> without <option>--path</option> otherwise.</para> | |
276 | </refsect1> | |
277 | ||
c129bd5d | 278 | <refsect1> |
45f09f93 JL |
279 | <title>Implicit Dependencies</title> |
280 | ||
281 | <para>A number of unit dependencies are implicitly established, | |
282 | depending on unit type and unit configuration. These implicit | |
283 | dependencies can make unit configuration file cleaner. For the | |
284 | implicit dependencies in each unit type, please refer to | |
285 | section "Implicit Dependencies" in respective man pages.</para> | |
286 | ||
287 | <para>For example, service units with <varname>Type=dbus</varname> | |
288 | automatically acquire dependencies of type <varname>Requires=</varname> | |
289 | and <varname>After=</varname> on <filename>dbus.socket</filename>. See | |
290 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
c129bd5d LP |
291 | for details.</para> |
292 | </refsect1> | |
293 | ||
45f09f93 JL |
294 | <refsect1> |
295 | <title>Default Dependencies</title> | |
296 | ||
297 | <para>Default dependencies are similar to implicit dependencies, | |
298 | but can be turned on and off by setting | |
299 | <varname>DefaultDependencies=</varname> to <varname>yes</varname> | |
300 | (the default) and <varname>no</varname>, while implicit dependencies | |
301 | are always in effect. See section "Default Dependencies" in respective | |
302 | man pages for the effect of enabling | |
303 | <varname>DefaultDependencies=</varname> in each unit types.</para> | |
304 | ||
305 | <para>For example, target units will complement all configured | |
dcfaecc7 | 306 | dependencies of type <varname>Wants=</varname> or |
45f09f93 | 307 | <varname>Requires=</varname> with dependencies of type |
c85f1346 YW |
308 | <varname>After=</varname> unless <varname>DefaultDependencies=no</varname> |
309 | is set in the specified units. See | |
45f09f93 JL |
310 | <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
311 | for details. Note that this behavior can be turned off by setting | |
312 | <varname>DefaultDependencies=no</varname>.</para> | |
313 | </refsect1> | |
314 | ||
798d3a52 | 315 | <refsect1> |
f757855e | 316 | <title>Unit File Load Path</title> |
798d3a52 ZJS |
317 | |
318 | <para>Unit files are loaded from a set of paths determined during | |
319 | compilation, described in the two tables below. Unit files found | |
320 | in directories listed earlier override files with the same name in | |
321 | directories lower in the list.</para> | |
322 | ||
aa3e4400 EV |
323 | <para>When the variable <varname>$SYSTEMD_UNIT_PATH</varname> is set, |
324 | the contents of this variable overrides the unit load path. If | |
798d3a52 ZJS |
325 | <varname>$SYSTEMD_UNIT_PATH</varname> ends with an empty component |
326 | (<literal>:</literal>), the usual unit load path will be appended | |
327 | to the contents of the variable.</para> | |
328 | ||
329 | <table> | |
330 | <title> | |
331 | Load path when running in system mode (<option>--system</option>). | |
332 | </title> | |
333 | ||
334 | <tgroup cols='2'> | |
335 | <colspec colname='path' /> | |
336 | <colspec colname='expl' /> | |
337 | <thead> | |
338 | <row> | |
5a15caf4 ZJS |
339 | <entry>Path</entry> |
340 | <entry>Description</entry> | |
798d3a52 ZJS |
341 | </row> |
342 | </thead> | |
343 | <tbody> | |
b82f27e7 ZJS |
344 | <row> |
345 | <entry><filename>/etc/systemd/system.control</filename></entry> | |
346 | <entry morerows="1">Persistent and transient configuration created using the dbus API</entry> | |
347 | </row> | |
348 | <row> | |
349 | <entry><filename>/run/systemd/system.control</filename></entry> | |
350 | </row> | |
351 | <row> | |
352 | <entry><filename>/run/systemd/transient</filename></entry> | |
353 | <entry>Dynamic configuration for transient units</entry> | |
354 | </row> | |
355 | <row> | |
356 | <entry><filename>/run/systemd/generator.early</filename></entry> | |
357 | <entry>Generated units with high priority (see <replaceable>early-dir</replaceable> in <citerefentry | |
358 | ><refentrytitle>system.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> | |
359 | </row> | |
798d3a52 | 360 | <row> |
5a15caf4 ZJS |
361 | <entry><filename>/etc/systemd/system</filename></entry> |
362 | <entry>Local configuration</entry> | |
798d3a52 ZJS |
363 | </row> |
364 | <row> | |
5a15caf4 ZJS |
365 | <entry><filename>/run/systemd/system</filename></entry> |
366 | <entry>Runtime units</entry> | |
798d3a52 | 367 | </row> |
b82f27e7 ZJS |
368 | <row> |
369 | <entry><filename>/run/systemd/generator</filename></entry> | |
370 | <entry>Generated units with medium priority (see <replaceable>normal-dir</replaceable> in <citerefentry | |
371 | ><refentrytitle>system.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> | |
372 | </row> | |
373 | <row> | |
374 | <entry><filename>/usr/local/lib/systemd/system</filename></entry> | |
375 | <entry morerows="1">Units of installed packages</entry> | |
376 | </row> | |
798d3a52 | 377 | <row> |
5a15caf4 | 378 | <entry><filename>/usr/lib/systemd/system</filename></entry> |
b82f27e7 ZJS |
379 | </row> |
380 | <row> | |
381 | <entry><filename>/run/systemd/generator.late</filename></entry> | |
382 | <entry>Generated units with low priority (see <replaceable>late-dir</replaceable> in <citerefentry | |
383 | ><refentrytitle>system.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> | |
798d3a52 ZJS |
384 | </row> |
385 | </tbody> | |
386 | </tgroup> | |
387 | </table> | |
388 | ||
389 | <table> | |
390 | <title> | |
391 | Load path when running in user mode (<option>--user</option>). | |
392 | </title> | |
393 | ||
394 | <tgroup cols='2'> | |
395 | <colspec colname='path' /> | |
396 | <colspec colname='expl' /> | |
397 | <thead> | |
398 | <row> | |
5a15caf4 ZJS |
399 | <entry>Path</entry> |
400 | <entry>Description</entry> | |
798d3a52 ZJS |
401 | </row> |
402 | </thead> | |
403 | <tbody> | |
404 | <row> | |
b82f27e7 ZJS |
405 | <entry><filename>$XDG_CONFIG_HOME/systemd/user.control</filename> or <filename |
406 | >~/.config/systemd/user.control</filename></entry> | |
407 | <entry morerows="1">Persistent and transient configuration created using the dbus API (<varname>$XDG_CONFIG_HOME</varname> is used if set, <filename>~/.config</filename> otherwise)</entry> | |
408 | </row> | |
409 | <row> | |
410 | <entry><filename>$XDG_RUNTIME_DIR/systemd/user.control</filename></entry> | |
411 | </row> | |
412 | <row> | |
413 | <entry><filename>/run/systemd/transient</filename></entry> | |
414 | <entry>Dynamic configuration for transient units</entry> | |
415 | </row> | |
416 | <row> | |
417 | <entry><filename>/run/systemd/generator.early</filename></entry> | |
418 | <entry>Generated units with high priority (see <replaceable>early-dir</replaceable> in <citerefentry | |
419 | ><refentrytitle>system.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> | |
798d3a52 ZJS |
420 | </row> |
421 | <row> | |
b82f27e7 ZJS |
422 | <entry><filename>$XDG_CONFIG_HOME/systemd/user</filename> or <filename>$HOME/.config/systemd/user</filename></entry> |
423 | <entry>User configuration (<varname>$XDG_CONFIG_HOME</varname> is used if set, <filename>~/.config</filename> otherwise)</entry> | |
798d3a52 ZJS |
424 | </row> |
425 | <row> | |
5a15caf4 ZJS |
426 | <entry><filename>/etc/systemd/user</filename></entry> |
427 | <entry>Local configuration</entry> | |
798d3a52 ZJS |
428 | </row> |
429 | <row> | |
5a15caf4 ZJS |
430 | <entry><filename>$XDG_RUNTIME_DIR/systemd/user</filename></entry> |
431 | <entry>Runtime units (only used when $XDG_RUNTIME_DIR is set)</entry> | |
798d3a52 ZJS |
432 | </row> |
433 | <row> | |
5a15caf4 ZJS |
434 | <entry><filename>/run/systemd/user</filename></entry> |
435 | <entry>Runtime units</entry> | |
798d3a52 ZJS |
436 | </row> |
437 | <row> | |
b82f27e7 ZJS |
438 | <entry><filename>$XDG_RUNTIME_DIR/systemd/generator</filename></entry> |
439 | <entry>Generated units with medium priority (see <replaceable>normal-dir</replaceable> in <citerefentry | |
440 | ><refentrytitle>system.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> | |
798d3a52 ZJS |
441 | </row> |
442 | <row> | |
b82f27e7 ZJS |
443 | <entry><filename>$XDG_DATA_HOME/systemd/user</filename> or <filename>$HOME/.local/share/systemd/user</filename></entry> |
444 | <entry>Units of packages that have been installed in the home directory (<varname>$XDG_DATA_HOME</varname> is used if set, <filename>~/.local/share</filename> otherwise)</entry> | |
445 | </row> | |
446 | <row> | |
447 | <entry><filename>$dir/systemd/user</filename> for each <varname noindex='true'>$dir</varname> in <varname>$XDG_DATA_DIRS</varname></entry> | |
448 | <entry>Additional locations for installed user units, one for each entry in <varname>$XDG_DATA_DIRS</varname></entry> | |
449 | </row> | |
450 | <row> | |
451 | <entry><filename>/usr/local/lib/systemd/user</filename></entry> | |
452 | <entry morerows="1">Units of packages that have been installed system-wide</entry> | |
798d3a52 ZJS |
453 | </row> |
454 | <row> | |
5a15caf4 | 455 | <entry><filename>/usr/lib/systemd/user</filename></entry> |
b82f27e7 ZJS |
456 | </row> |
457 | <row> | |
458 | <entry><filename>$XDG_RUNTIME_DIR/systemd/generator.late</filename></entry> | |
459 | <entry>Generated units with low priority (see <replaceable>late-dir</replaceable> in <citerefentry | |
460 | ><refentrytitle>system.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> | |
798d3a52 ZJS |
461 | </row> |
462 | </tbody> | |
463 | </tgroup> | |
464 | </table> | |
465 | ||
b82f27e7 ZJS |
466 | <para>The set of load paths for the user manager instance may be augmented or |
467 | changed using various environment variables. And environment variables may in | |
468 | turn be set using environment generators, see | |
469 | <citerefentry><refentrytitle>system.environment-generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>. | |
470 | In particular, <varname>$XDG_DATA_HOME</varname> and | |
471 | <varname>$XDG_DATA_DIRS</varname> may be easily set using | |
472 | <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>. | |
473 | Thus, directories listed here are just the defaults. To see the actual list that | |
474 | would be used based on compilation options and current environment use | |
475 | <programlisting>systemd-analyze --user unit-paths</programlisting> | |
476 | </para> | |
477 | ||
478 | <para>Moreover, additional units might be loaded into systemd ("linked") from | |
479 | directories not on the unit load path. See the <command>link</command> command | |
480 | for | |
798d3a52 | 481 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>. |
798d3a52 ZJS |
482 | </para> |
483 | </refsect1> | |
484 | ||
5afe510c LP |
485 | <refsect1> |
486 | <title>Unit Garbage Collection</title> | |
487 | ||
488 | <para>The system and service manager loads a unit's configuration automatically when a unit is referenced for the | |
489 | first time. It will automatically unload the unit configuration and state again when the unit is not needed anymore | |
490 | ("garbage collection"). A unit may be referenced through a number of different mechanisms:</para> | |
491 | ||
492 | <orderedlist> | |
493 | <listitem><para>Another loaded unit references it with a dependency such as <varname>After=</varname>, | |
494 | <varname>Wants=</varname>, …</para></listitem> | |
495 | ||
496 | <listitem><para>The unit is currently starting, running, reloading or stopping.</para></listitem> | |
497 | ||
498 | <listitem><para>The unit is currently in the <constant>failed</constant> state. (But see below.)</para></listitem> | |
499 | ||
500 | <listitem><para>A job for the unit is pending.</para></listitem> | |
501 | ||
502 | <listitem><para>The unit is pinned by an active IPC client program.</para></listitem> | |
503 | ||
504 | <listitem><para>The unit is a special "perpetual" unit that is always active and loaded. Examples for perpetual | |
505 | units are the root mount unit <filename>-.mount</filename> or the scope unit <filename>init.scope</filename> that | |
506 | the service manager itself lives in.</para></listitem> | |
507 | ||
508 | <listitem><para>The unit has running processes associated with it.</para></listitem> | |
509 | </orderedlist> | |
510 | ||
511 | <para>The garbage collection logic may be altered with the <varname>CollectMode=</varname> option, which allows | |
512 | configuration whether automatic unloading of units that are in <constant>failed</constant> state is permissible, | |
513 | see below.</para> | |
514 | ||
515 | <para>Note that when a unit's configuration and state is unloaded, all execution results, such as exit codes, exit | |
516 | signals, resource consumption and other statistics are lost, except for what is stored in the log subsystem.</para> | |
517 | ||
518 | <para>Use <command>systemctl daemon-reload</command> or an equivalent command to reload unit configuration while | |
519 | the unit is already loaded. In this case all configuration settings are flushed out and replaced with the new | |
520 | configuration (which however might not be in effect immediately), however all runtime state is | |
521 | saved/restored.</para> | |
522 | </refsect1> | |
523 | ||
798d3a52 ZJS |
524 | <refsect1> |
525 | <title>[Unit] Section Options</title> | |
526 | ||
a8eaaee7 | 527 | <para>The unit file may include a [Unit] section, which carries |
798d3a52 ZJS |
528 | generic information about the unit that is not dependent on the |
529 | type of unit:</para> | |
530 | ||
531 | <variablelist class='unit-directives'> | |
532 | ||
533 | <varlistentry> | |
534 | <term><varname>Description=</varname></term> | |
535 | <listitem><para>A free-form string describing the unit. This | |
536 | is intended for use in UIs to show descriptive information | |
537 | along with the unit name. The description should contain a | |
538 | name that means something to the end user. <literal>Apache2 | |
539 | Web Server</literal> is a good example. Bad examples are | |
540 | <literal>high-performance light-weight HTTP server</literal> | |
541 | (too generic) or <literal>Apache2</literal> (too specific and | |
542 | meaningless for people who do not know | |
543 | Apache).</para></listitem> | |
544 | </varlistentry> | |
545 | ||
546 | <varlistentry> | |
547 | <term><varname>Documentation=</varname></term> | |
548 | <listitem><para>A space-separated list of URIs referencing | |
549 | documentation for this unit or its configuration. Accepted are | |
550 | only URIs of the types <literal>http://</literal>, | |
551 | <literal>https://</literal>, <literal>file:</literal>, | |
552 | <literal>info:</literal>, <literal>man:</literal>. For more | |
553 | information about the syntax of these URIs, see <citerefentry | |
554 | project='man-pages'><refentrytitle>uri</refentrytitle><manvolnum>7</manvolnum></citerefentry>. | |
555 | The URIs should be listed in order of relevance, starting with | |
556 | the most relevant. It is a good idea to first reference | |
557 | documentation that explains what the unit's purpose is, | |
558 | followed by how it is configured, followed by any other | |
559 | related documentation. This option may be specified more than | |
560 | once, in which case the specified list of URIs is merged. If | |
561 | the empty string is assigned to this option, the list is reset | |
562 | and all prior assignments will have no | |
563 | effect.</para></listitem> | |
564 | </varlistentry> | |
565 | ||
566 | <varlistentry> | |
567 | <term><varname>Requires=</varname></term> | |
568 | ||
62d3ca24 | 569 | <listitem><para>Configures requirement dependencies on other units. If this unit gets activated, the units |
a195dd8e | 570 | listed here will be activated as well. If one of the other units fails to activate, and an ordering dependency |
e79eabdb | 571 | <varname>After=</varname> on the failing unit is set, this unit will not be started. Besides, with or without |
22a70563 ZJS |
572 | specifying <varname>After=</varname>, this unit will be stopped if one of the other units is explicitly |
573 | stopped. This option may be specified more than once or multiple space-separated units may be | |
62d3ca24 LP |
574 | specified in one option in which case requirement dependencies for all listed names will be created. Note that |
575 | requirement dependencies do not influence the order in which services are started or stopped. This has to be | |
576 | configured independently with the <varname>After=</varname> or <varname>Before=</varname> options. If a unit | |
577 | <filename>foo.service</filename> requires a unit <filename>bar.service</filename> as configured with | |
578 | <varname>Requires=</varname> and no ordering is configured with <varname>After=</varname> or | |
579 | <varname>Before=</varname>, then both units will be started simultaneously and without any delay between them | |
580 | if <filename>foo.service</filename> is activated. Often, it is a better choice to use <varname>Wants=</varname> | |
581 | instead of <varname>Requires=</varname> in order to achieve a system that is more robust when dealing with | |
582 | failing services.</para> | |
583 | ||
584 | <para>Note that this dependency type does not imply that the other unit always has to be in active state when | |
585 | this unit is running. Specifically: failing condition checks (such as <varname>ConditionPathExists=</varname>, | |
6b5bb2f9 | 586 | <varname>ConditionPathIsSymbolicLink=</varname>, … — see below) do not cause the start job of a unit with a |
62d3ca24 LP |
587 | <varname>Requires=</varname> dependency on it to fail. Also, some unit types may deactivate on their own (for |
588 | example, a service process may decide to exit cleanly, or a device may be unplugged by the user), which is not | |
589 | propagated to units having a <varname>Requires=</varname> dependency. Use the <varname>BindsTo=</varname> | |
590 | dependency type together with <varname>After=</varname> to ensure that a unit may never be in active state | |
591 | without a specific other unit also in active state (see below).</para> | |
592 | ||
593 | <para>Note that dependencies of this type may also be configured outside of the unit configuration file by | |
594 | adding a symlink to a <filename>.requires/</filename> directory accompanying the unit file. For details, see | |
798d3a52 ZJS |
595 | above.</para></listitem> |
596 | </varlistentry> | |
597 | ||
798d3a52 ZJS |
598 | <varlistentry> |
599 | <term><varname>Requisite=</varname></term> | |
798d3a52 | 600 | |
f32b43bd | 601 | <listitem><para>Similar to <varname>Requires=</varname>. |
798d3a52 ZJS |
602 | However, if the units listed here are not started already, |
603 | they will not be started and the transaction will fail | |
b2920668 ZJS |
604 | immediately.</para> |
605 | ||
606 | <para>When <varname>Requisite=b.service</varname> is used on | |
607 | <filename>a.service</filename>, this dependency will show as | |
608 | <varname>RequisiteOf=a.service</varname> in property listing of | |
609 | <filename>b.service</filename>. <varname>RequisiteOf=</varname> | |
610 | dependency cannot be specified directly.</para> | |
611 | </listitem> | |
798d3a52 ZJS |
612 | </varlistentry> |
613 | ||
614 | <varlistentry> | |
615 | <term><varname>Wants=</varname></term> | |
616 | ||
617 | <listitem><para>A weaker version of | |
618 | <varname>Requires=</varname>. Units listed in this option will | |
619 | be started if the configuring unit is. However, if the listed | |
620 | units fail to start or cannot be added to the transaction, | |
621 | this has no impact on the validity of the transaction as a | |
622 | whole. This is the recommended way to hook start-up of one | |
623 | unit to the start-up of another unit.</para> | |
624 | ||
625 | <para>Note that dependencies of this type may also be | |
626 | configured outside of the unit configuration file by adding | |
627 | symlinks to a <filename>.wants/</filename> directory | |
628 | accompanying the unit file. For details, see | |
629 | above.</para></listitem> | |
630 | </varlistentry> | |
631 | ||
632 | <varlistentry> | |
633 | <term><varname>BindsTo=</varname></term> | |
634 | ||
62d3ca24 LP |
635 | <listitem><para>Configures requirement dependencies, very similar in style to |
636 | <varname>Requires=</varname>. However, this dependency type is stronger: in addition to the effect of | |
637 | <varname>Requires=</varname> it declares that if the unit bound to is stopped, this unit will be stopped | |
638 | too. This means a unit bound to another unit that suddenly enters inactive state will be stopped too. | |
639 | Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit | |
640 | might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of | |
641 | a mount unit might be unmounted without involvement of the system and service manager.</para> | |
642 | ||
643 | <para>When used in conjunction with <varname>After=</varname> on the same unit the behaviour of | |
644 | <varname>BindsTo=</varname> is even stronger. In this case, the unit bound to strictly has to be in active | |
645 | state for this unit to also be in active state. This not only means a unit bound to another unit that suddenly | |
646 | enters inactive state, but also one that is bound to another unit that gets skipped due to a failed condition | |
647 | check (such as <varname>ConditionPathExists=</varname>, <varname>ConditionPathIsSymbolicLink=</varname>, … — | |
648 | see below) will be stopped, should it be running. Hence, in many cases it is best to combine | |
b2920668 ZJS |
649 | <varname>BindsTo=</varname> with <varname>After=</varname>.</para> |
650 | ||
651 | <para>When <varname>BindsTo=b.service</varname> is used on | |
652 | <filename>a.service</filename>, this dependency will show as | |
653 | <varname>BoundBy=a.service</varname> in property listing of | |
654 | <filename>b.service</filename>. <varname>BoundBy=</varname> | |
655 | dependency cannot be specified directly.</para> | |
656 | </listitem> | |
798d3a52 ZJS |
657 | </varlistentry> |
658 | ||
659 | <varlistentry> | |
660 | <term><varname>PartOf=</varname></term> | |
661 | ||
662 | <listitem><para>Configures dependencies similar to | |
663 | <varname>Requires=</varname>, but limited to stopping and | |
664 | restarting of units. When systemd stops or restarts the units | |
665 | listed here, the action is propagated to this unit. Note that | |
666 | this is a one-way dependency — changes to this unit do not | |
b2920668 ZJS |
667 | affect the listed units.</para> |
668 | ||
669 | <para>When <varname>PartOf=b.service</varname> is used on | |
670 | <filename>a.service</filename>, this dependency will show as | |
671 | <varname>ConsistsOf=a.service</varname> in property listing of | |
672 | <filename>b.service</filename>. <varname>ConsistsOf=</varname> | |
673 | dependency cannot be specified directly.</para> | |
674 | </listitem> | |
798d3a52 ZJS |
675 | </varlistentry> |
676 | ||
677 | <varlistentry> | |
678 | <term><varname>Conflicts=</varname></term> | |
679 | ||
680 | <listitem><para>A space-separated list of unit names. | |
681 | Configures negative requirement dependencies. If a unit has a | |
682 | <varname>Conflicts=</varname> setting on another unit, | |
683 | starting the former will stop the latter and vice versa. Note | |
684 | that this setting is independent of and orthogonal to the | |
685 | <varname>After=</varname> and <varname>Before=</varname> | |
686 | ordering dependencies.</para> | |
687 | ||
688 | <para>If a unit A that conflicts with a unit B is scheduled to | |
689 | be started at the same time as B, the transaction will either | |
690 | fail (in case both are required part of the transaction) or be | |
691 | modified to be fixed (in case one or both jobs are not a | |
692 | required part of the transaction). In the latter case, the job | |
693 | that is not the required will be removed, or in case both are | |
694 | not required, the unit that conflicts will be started and the | |
695 | unit that is conflicted is stopped.</para></listitem> | |
696 | </varlistentry> | |
697 | ||
698 | <varlistentry> | |
699 | <term><varname>Before=</varname></term> | |
700 | <term><varname>After=</varname></term> | |
701 | ||
2eb6ff5e LP |
702 | <listitem><para>These two settings expect a space-separated list of unit names. They configure ordering |
703 | dependencies between units. If a unit <filename>foo.service</filename> contains a setting | |
704 | <option>Before=bar.service</option> and both units are being started, <filename>bar.service</filename>'s | |
705 | start-up is delayed until <filename>foo.service</filename> has finished starting up. Note that this setting is | |
706 | independent of and orthogonal to the requirement dependencies as configured by <varname>Requires=</varname>, | |
707 | <varname>Wants=</varname> or <varname>BindsTo=</varname>. It is a common pattern to include a unit name in both | |
708 | the <varname>After=</varname> and <varname>Requires=</varname> options, in which case the unit listed will be | |
709 | started before the unit that is configured with these options. This option may be specified more than once, in | |
710 | which case ordering dependencies for all listed names are created. <varname>After=</varname> is the inverse of | |
711 | <varname>Before=</varname>, i.e. while <varname>After=</varname> ensures that the configured unit is started | |
712 | after the listed unit finished starting up, <varname>Before=</varname> ensures the opposite, that the | |
713 | configured unit is fully started up before the listed unit is started. Note that when two units with an | |
714 | ordering dependency between them are shut down, the inverse of the start-up order is applied. i.e. if a unit is | |
715 | configured with <varname>After=</varname> on another unit, the former is stopped before the latter if both are | |
716 | shut down. Given two units with any ordering dependency between them, if one unit is shut down and the other is | |
717 | started up, the shutdown is ordered before the start-up. It doesn't matter if the ordering dependency is | |
718 | <varname>After=</varname> or <varname>Before=</varname>, in this case. It also doesn't matter which of the two | |
719 | is shut down, as long as one is shut down and the other is started up. The shutdown is ordered before the | |
720 | start-up in all cases. If two units have no ordering dependencies between them, they are shut down or started | |
721 | up simultaneously, and no ordering takes place. It depends on the unit type when precisely a unit has finished | |
722 | starting up. Most importantly, for service units start-up is considered completed for the purpose of | |
723 | <varname>Before=</varname>/<varname>After=</varname> when all its configured start-up commands have been | |
724 | invoked and they either failed or reported start-up success.</para></listitem> | |
798d3a52 ZJS |
725 | </varlistentry> |
726 | ||
727 | <varlistentry> | |
728 | <term><varname>OnFailure=</varname></term> | |
729 | ||
730 | <listitem><para>A space-separated list of one or more units | |
731 | that are activated when this unit enters the | |
bd2538b5 KBM |
732 | <literal>failed</literal> state. A service unit using |
733 | <varname>Restart=</varname> enters the failed state only after | |
734 | the start limits are reached.</para></listitem> | |
798d3a52 ZJS |
735 | </varlistentry> |
736 | ||
737 | <varlistentry> | |
738 | <term><varname>PropagatesReloadTo=</varname></term> | |
739 | <term><varname>ReloadPropagatedFrom=</varname></term> | |
740 | ||
741 | <listitem><para>A space-separated list of one or more units | |
742 | where reload requests on this unit will be propagated to, or | |
743 | reload requests on the other unit will be propagated to this | |
744 | unit, respectively. Issuing a reload request on a unit will | |
745 | automatically also enqueue a reload request on all units that | |
746 | the reload request shall be propagated to via these two | |
747 | settings.</para></listitem> | |
748 | </varlistentry> | |
749 | ||
750 | <varlistentry> | |
751 | <term><varname>JoinsNamespaceOf=</varname></term> | |
752 | ||
753 | <listitem><para>For units that start processes (such as | |
754 | service units), lists one or more other units whose network | |
755 | and/or temporary file namespace to join. This only applies to | |
756 | unit types which support the | |
757 | <varname>PrivateNetwork=</varname> and | |
758 | <varname>PrivateTmp=</varname> directives (see | |
759 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
760 | for details). If a unit that has this setting set is started, | |
761 | its processes will see the same <filename>/tmp</filename>, | |
80f524a4 | 762 | <filename>/var/tmp</filename> and network namespace as one |
798d3a52 ZJS |
763 | listed unit that is started. If multiple listed units are |
764 | already started, it is not defined which namespace is joined. | |
765 | Note that this setting only has an effect if | |
766 | <varname>PrivateNetwork=</varname> and/or | |
767 | <varname>PrivateTmp=</varname> is enabled for both the unit | |
768 | that joins the namespace and the unit whose namespace is | |
769 | joined.</para></listitem> | |
770 | </varlistentry> | |
771 | ||
772 | <varlistentry> | |
773 | <term><varname>RequiresMountsFor=</varname></term> | |
774 | ||
775 | <listitem><para>Takes a space-separated list of absolute | |
776 | paths. Automatically adds dependencies of type | |
777 | <varname>Requires=</varname> and <varname>After=</varname> for | |
778 | all mount units required to access the specified path.</para> | |
779 | ||
780 | <para>Mount points marked with <option>noauto</option> are not | |
88e328fd ZJS |
781 | mounted automatically through <filename>local-fs.target</filename>, |
782 | but are still honored for the purposes of this option, i.e. they | |
783 | will be pulled in by this unit.</para></listitem> | |
798d3a52 ZJS |
784 | </varlistentry> |
785 | ||
786 | <varlistentry> | |
787 | <term><varname>OnFailureJobMode=</varname></term> | |
788 | ||
789 | <listitem><para>Takes a value of | |
790 | <literal>fail</literal>, | |
791 | <literal>replace</literal>, | |
792 | <literal>replace-irreversibly</literal>, | |
793 | <literal>isolate</literal>, | |
794 | <literal>flush</literal>, | |
795 | <literal>ignore-dependencies</literal> or | |
796 | <literal>ignore-requirements</literal>. Defaults to | |
797 | <literal>replace</literal>. Specifies how the units listed in | |
798 | <varname>OnFailure=</varname> will be enqueued. See | |
799 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s | |
800 | <option>--job-mode=</option> option for details on the | |
801 | possible values. If this is set to <literal>isolate</literal>, | |
802 | only a single unit may be listed in | |
803 | <varname>OnFailure=</varname>..</para></listitem> | |
804 | </varlistentry> | |
805 | ||
806 | <varlistentry> | |
807 | <term><varname>IgnoreOnIsolate=</varname></term> | |
808 | ||
26adf774 ZJS |
809 | <listitem><para>Takes a boolean argument. If <option>true</option>, this unit |
810 | will not be stopped when isolating another unit. Defaults to | |
811 | <option>false</option> for service, target, socket, busname, timer, and path | |
812 | units, and <option>true</option> for slice, scope, device, swap, mount, and | |
813 | automount units.</para></listitem> | |
798d3a52 ZJS |
814 | </varlistentry> |
815 | ||
798d3a52 ZJS |
816 | <varlistentry> |
817 | <term><varname>StopWhenUnneeded=</varname></term> | |
818 | ||
819 | <listitem><para>Takes a boolean argument. If | |
820 | <option>true</option>, this unit will be stopped when it is no | |
b938cb90 | 821 | longer used. Note that, in order to minimize the work to be |
798d3a52 ZJS |
822 | executed, systemd will not stop units by default unless they |
823 | are conflicting with other units, or the user explicitly | |
824 | requested their shut down. If this option is set, a unit will | |
825 | be automatically cleaned up if no other active unit requires | |
826 | it. Defaults to <option>false</option>.</para></listitem> | |
827 | </varlistentry> | |
828 | ||
829 | <varlistentry> | |
830 | <term><varname>RefuseManualStart=</varname></term> | |
831 | <term><varname>RefuseManualStop=</varname></term> | |
832 | ||
833 | <listitem><para>Takes a boolean argument. If | |
834 | <option>true</option>, this unit can only be activated or | |
835 | deactivated indirectly. In this case, explicit start-up or | |
836 | termination requested by the user is denied, however if it is | |
837 | started or stopped as a dependency of another unit, start-up | |
838 | or termination will succeed. This is mostly a safety feature | |
839 | to ensure that the user does not accidentally activate units | |
840 | that are not intended to be activated explicitly, and not | |
841 | accidentally deactivate units that are not intended to be | |
842 | deactivated. These options default to | |
843 | <option>false</option>.</para></listitem> | |
844 | </varlistentry> | |
845 | ||
846 | <varlistentry> | |
847 | <term><varname>AllowIsolate=</varname></term> | |
848 | ||
849 | <listitem><para>Takes a boolean argument. If | |
850 | <option>true</option>, this unit may be used with the | |
851 | <command>systemctl isolate</command> command. Otherwise, this | |
852 | will be refused. It probably is a good idea to leave this | |
853 | disabled except for target units that shall be used similar to | |
854 | runlevels in SysV init systems, just as a precaution to avoid | |
855 | unusable system states. This option defaults to | |
856 | <option>false</option>.</para></listitem> | |
857 | </varlistentry> | |
858 | ||
859 | <varlistentry> | |
860 | <term><varname>DefaultDependencies=</varname></term> | |
861 | ||
862 | <listitem><para>Takes a boolean argument. If | |
863 | <option>true</option>, (the default), a few default | |
864 | dependencies will implicitly be created for the unit. The | |
865 | actual dependencies created depend on the unit type. For | |
866 | example, for service units, these dependencies ensure that the | |
867 | service is started only after basic system initialization is | |
868 | completed and is properly terminated on system shutdown. See | |
869 | the respective man pages for details. Generally, only services | |
870 | involved with early boot or late shutdown should set this | |
871 | option to <option>false</option>. It is highly recommended to | |
872 | leave this option enabled for the majority of common units. If | |
873 | set to <option>false</option>, this option does not disable | |
874 | all implicit dependencies, just non-essential | |
875 | ones.</para></listitem> | |
876 | </varlistentry> | |
877 | ||
5afe510c LP |
878 | <varlistentry> |
879 | <term><varname>CollectMode=</varname></term> | |
880 | ||
881 | <listitem><para>Tweaks the "garbage collection" algorithm for this unit. Takes one of <option>inactive</option> | |
882 | or <option>inactive-or-failed</option>. If set to <option>inactive</option> the unit will be unloaded if it is | |
883 | in the <constant>inactive</constant> state and is not referenced by clients, jobs or other units — however it | |
884 | is not unloaded if it is in the <constant>failed</constant> state. In <option>failed</option> mode, failed | |
885 | units are not unloaded until the user invoked <command>systemctl reset-failed</command> on them to reset the | |
886 | <constant>failed</constant> state, or an equivalent command. This behaviour is altered if this option is set to | |
887 | <option>inactive-or-failed</option>: in this case the unit is unloaded even if the unit is in a | |
888 | <constant>failed</constant> state, and thus an explicitly resetting of the <constant>failed</constant> state is | |
889 | not necessary. Note that if this mode is used unit results (such as exit codes, exit signals, consumed | |
890 | resources, …) are flushed out immediately after the unit completed, except for what is stored in the logging | |
891 | subsystem. Defaults to <option>inactive</option>.</para> | |
892 | </listitem> | |
893 | </varlistentry> | |
894 | ||
798d3a52 ZJS |
895 | <varlistentry> |
896 | <term><varname>JobTimeoutSec=</varname></term> | |
a2df3ea4 | 897 | <term><varname>JobRunningTimeoutSec=</varname></term> |
798d3a52 ZJS |
898 | <term><varname>JobTimeoutAction=</varname></term> |
899 | <term><varname>JobTimeoutRebootArgument=</varname></term> | |
900 | ||
a2df3ea4 MK |
901 | <listitem><para>When a job for this unit is queued, a time-out <varname>JobTimeoutSec=</varname> may be |
902 | configured. Similarly, <varname>JobRunningTimeoutSec=</varname> starts counting when the queued job is actually | |
903 | started. If either time limit is reached, the job will be cancelled, the unit however will not change state or | |
904 | even enter the <literal>failed</literal> mode. This value defaults to <literal>infinity</literal> (job timeouts | |
905 | disabled), except for device units (<varname>JobRunningTimeoutSec=</varname> defaults to | |
906 | <varname>DefaultTimeoutStartSec=</varname>). NB: this timeout is independent from any unit-specific timeout | |
907 | (for example, the timeout set with <varname>TimeoutStartSec=</varname> in service units) as the job timeout has | |
908 | no effect on the unit itself, only on the job that might be pending for it. Or in other words: unit-specific | |
909 | timeouts are useful to abort unit state changes, and revert them. The job timeout set with this option however | |
910 | is useful to abort only the job waiting for the unit state to change.</para> | |
798d3a52 | 911 | |
0aabe747 AJ |
912 | <para><varname>JobTimeoutAction=</varname> optionally configures an additional action to take when the time-out |
913 | is hit. It takes the same values as <varname>StartLimitAction=</varname>. Defaults to <option>none</option>. | |
914 | <varname>JobTimeoutRebootArgument=</varname> configures an optional reboot string to pass to the | |
798d3a52 ZJS |
915 | <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> |
916 | system call.</para></listitem> | |
917 | </varlistentry> | |
918 | ||
6bf0f408 | 919 | <varlistentry> |
fc5ffacd ZJS |
920 | <term><varname>StartLimitIntervalSec=<replaceable>interval</replaceable></varname></term> |
921 | <term><varname>StartLimitBurst=<replaceable>burst</replaceable></varname></term> | |
6bf0f408 | 922 | |
fc5ffacd | 923 | <listitem><para>Configure unit start rate limiting. Units which are started more than |
b94f4313 LP |
924 | <replaceable>burst</replaceable> times within an <replaceable>interval</replaceable> time interval are not |
925 | permitted to start any more. Use <varname>StartLimitIntervalSec=</varname> to configure the checking interval | |
926 | (defaults to <varname>DefaultStartLimitIntervalSec=</varname> in manager configuration file, set it to 0 to | |
927 | disable any kind of rate limiting). Use <varname>StartLimitBurst=</varname> to configure how many starts per | |
928 | interval are allowed (defaults to <varname>DefaultStartLimitBurst=</varname> in manager configuration | |
929 | file). These configuration options are particularly useful in conjunction with the service setting | |
930 | <varname>Restart=</varname> (see | |
6bf0f408 LP |
931 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>); however, |
932 | they apply to all kinds of starts (including manual), not just those triggered by the | |
933 | <varname>Restart=</varname> logic. Note that units which are configured for <varname>Restart=</varname> and | |
934 | which reach the start limit are not attempted to be restarted anymore; however, they may still be restarted | |
b94f4313 LP |
935 | manually at a later point, after the <replaceable>interval</replaceable> has passed. From this point on, the |
936 | restart logic is activated again. Note that <command>systemctl reset-failed</command> will cause the restart | |
937 | rate counter for a service to be flushed, which is useful if the administrator wants to manually start a unit | |
938 | and the start limit interferes with that. Note that this rate-limiting is enforced after any unit condition | |
939 | checks are executed, and hence unit activations with failing conditions do not count towards this rate | |
940 | limit. This setting does not apply to slice, target, device, and scope units, since they are unit types whose | |
941 | activation may either never fail, or may succeed only a single time.</para> | |
942 | ||
943 | <para>When a unit is unloaded due to the garbage collection logic (see above) its rate limit counters are | |
944 | flushed out too. This means that configuring start rate limiting for a unit that is not referenced continously | |
945 | has no effect.</para></listitem> | |
6bf0f408 LP |
946 | </varlistentry> |
947 | ||
948 | <varlistentry> | |
949 | <term><varname>StartLimitAction=</varname></term> | |
950 | ||
951 | <listitem><para>Configure the action to take if the rate limit configured with | |
f0367da7 | 952 | <varname>StartLimitIntervalSec=</varname> and <varname>StartLimitBurst=</varname> is hit. Takes one of |
6bf0f408 LP |
953 | <option>none</option>, <option>reboot</option>, <option>reboot-force</option>, |
954 | <option>reboot-immediate</option>, <option>poweroff</option>, <option>poweroff-force</option> or | |
955 | <option>poweroff-immediate</option>. If <option>none</option> is set, hitting the rate limit will trigger no | |
956 | action besides that the start will not be permitted. <option>reboot</option> causes a reboot following the | |
957 | normal shutdown procedure (i.e. equivalent to <command>systemctl reboot</command>). | |
958 | <option>reboot-force</option> causes a forced reboot which will terminate all processes forcibly but should | |
959 | cause no dirty file systems on reboot (i.e. equivalent to <command>systemctl reboot -f</command>) and | |
960 | <option>reboot-immediate</option> causes immediate execution of the | |
961 | <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call, which | |
962 | might result in data loss. Similarly, <option>poweroff</option>, <option>poweroff-force</option>, | |
963 | <option>poweroff-immediate</option> have the effect of powering down the system with similar | |
964 | semantics. Defaults to <option>none</option>.</para></listitem> | |
965 | </varlistentry> | |
966 | ||
53c35a76 LP |
967 | <varlistentry> |
968 | <term><varname>FailureAction=</varname></term> | |
e7dfbb4e LP |
969 | <term><varname>SuccessAction=</varname></term> |
970 | <listitem><para>Configure the action to take when the unit stops and enters a failed state or inactive | |
971 | state. Takes the same values as the setting <varname>StartLimitAction=</varname> setting and executes the same | |
f7a4bd95 | 972 | actions. Both options default to <option>none</option>.</para></listitem> |
53c35a76 LP |
973 | </varlistentry> |
974 | ||
6bf0f408 LP |
975 | <varlistentry> |
976 | <term><varname>RebootArgument=</varname></term> | |
977 | <listitem><para>Configure the optional argument for the | |
978 | <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call if | |
53c35a76 | 979 | <varname>StartLimitAction=</varname> or <varname>FailureAction=</varname> is a reboot action. This |
6bf0f408 LP |
980 | works just like the optional argument to <command>systemctl reboot</command> command.</para></listitem> |
981 | </varlistentry> | |
982 | ||
798d3a52 ZJS |
983 | <varlistentry> |
984 | <term><varname>ConditionArchitecture=</varname></term> | |
985 | <term><varname>ConditionVirtualization=</varname></term> | |
986 | <term><varname>ConditionHost=</varname></term> | |
987 | <term><varname>ConditionKernelCommandLine=</varname></term> | |
5022f08a | 988 | <term><varname>ConditionKernelVersion=</varname></term> |
798d3a52 ZJS |
989 | <term><varname>ConditionSecurity=</varname></term> |
990 | <term><varname>ConditionCapability=</varname></term> | |
991 | <term><varname>ConditionACPower=</varname></term> | |
992 | <term><varname>ConditionNeedsUpdate=</varname></term> | |
993 | <term><varname>ConditionFirstBoot=</varname></term> | |
994 | <term><varname>ConditionPathExists=</varname></term> | |
995 | <term><varname>ConditionPathExistsGlob=</varname></term> | |
996 | <term><varname>ConditionPathIsDirectory=</varname></term> | |
997 | <term><varname>ConditionPathIsSymbolicLink=</varname></term> | |
998 | <term><varname>ConditionPathIsMountPoint=</varname></term> | |
999 | <term><varname>ConditionPathIsReadWrite=</varname></term> | |
1000 | <term><varname>ConditionDirectoryNotEmpty=</varname></term> | |
1001 | <term><varname>ConditionFileNotEmpty=</varname></term> | |
1002 | <term><varname>ConditionFileIsExecutable=</varname></term> | |
c465a29f FS |
1003 | <term><varname>ConditionUser=</varname></term> |
1004 | <term><varname>ConditionGroup=</varname></term> | |
e16647c3 | 1005 | <term><varname>ConditionControlGroupController=</varname></term> |
798d3a52 | 1006 | |
7ca41557 | 1007 | <!-- We do not document ConditionNull= |
b938cb90 | 1008 | here, as it is not particularly |
798d3a52 ZJS |
1009 | useful and probably just |
1010 | confusing. --> | |
1011 | ||
41448597 LP |
1012 | <listitem><para>Before starting a unit, verify that the specified condition is true. If it is not true, the |
1013 | starting of the unit will be (mostly silently) skipped, however all ordering dependencies of it are still | |
1014 | respected. A failing condition will not result in the unit being moved into a failure state. The condition is | |
1015 | checked at the time the queued start job is to be executed. Use condition expressions in order to silently skip | |
1016 | units that do not apply to the local running system, for example because the kernel or runtime environment | |
1017 | doesn't require its functionality. Use the various <varname>AssertArchitecture=</varname>, | |
1018 | <varname>AssertVirtualization=</varname>, … options for a similar mechanism that puts the unit in a failure | |
1019 | state and logs about the failed check (see below).</para> | |
798d3a52 ZJS |
1020 | |
1021 | <para><varname>ConditionArchitecture=</varname> may be used to | |
1022 | check whether the system is running on a specific | |
1023 | architecture. Takes one of | |
1024 | <varname>x86</varname>, | |
1025 | <varname>x86-64</varname>, | |
1026 | <varname>ppc</varname>, | |
1027 | <varname>ppc-le</varname>, | |
1028 | <varname>ppc64</varname>, | |
1029 | <varname>ppc64-le</varname>, | |
1030 | <varname>ia64</varname>, | |
1031 | <varname>parisc</varname>, | |
1032 | <varname>parisc64</varname>, | |
1033 | <varname>s390</varname>, | |
1034 | <varname>s390x</varname>, | |
1035 | <varname>sparc</varname>, | |
1036 | <varname>sparc64</varname>, | |
1037 | <varname>mips</varname>, | |
1038 | <varname>mips-le</varname>, | |
1039 | <varname>mips64</varname>, | |
1040 | <varname>mips64-le</varname>, | |
1041 | <varname>alpha</varname>, | |
1042 | <varname>arm</varname>, | |
1043 | <varname>arm-be</varname>, | |
1044 | <varname>arm64</varname>, | |
1045 | <varname>arm64-be</varname>, | |
1046 | <varname>sh</varname>, | |
1047 | <varname>sh64</varname>, | |
215a2db4 | 1048 | <varname>m68k</varname>, |
798d3a52 | 1049 | <varname>tilegx</varname>, |
27b09f1f AB |
1050 | <varname>cris</varname>, |
1051 | <varname>arc</varname>, | |
1052 | <varname>arc-be</varname> to test | |
798d3a52 ZJS |
1053 | against a specific architecture. The architecture is |
1054 | determined from the information returned by | |
3ba3a79d | 1055 | <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry> |
798d3a52 ZJS |
1056 | and is thus subject to |
1057 | <citerefentry><refentrytitle>personality</refentrytitle><manvolnum>2</manvolnum></citerefentry>. | |
1058 | Note that a <varname>Personality=</varname> setting in the | |
1059 | same unit file has no effect on this condition. A special | |
1060 | architecture name <varname>native</varname> is mapped to the | |
1061 | architecture the system manager itself is compiled for. The | |
1062 | test may be negated by prepending an exclamation mark.</para> | |
1063 | ||
1064 | <para><varname>ConditionVirtualization=</varname> may be used | |
1065 | to check whether the system is executed in a virtualized | |
1066 | environment and optionally test whether it is a specific | |
1067 | implementation. Takes either boolean value to check if being | |
1068 | executed in any virtualized environment, or one of | |
1069 | <varname>vm</varname> and | |
1070 | <varname>container</varname> to test against a generic type of | |
1071 | virtualization solution, or one of | |
1072 | <varname>qemu</varname>, | |
1073 | <varname>kvm</varname>, | |
1074 | <varname>zvm</varname>, | |
1075 | <varname>vmware</varname>, | |
1076 | <varname>microsoft</varname>, | |
1077 | <varname>oracle</varname>, | |
1078 | <varname>xen</varname>, | |
1079 | <varname>bochs</varname>, | |
1080 | <varname>uml</varname>, | |
9bfaf6ea | 1081 | <varname>bhyve</varname>, |
1fdf07f5 | 1082 | <varname>qnx</varname>, |
798d3a52 ZJS |
1083 | <varname>openvz</varname>, |
1084 | <varname>lxc</varname>, | |
1085 | <varname>lxc-libvirt</varname>, | |
1086 | <varname>systemd-nspawn</varname>, | |
9fb16425 ILG |
1087 | <varname>docker</varname>, |
1088 | <varname>rkt</varname> to test | |
299a34c1 ZJS |
1089 | against a specific implementation, or |
1090 | <varname>private-users</varname> to check whether we are running in a user namespace. See | |
798d3a52 ZJS |
1091 | <citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
1092 | for a full list of known virtualization technologies and their | |
1093 | identifiers. If multiple virtualization technologies are | |
1094 | nested, only the innermost is considered. The test may be | |
1095 | negated by prepending an exclamation mark.</para> | |
1096 | ||
1097 | <para><varname>ConditionHost=</varname> may be used to match | |
1098 | against the hostname or machine ID of the host. This either | |
1099 | takes a hostname string (optionally with shell style globs) | |
1100 | which is tested against the locally set hostname as returned | |
1101 | by | |
1102 | <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>, | |
1103 | or a machine ID formatted as string (see | |
1104 | <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>). | |
1105 | The test may be negated by prepending an exclamation | |
1106 | mark.</para> | |
1107 | ||
1108 | <para><varname>ConditionKernelCommandLine=</varname> may be | |
1109 | used to check whether a specific kernel command line option is | |
1110 | set (or if prefixed with the exclamation mark unset). The | |
1111 | argument must either be a single word, or an assignment (i.e. | |
1112 | two words, separated <literal>=</literal>). In the former case | |
1113 | the kernel command line is searched for the word appearing as | |
1114 | is, or as left hand side of an assignment. In the latter case, | |
1115 | the exact assignment is looked for with right and left hand | |
1116 | side matching.</para> | |
1117 | ||
5022f08a LP |
1118 | <para><varname>ConditionKernelVersion=</varname> may be used to check whether the kernel version (as reported |
1119 | by <command>uname -r</command>) matches a certain expression (or if prefixed with the exclamation mark does not | |
68c58c67 LP |
1120 | match it). The argument must be a single string. If the string starts with one of <literal><</literal>, |
1121 | <literal><=</literal>, <literal>=</literal>, <literal>>=</literal>, <literal>></literal> a relative | |
1122 | version comparison is done, otherwise the specified string is matched with shell-style globs.</para> | |
5022f08a | 1123 | |
871c6d54 ZJS |
1124 | <para>Note that using the kernel version string is an unreliable way to determine which features are supported |
1125 | by a kernel, because of the widespread practice of backporting drivers, features, and fixes from newer upstream | |
1126 | kernels into older versions provided by distributions. Hence, this check is inherently unportable and should | |
1127 | not be used for units which may be used on different distributions.</para> | |
1128 | ||
798d3a52 ZJS |
1129 | <para><varname>ConditionSecurity=</varname> may be used to |
1130 | check whether the given security module is enabled on the | |
b8e1d4d1 | 1131 | system. Currently, the recognized values are |
798d3a52 ZJS |
1132 | <varname>selinux</varname>, |
1133 | <varname>apparmor</varname>, | |
ed440f6b | 1134 | <varname>tomoyo</varname>, |
798d3a52 ZJS |
1135 | <varname>ima</varname>, |
1136 | <varname>smack</varname> and | |
1137 | <varname>audit</varname>. The test may be negated by | |
1138 | prepending an exclamation mark.</para> | |
1139 | ||
1140 | <para><varname>ConditionCapability=</varname> may be used to | |
1141 | check whether the given capability exists in the capability | |
1142 | bounding set of the service manager (i.e. this does not check | |
1143 | whether capability is actually available in the permitted or | |
1144 | effective sets, see | |
1145 | <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
1146 | for details). Pass a capability name such as | |
1147 | <literal>CAP_MKNOD</literal>, possibly prefixed with an | |
1148 | exclamation mark to negate the check.</para> | |
1149 | ||
1150 | <para><varname>ConditionACPower=</varname> may be used to | |
1151 | check whether the system has AC power, or is exclusively | |
1152 | battery powered at the time of activation of the unit. This | |
1153 | takes a boolean argument. If set to <varname>true</varname>, | |
1154 | the condition will hold only if at least one AC connector of | |
1155 | the system is connected to a power source, or if no AC | |
1156 | connectors are known. Conversely, if set to | |
1157 | <varname>false</varname>, the condition will hold only if | |
1158 | there is at least one AC connector known and all AC connectors | |
1159 | are disconnected from a power source.</para> | |
1160 | ||
1161 | <para><varname>ConditionNeedsUpdate=</varname> takes one of | |
1162 | <filename>/var</filename> or <filename>/etc</filename> as | |
1163 | argument, possibly prefixed with a <literal>!</literal> (for | |
1164 | inverting the condition). This condition may be used to | |
1165 | conditionalize units on whether the specified directory | |
1166 | requires an update because <filename>/usr</filename>'s | |
1167 | modification time is newer than the stamp file | |
1168 | <filename>.updated</filename> in the specified directory. This | |
1169 | is useful to implement offline updates of the vendor operating | |
1170 | system resources in <filename>/usr</filename> that require | |
1171 | updating of <filename>/etc</filename> or | |
1172 | <filename>/var</filename> on the next following boot. Units | |
1173 | making use of this condition should order themselves before | |
1174 | <citerefentry><refentrytitle>systemd-update-done.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, | |
7f3fdb7f | 1175 | to make sure they run before the stamp file's modification |
798d3a52 ZJS |
1176 | time gets reset indicating a completed update.</para> |
1177 | ||
23254af1 LP |
1178 | <para><varname>ConditionFirstBoot=</varname> takes a boolean argument. This condition may be used to |
1179 | conditionalize units on whether the system is booting up with an unpopulated <filename>/etc</filename> | |
1180 | directory (specifically: an <filename>/etc</filename> with no <filename>/etc/machine-id</filename>). This may | |
1181 | be used to populate <filename>/etc</filename> on the first boot after factory reset, or when a new system | |
1182 | instance boots up for the first time.</para> | |
798d3a52 ZJS |
1183 | |
1184 | <para>With <varname>ConditionPathExists=</varname> a file | |
1185 | existence condition is checked before a unit is started. If | |
1186 | the specified absolute path name does not exist, the condition | |
1187 | will fail. If the absolute path name passed to | |
1188 | <varname>ConditionPathExists=</varname> is prefixed with an | |
1189 | exclamation mark (<literal>!</literal>), the test is negated, | |
1190 | and the unit is only started if the path does not | |
1191 | exist.</para> | |
1192 | ||
1193 | <para><varname>ConditionPathExistsGlob=</varname> is similar | |
1194 | to <varname>ConditionPathExists=</varname>, but checks for the | |
1195 | existence of at least one file or directory matching the | |
1196 | specified globbing pattern.</para> | |
1197 | ||
1198 | <para><varname>ConditionPathIsDirectory=</varname> is similar | |
1199 | to <varname>ConditionPathExists=</varname> but verifies | |
1200 | whether a certain path exists and is a directory.</para> | |
1201 | ||
1202 | <para><varname>ConditionPathIsSymbolicLink=</varname> is | |
1203 | similar to <varname>ConditionPathExists=</varname> but | |
1204 | verifies whether a certain path exists and is a symbolic | |
1205 | link.</para> | |
1206 | ||
1207 | <para><varname>ConditionPathIsMountPoint=</varname> is similar | |
1208 | to <varname>ConditionPathExists=</varname> but verifies | |
1209 | whether a certain path exists and is a mount point.</para> | |
1210 | ||
1211 | <para><varname>ConditionPathIsReadWrite=</varname> is similar | |
1212 | to <varname>ConditionPathExists=</varname> but verifies | |
1213 | whether the underlying file system is readable and writable | |
1214 | (i.e. not mounted read-only).</para> | |
1215 | ||
1216 | <para><varname>ConditionDirectoryNotEmpty=</varname> is | |
1217 | similar to <varname>ConditionPathExists=</varname> but | |
1218 | verifies whether a certain path exists and is a non-empty | |
1219 | directory.</para> | |
1220 | ||
1221 | <para><varname>ConditionFileNotEmpty=</varname> is similar to | |
1222 | <varname>ConditionPathExists=</varname> but verifies whether a | |
1223 | certain path exists and refers to a regular file with a | |
1224 | non-zero size.</para> | |
1225 | ||
1226 | <para><varname>ConditionFileIsExecutable=</varname> is similar | |
1227 | to <varname>ConditionPathExists=</varname> but verifies | |
1228 | whether a certain path exists, is a regular file and marked | |
1229 | executable.</para> | |
1230 | ||
c465a29f | 1231 | <para><varname>ConditionUser=</varname> takes a numeric |
534bab66 FS |
1232 | <literal>UID</literal>, a UNIX user name, or the special value |
1233 | <literal>@system</literal>. This condition may be used to check | |
1234 | whether the service manager is running as the given user. The | |
1235 | special value <literal>@system</literal> can be used to check | |
1236 | if the user id is within the system user range. This option is not | |
c465a29f FS |
1237 | useful for system services, as the system manager exclusively |
1238 | runs as the root user, and thus the test result is constant.</para> | |
1239 | ||
1240 | <para><varname>ConditionGroup=</varname> is similar | |
1241 | to <varname>ConditionUser=</varname> but verifies that the | |
1242 | service manager's real or effective group, or any of its | |
534bab66 FS |
1243 | auxiliary groups match the specified group or GID. This setting |
1244 | does not have a special value <literal>@system</literal>.</para> | |
c465a29f | 1245 | |
e16647c3 CD |
1246 | <para><varname>ConditionControlGroupController=</varname> takes a |
1247 | cgroup controller name (eg. <option>cpu</option>), verifying that it is | |
1248 | available for use on the system. For example, a particular controller | |
1249 | may not be available if it was disabled on the kernel command line with | |
1250 | <literal>cgroup_disable=</literal><replaceable>controller</replaceable>. | |
1251 | Multiple controllers may be passed with a space separating them; in | |
1252 | this case the condition will only pass if all listed controllers are | |
1253 | available for use. Controllers unknown to systemd are ignored. Valid | |
1254 | controllers are <option>cpu</option>, <option>cpuacct</option>, | |
1255 | <option>io</option>, <option>blkio</option>, <option>memory</option>, | |
1256 | <option>devices</option>, and <option>pids</option>.</para> | |
1257 | ||
798d3a52 ZJS |
1258 | <para>If multiple conditions are specified, the unit will be |
1259 | executed if all of them apply (i.e. a logical AND is applied). | |
1260 | Condition checks can be prefixed with a pipe symbol (|) in | |
1261 | which case a condition becomes a triggering condition. If at | |
1262 | least one triggering condition is defined for a unit, then the | |
1263 | unit will be executed if at least one of the triggering | |
1264 | conditions apply and all of the non-triggering conditions. If | |
1265 | you prefix an argument with the pipe symbol and an exclamation | |
1266 | mark, the pipe symbol must be passed first, the exclamation | |
1267 | second. Except for | |
1268 | <varname>ConditionPathIsSymbolicLink=</varname>, all path | |
1269 | checks follow symlinks. If any of these options is assigned | |
1270 | the empty string, the list of conditions is reset completely, | |
1271 | all previous condition settings (of any kind) will have no | |
1272 | effect.</para></listitem> | |
1273 | </varlistentry> | |
1274 | ||
1275 | <varlistentry> | |
1276 | <term><varname>AssertArchitecture=</varname></term> | |
1277 | <term><varname>AssertVirtualization=</varname></term> | |
1278 | <term><varname>AssertHost=</varname></term> | |
1279 | <term><varname>AssertKernelCommandLine=</varname></term> | |
5022f08a | 1280 | <term><varname>AssertKernelVersion=</varname></term> |
798d3a52 ZJS |
1281 | <term><varname>AssertSecurity=</varname></term> |
1282 | <term><varname>AssertCapability=</varname></term> | |
1283 | <term><varname>AssertACPower=</varname></term> | |
1284 | <term><varname>AssertNeedsUpdate=</varname></term> | |
1285 | <term><varname>AssertFirstBoot=</varname></term> | |
1286 | <term><varname>AssertPathExists=</varname></term> | |
1287 | <term><varname>AssertPathExistsGlob=</varname></term> | |
1288 | <term><varname>AssertPathIsDirectory=</varname></term> | |
1289 | <term><varname>AssertPathIsSymbolicLink=</varname></term> | |
1290 | <term><varname>AssertPathIsMountPoint=</varname></term> | |
1291 | <term><varname>AssertPathIsReadWrite=</varname></term> | |
1292 | <term><varname>AssertDirectoryNotEmpty=</varname></term> | |
1293 | <term><varname>AssertFileNotEmpty=</varname></term> | |
1294 | <term><varname>AssertFileIsExecutable=</varname></term> | |
c465a29f FS |
1295 | <term><varname>AssertUser=</varname></term> |
1296 | <term><varname>AssertGroup=</varname></term> | |
e16647c3 | 1297 | <term><varname>AssertControlGroupController=</varname></term> |
798d3a52 | 1298 | |
41448597 LP |
1299 | <listitem><para>Similar to the <varname>ConditionArchitecture=</varname>, |
1300 | <varname>ConditionVirtualization=</varname>, …, condition settings described above, these settings add | |
1301 | assertion checks to the start-up of the unit. However, unlike the conditions settings, any assertion setting | |
da25e029 ZJS |
1302 | that is not met results in failure of the start job (which means this is logged loudly). Use assertion |
1303 | expressions for units that cannot operate when specific requirements are not met, and when this is something | |
1304 | the administrator or user should look into.</para></listitem> | |
798d3a52 ZJS |
1305 | </varlistentry> |
1306 | ||
1307 | <varlistentry> | |
1308 | <term><varname>SourcePath=</varname></term> | |
1309 | <listitem><para>A path to a configuration file this unit has | |
1310 | been generated from. This is primarily useful for | |
1311 | implementation of generator tools that convert configuration | |
1312 | from an external configuration file format into native unit | |
1313 | files. This functionality should not be used in normal | |
1314 | units.</para></listitem> | |
1315 | </varlistentry> | |
1316 | </variablelist> | |
2bf92506 ZJS |
1317 | </refsect1> |
1318 | ||
1319 | <refsect1> | |
1320 | <title>Mapping of unit properties to their inverses</title> | |
1321 | ||
1322 | <para>Unit settings that create a relationship with a second unit usually show up | |
1323 | in properties of both units, for example in <command>systemctl show</command> | |
1324 | output. In some cases the name of the property is the same as the name of the | |
1325 | configuration setting, but not always. This table lists the pairs of properties | |
1326 | that are shown on two units which are connected through some dependency, and shows | |
1327 | which property on "source" unit corresponds to which property on the "target" unit. | |
1328 | </para> | |
1329 | ||
1330 | <table> | |
1331 | <title> | |
1332 | "Forward" and "reverse" unit properties | |
1333 | </title> | |
1334 | ||
1335 | <tgroup cols='2'> | |
1336 | <colspec colname='forward' /> | |
1337 | <colspec colname='reverse' /> | |
1338 | <colspec colname='notes' /> | |
1339 | <thead> | |
1340 | <row> | |
1341 | <entry>"Forward" property</entry> | |
1342 | <entry>"Reverse" property</entry> | |
1343 | <entry>Where used</entry> | |
1344 | </row> | |
1345 | </thead> | |
1346 | <tbody> | |
1347 | <row> | |
1348 | <entry><varname>Before=</varname></entry> | |
1349 | <entry><varname>After=</varname></entry> | |
1350 | <entry morerows='1' valign='middle'>Both are unit file options</entry> | |
1351 | </row> | |
1352 | <row> | |
1353 | <entry><varname>After=</varname></entry> | |
1354 | <entry><varname>Before=</varname></entry> | |
1355 | </row> | |
1356 | <row> | |
1357 | <entry><varname>Requires=</varname></entry> | |
1358 | <entry><varname>RequiredBy=</varname></entry> | |
1359 | <entry>A unit file option; an option in the [Install] section</entry> | |
1360 | </row> | |
1361 | <row> | |
1362 | <entry><varname>Wants=</varname></entry> | |
1363 | <entry><varname>WantedBy=</varname></entry> | |
1364 | <entry>A unit file option; an option in the [Install] section</entry> | |
1365 | </row> | |
1366 | <row> | |
1367 | <entry><varname>PartOf=</varname></entry> | |
1368 | <entry><varname>ConsistsOf=</varname></entry> | |
1369 | <entry>A unit file option; an automatic property</entry> | |
1370 | </row> | |
1371 | <row> | |
1372 | <entry><varname>BindsTo=</varname></entry> | |
1373 | <entry><varname>BoundBy=</varname></entry> | |
1374 | <entry>A unit file option; an automatic property</entry> | |
1375 | </row> | |
1376 | <row> | |
1377 | <entry><varname>Requisite=</varname></entry> | |
1378 | <entry><varname>RequisiteOf=</varname></entry> | |
1379 | <entry>A unit file option; an automatic property</entry> | |
1380 | </row> | |
1381 | <row> | |
1382 | <entry><varname>Triggers=</varname></entry> | |
1383 | <entry><varname>TriggeredBy=</varname></entry> | |
1384 | <entry>Automatic properties, see notes below</entry> | |
1385 | </row> | |
1386 | <row> | |
1387 | <entry><varname>Conflicts=</varname></entry> | |
1388 | <entry><varname>ConflictedBy=</varname></entry> | |
1389 | <entry>A unit file option; an automatic property</entry> | |
1390 | </row> | |
1391 | <row> | |
1392 | <entry><varname>PropagatesReloadTo=</varname></entry> | |
1393 | <entry><varname>ReloadPropagatedFrom=</varname></entry> | |
1394 | <entry morerows='1' valign='middle'>Both are unit file options</entry> | |
1395 | </row> | |
1396 | <row> | |
1397 | <entry><varname>ReloadPropagatedFrom=</varname></entry> | |
1398 | <entry><varname>PropagatesReloadTo=</varname></entry> | |
1399 | </row> | |
1400 | </tbody> | |
1401 | </tgroup> | |
1402 | </table> | |
798d3a52 | 1403 | |
2bf92506 ZJS |
1404 | <para>Note: <varname>WantedBy=</varname> and <varname>RequiredBy=</varname> are |
1405 | used in the [Install] section to create symlinks in <filename>.wants/</filename> | |
1406 | and <filename>.requires/</filename> directories. They cannot be used directly as a | |
1407 | unit configuration setting.</para> | |
1408 | ||
1409 | <para>Note: <varname>ConsistsOf=</varname>, <varname>BoundBy=</varname>, | |
1410 | <varname>RequisiteOf=</varname>, <varname>ConflictedBy=</varname> are created | |
1411 | implicitly along with their reverse and cannot be specified directly.</para> | |
1412 | ||
1413 | <para>Note: <varname>Triggers=</varname> is created implicitly between a socket, | |
1414 | path unit, or an automount unit, and the unit they activate. By default a unit | |
1415 | with the same name is triggered, but this can be overriden using | |
1416 | <varname>Sockets=</varname>, <varname>Service=</varname>, and <varname>Unit=</varname> | |
1417 | settings. See | |
1418 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1419 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1420 | <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1421 | and | |
1422 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
1423 | for details. <varname>TriggersBy=</varname> is created implicitly on the | |
1424 | triggered unit.</para> | |
798d3a52 ZJS |
1425 | </refsect1> |
1426 | ||
1427 | <refsect1> | |
1428 | <title>[Install] Section Options</title> | |
1429 | ||
be73bb48 LP |
1430 | <para>Unit files may include an <literal>[Install]</literal> section, which carries installation information for |
1431 | the unit. This section is not interpreted by | |
1432 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> during runtime; it is | |
1433 | used by the <command>enable</command> and <command>disable</command> commands of the | |
1434 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool during | |
caa45f5b | 1435 | installation of a unit.</para> |
798d3a52 ZJS |
1436 | |
1437 | <variablelist class='unit-directives'> | |
1438 | <varlistentry> | |
1439 | <term><varname>Alias=</varname></term> | |
1440 | ||
f4bf8d2f | 1441 | <listitem><para>A space-separated list of additional names this unit shall be installed under. The names listed |
1245e413 | 1442 | here must have the same suffix (i.e. type) as the unit filename. This option may be specified more than once, |
f4bf8d2f LP |
1443 | in which case all listed names are used. At installation time, <command>systemctl enable</command> will create |
1444 | symlinks from these names to the unit filename. Note that not all unit types support such alias names, and this | |
1445 | setting is not supported for them. Specifically, mount, slice, swap, and automount units do not support | |
1446 | aliasing.</para></listitem> | |
798d3a52 ZJS |
1447 | </varlistentry> |
1448 | ||
1449 | <varlistentry> | |
1450 | <term><varname>WantedBy=</varname></term> | |
1451 | <term><varname>RequiredBy=</varname></term> | |
1452 | ||
1453 | <listitem><para>This option may be used more than once, or a | |
1454 | space-separated list of unit names may be given. A symbolic | |
1455 | link is created in the <filename>.wants/</filename> or | |
1456 | <filename>.requires/</filename> directory of each of the | |
1457 | listed units when this unit is installed by <command>systemctl | |
1458 | enable</command>. This has the effect that a dependency of | |
1459 | type <varname>Wants=</varname> or <varname>Requires=</varname> | |
1460 | is added from the listed unit to the current unit. The primary | |
1461 | result is that the current unit will be started when the | |
1462 | listed unit is started. See the description of | |
1463 | <varname>Wants=</varname> and <varname>Requires=</varname> in | |
1464 | the [Unit] section for details.</para> | |
1465 | ||
1466 | <para><command>WantedBy=foo.service</command> in a service | |
1467 | <filename>bar.service</filename> is mostly equivalent to | |
1468 | <command>Alias=foo.service.wants/bar.service</command> in the | |
1469 | same file. In case of template units, <command>systemctl | |
1470 | enable</command> must be called with an instance name, and | |
1471 | this instance will be added to the | |
1472 | <filename>.wants/</filename> or | |
1473 | <filename>.requires/</filename> list of the listed unit. E.g. | |
1474 | <command>WantedBy=getty.target</command> in a service | |
1475 | <filename>getty@.service</filename> will result in | |
1476 | <command>systemctl enable getty@tty2.service</command> | |
1477 | creating a | |
1478 | <filename>getty.target.wants/getty@tty2.service</filename> | |
1479 | link to <filename>getty@.service</filename>. | |
1480 | </para></listitem> | |
1481 | </varlistentry> | |
1482 | ||
1483 | <varlistentry> | |
1484 | <term><varname>Also=</varname></term> | |
1485 | ||
1486 | <listitem><para>Additional units to install/deinstall when | |
1487 | this unit is installed/deinstalled. If the user requests | |
1488 | installation/deinstallation of a unit with this option | |
1489 | configured, <command>systemctl enable</command> and | |
1490 | <command>systemctl disable</command> will automatically | |
1491 | install/uninstall units listed in this option as well.</para> | |
1492 | ||
1493 | <para>This option may be used more than once, or a | |
1494 | space-separated list of unit names may be | |
1495 | given.</para></listitem> | |
1496 | </varlistentry> | |
1497 | ||
1498 | <varlistentry> | |
1499 | <term><varname>DefaultInstance=</varname></term> | |
1500 | ||
1501 | <listitem><para>In template unit files, this specifies for | |
1502 | which instance the unit shall be enabled if the template is | |
1503 | enabled without any explicitly set instance. This option has | |
1504 | no effect in non-template unit files. The specified string | |
1505 | must be usable as instance identifier.</para></listitem> | |
1506 | </varlistentry> | |
1507 | </variablelist> | |
1508 | ||
1509 | <para>The following specifiers are interpreted in the Install | |
1510 | section: %n, %N, %p, %i, %U, %u, %m, %H, %b, %v. For their meaning | |
1511 | see the next section. | |
1512 | </para> | |
1513 | </refsect1> | |
1514 | ||
1515 | <refsect1> | |
1516 | <title>Specifiers</title> | |
1517 | ||
1518 | <para>Many settings resolve specifiers which may be used to write | |
1519 | generic unit files referring to runtime or unit parameters that | |
751223fe ZJS |
1520 | are replaced when the unit files are loaded. Specifiers must be known |
1521 | and resolvable for the setting to be valid. The following | |
798d3a52 ZJS |
1522 | specifiers are understood:</para> |
1523 | ||
1524 | <table> | |
1525 | <title>Specifiers available in unit files</title> | |
1526 | <tgroup cols='3' align='left' colsep='1' rowsep='1'> | |
1527 | <colspec colname="spec" /> | |
1528 | <colspec colname="mean" /> | |
1529 | <colspec colname="detail" /> | |
1530 | <thead> | |
1531 | <row> | |
5a15caf4 ZJS |
1532 | <entry>Specifier</entry> |
1533 | <entry>Meaning</entry> | |
1534 | <entry>Details</entry> | |
798d3a52 ZJS |
1535 | </row> |
1536 | </thead> | |
1537 | <tbody> | |
1538 | <row> | |
5a15caf4 ZJS |
1539 | <entry><literal>%n</literal></entry> |
1540 | <entry>Full unit name</entry> | |
1541 | <entry></entry> | |
798d3a52 ZJS |
1542 | </row> |
1543 | <row> | |
5a15caf4 ZJS |
1544 | <entry><literal>%N</literal></entry> |
1545 | <entry>Unescaped full unit name</entry> | |
1546 | <entry>Same as <literal>%n</literal>, but with escaping undone. This undoes the escaping used when generating unit names from arbitrary strings (see above). </entry> | |
798d3a52 ZJS |
1547 | </row> |
1548 | <row> | |
5a15caf4 ZJS |
1549 | <entry><literal>%p</literal></entry> |
1550 | <entry>Prefix name</entry> | |
1551 | <entry>For instantiated units, this refers to the string before the <literal>@</literal> character of the unit name. For non-instantiated units, this refers to the name of the unit with the type suffix removed.</entry> | |
798d3a52 ZJS |
1552 | </row> |
1553 | <row> | |
5a15caf4 ZJS |
1554 | <entry><literal>%P</literal></entry> |
1555 | <entry>Unescaped prefix name</entry> | |
1556 | <entry>Same as <literal>%p</literal>, but with escaping undone</entry> | |
798d3a52 ZJS |
1557 | </row> |
1558 | <row> | |
5a15caf4 ZJS |
1559 | <entry><literal>%i</literal></entry> |
1560 | <entry>Instance name</entry> | |
1561 | <entry>For instantiated units: this is the string between the <literal>@</literal> character and the suffix of the unit name.</entry> | |
798d3a52 ZJS |
1562 | </row> |
1563 | <row> | |
5a15caf4 ZJS |
1564 | <entry><literal>%I</literal></entry> |
1565 | <entry>Unescaped instance name</entry> | |
1566 | <entry>Same as <literal>%i</literal>, but with escaping undone</entry> | |
798d3a52 ZJS |
1567 | </row> |
1568 | <row> | |
5a15caf4 ZJS |
1569 | <entry><literal>%f</literal></entry> |
1570 | <entry>Unescaped filename</entry> | |
1571 | <entry>This is either the unescaped instance name (if applicable) with <filename>/</filename> prepended (if applicable), or the unescaped prefix name prepended with <filename>/</filename>. This implements unescaping according to the rules for escaping absolute file system paths discussed above.</entry> | |
798d3a52 ZJS |
1572 | </row> |
1573 | <row> | |
5a15caf4 ZJS |
1574 | <entry><literal>%t</literal></entry> |
1575 | <entry>Runtime directory root</entry> | |
1576 | <entry>This is either <filename>/run</filename> (for the system manager) or the path <literal>$XDG_RUNTIME_DIR</literal> resolves to (for user managers).</entry> | |
798d3a52 ZJS |
1577 | </row> |
1578 | <row> | |
5a15caf4 ZJS |
1579 | <entry><literal>%S</literal></entry> |
1580 | <entry>State directory root</entry> | |
1581 | <entry>This is either <filename>/var/lib</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to (for user managers).</entry> | |
14068e17 LP |
1582 | </row> |
1583 | <row> | |
5a15caf4 ZJS |
1584 | <entry><literal>%C</literal></entry> |
1585 | <entry>Cache directory root</entry> | |
1586 | <entry>This is either <filename>/var/cache</filename> (for the system manager) or the path <literal>$XDG_CACHE_HOME</literal> resolves to (for user managers).</entry> | |
14068e17 LP |
1587 | </row> |
1588 | <row> | |
5a15caf4 ZJS |
1589 | <entry><literal>%L</literal></entry> |
1590 | <entry>Log directory root</entry> | |
1591 | <entry>This is either <filename>/var/log</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to with <filename noindex='true'>/log</filename> appended (for user managers).</entry> | |
14068e17 LP |
1592 | </row> |
1593 | <row> | |
5a15caf4 ZJS |
1594 | <entry><literal>%u</literal></entry> |
1595 | <entry>User name</entry> | |
1596 | <entry>This is the name of the user running the service manager instance. In case of the system manager this resolves to <literal>root</literal>.</entry> | |
798d3a52 ZJS |
1597 | </row> |
1598 | <row> | |
5a15caf4 ZJS |
1599 | <entry><literal>%U</literal></entry> |
1600 | <entry>User UID</entry> | |
1601 | <entry>This is the numeric UID of the user running the service manager instance. In case of the system manager this resolves to <literal>0</literal>.</entry> | |
798d3a52 ZJS |
1602 | </row> |
1603 | <row> | |
5a15caf4 ZJS |
1604 | <entry><literal>%h</literal></entry> |
1605 | <entry>User home directory</entry> | |
1606 | <entry>This is the home directory of the user running the service manager instance. In case of the system manager this resolves to <literal>/root</literal>.</entry> | |
798d3a52 ZJS |
1607 | </row> |
1608 | <row> | |
5a15caf4 ZJS |
1609 | <entry><literal>%s</literal></entry> |
1610 | <entry>User shell</entry> | |
1611 | <entry>This is the shell of the user running the service manager instance. In case of the system manager this resolves to <literal>/bin/sh</literal>.</entry> | |
798d3a52 ZJS |
1612 | </row> |
1613 | <row> | |
5a15caf4 ZJS |
1614 | <entry><literal>%m</literal></entry> |
1615 | <entry>Machine ID</entry> | |
1616 | <entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry> | |
798d3a52 ZJS |
1617 | </row> |
1618 | <row> | |
5a15caf4 ZJS |
1619 | <entry><literal>%b</literal></entry> |
1620 | <entry>Boot ID</entry> | |
1621 | <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry> | |
798d3a52 ZJS |
1622 | </row> |
1623 | <row> | |
5a15caf4 ZJS |
1624 | <entry><literal>%H</literal></entry> |
1625 | <entry>Host name</entry> | |
1626 | <entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry> | |
798d3a52 ZJS |
1627 | </row> |
1628 | <row> | |
5a15caf4 ZJS |
1629 | <entry><literal>%v</literal></entry> |
1630 | <entry>Kernel release</entry> | |
1631 | <entry>Identical to <command>uname -r</command> output</entry> | |
798d3a52 ZJS |
1632 | </row> |
1633 | <row> | |
5a15caf4 ZJS |
1634 | <entry><literal>%%</literal></entry> |
1635 | <entry>Single percent sign</entry> | |
1636 | <entry>Use <literal>%%</literal> in place of <literal>%</literal> to specify a single percent sign.</entry> | |
798d3a52 ZJS |
1637 | </row> |
1638 | </tbody> | |
1639 | </tgroup> | |
1640 | </table> | |
798d3a52 ZJS |
1641 | </refsect1> |
1642 | ||
1643 | <refsect1> | |
1644 | <title>Examples</title> | |
1645 | ||
1646 | <example> | |
1647 | <title>Allowing units to be enabled</title> | |
1648 | ||
1649 | <para>The following snippet (highlighted) allows a unit (e.g. | |
1650 | <filename>foo.service</filename>) to be enabled via | |
1651 | <command>systemctl enable</command>:</para> | |
1652 | ||
1653 | <programlisting>[Unit] | |
92b1e225 CS |
1654 | Description=Foo |
1655 | ||
1656 | [Service] | |
1657 | ExecStart=/usr/sbin/foo-daemon | |
1658 | ||
1659 | <emphasis>[Install]</emphasis> | |
1660 | <emphasis>WantedBy=multi-user.target</emphasis></programlisting> | |
1661 | ||
798d3a52 ZJS |
1662 | <para>After running <command>systemctl enable</command>, a |
1663 | symlink | |
12b42c76 | 1664 | <filename>/etc/systemd/system/multi-user.target.wants/foo.service</filename> |
798d3a52 ZJS |
1665 | linking to the actual unit will be created. It tells systemd to |
1666 | pull in the unit when starting | |
1667 | <filename>multi-user.target</filename>. The inverse | |
1668 | <command>systemctl disable</command> will remove that symlink | |
1669 | again.</para> | |
1670 | </example> | |
1671 | ||
1672 | <example> | |
1673 | <title>Overriding vendor settings</title> | |
1674 | ||
1675 | <para>There are two methods of overriding vendor settings in | |
1676 | unit files: copying the unit file from | |
12b42c76 TG |
1677 | <filename>/usr/lib/systemd/system</filename> to |
1678 | <filename>/etc/systemd/system</filename> and modifying the | |
798d3a52 ZJS |
1679 | chosen settings. Alternatively, one can create a directory named |
1680 | <filename><replaceable>unit</replaceable>.d/</filename> within | |
12b42c76 | 1681 | <filename>/etc/systemd/system</filename> and place a drop-in |
798d3a52 ZJS |
1682 | file <filename><replaceable>name</replaceable>.conf</filename> |
1683 | there that only changes the specific settings one is interested | |
1684 | in. Note that multiple such drop-in files are read if | |
8331eaab | 1685 | present, processed in lexicographic order of their filename.</para> |
798d3a52 ZJS |
1686 | |
1687 | <para>The advantage of the first method is that one easily | |
1688 | overrides the complete unit, the vendor unit is not parsed at | |
1689 | all anymore. It has the disadvantage that improvements to the | |
1690 | unit file by the vendor are not automatically incorporated on | |
1691 | updates.</para> | |
1692 | ||
1693 | <para>The advantage of the second method is that one only | |
1694 | overrides the settings one specifically wants, where updates to | |
1695 | the unit by the vendor automatically apply. This has the | |
1696 | disadvantage that some future updates by the vendor might be | |
1697 | incompatible with the local changes.</para> | |
1698 | ||
798d3a52 ZJS |
1699 | <para>This also applies for user instances of systemd, but with |
1700 | different locations for the unit files. See the section on unit | |
1701 | load paths for further details.</para> | |
1702 | ||
1703 | <para>Suppose there is a vendor-supplied unit | |
12b42c76 | 1704 | <filename>/usr/lib/systemd/system/httpd.service</filename> with |
798d3a52 ZJS |
1705 | the following contents:</para> |
1706 | ||
1707 | <programlisting>[Unit] | |
92b1e225 CS |
1708 | Description=Some HTTP server |
1709 | After=remote-fs.target sqldb.service | |
1710 | Requires=sqldb.service | |
1711 | AssertPathExists=/srv/webserver | |
1712 | ||
1713 | [Service] | |
1714 | Type=notify | |
1715 | ExecStart=/usr/sbin/some-fancy-httpd-server | |
1716 | Nice=5 | |
1717 | ||
1718 | [Install] | |
1719 | WantedBy=multi-user.target</programlisting> | |
1720 | ||
798d3a52 ZJS |
1721 | <para>Now one wants to change some settings as an administrator: |
1722 | firstly, in the local setup, <filename>/srv/webserver</filename> | |
e2acdb6b | 1723 | might not exist, because the HTTP server is configured to use |
798d3a52 ZJS |
1724 | <filename>/srv/www</filename> instead. Secondly, the local |
1725 | configuration makes the HTTP server also depend on a memory | |
1726 | cache service, <filename>memcached.service</filename>, that | |
1727 | should be pulled in (<varname>Requires=</varname>) and also be | |
1728 | ordered appropriately (<varname>After=</varname>). Thirdly, in | |
1729 | order to harden the service a bit more, the administrator would | |
1730 | like to set the <varname>PrivateTmp=</varname> setting (see | |
912f003f | 1731 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
798d3a52 ZJS |
1732 | for details). And lastly, the administrator would like to reset |
1733 | the niceness of the service to its default value of 0.</para> | |
1734 | ||
1735 | <para>The first possibility is to copy the unit file to | |
12b42c76 | 1736 | <filename>/etc/systemd/system/httpd.service</filename> and |
798d3a52 ZJS |
1737 | change the chosen settings:</para> |
1738 | ||
1739 | <programlisting>[Unit] | |
92b1e225 CS |
1740 | Description=Some HTTP server |
1741 | After=remote-fs.target sqldb.service <emphasis>memcached.service</emphasis> | |
1742 | Requires=sqldb.service <emphasis>memcached.service</emphasis> | |
1743 | AssertPathExists=<emphasis>/srv/www</emphasis> | |
1744 | ||
1745 | [Service] | |
1746 | Type=notify | |
1747 | ExecStart=/usr/sbin/some-fancy-httpd-server | |
1748 | <emphasis>Nice=0</emphasis> | |
1749 | <emphasis>PrivateTmp=yes</emphasis> | |
1750 | ||
1751 | [Install] | |
1752 | WantedBy=multi-user.target</programlisting> | |
1753 | ||
798d3a52 ZJS |
1754 | <para>Alternatively, the administrator could create a drop-in |
1755 | file | |
12b42c76 | 1756 | <filename>/etc/systemd/system/httpd.service.d/local.conf</filename> |
798d3a52 | 1757 | with the following contents:</para> |
92b1e225 | 1758 | |
798d3a52 | 1759 | <programlisting>[Unit] |
92b1e225 CS |
1760 | After=memcached.service |
1761 | Requires=memcached.service | |
1762 | # Reset all assertions and then re-add the condition we want | |
1763 | AssertPathExists= | |
1764 | AssertPathExists=/srv/www | |
1765 | ||
1766 | [Service] | |
1767 | Nice=0 | |
1768 | PrivateTmp=yes</programlisting> | |
1769 | ||
afbc75e6 DB |
1770 | <para>Note that for drop-in files, if one wants to remove |
1771 | entries from a setting that is parsed as a list (and is not a | |
1772 | dependency), such as <varname>AssertPathExists=</varname> (or | |
1773 | e.g. <varname>ExecStart=</varname> in service units), one needs | |
1774 | to first clear the list before re-adding all entries except the | |
1775 | one that is to be removed. Dependencies (<varname>After=</varname>, etc.) | |
798d3a52 ZJS |
1776 | cannot be reset to an empty list, so dependencies can only be |
1777 | added in drop-ins. If you want to remove dependencies, you have | |
1778 | to override the entire unit.</para> | |
0cf4c0d1 | 1779 | |
798d3a52 ZJS |
1780 | </example> |
1781 | </refsect1> | |
1782 | ||
1783 | <refsect1> | |
1784 | <title>See Also</title> | |
1785 | <para> | |
1786 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
1787 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
1788 | <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
1789 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1790 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1791 | <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1792 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1793 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1794 | <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1795 | <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1796 | <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1797 | <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
798d3a52 ZJS |
1798 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
1799 | <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1800 | <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
1801 | <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
1802 | <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
1803 | <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
3ba3a79d | 1804 | <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
798d3a52 ZJS |
1805 | </para> |
1806 | </refsect1> | |
d1ab0ca0 LP |
1807 | |
1808 | </refentry> |