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