]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
3a54a157 | 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//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 | ]> | |
db9ecf05 | 7 | <!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
d1ab0ca0 | 8 | |
503298b7 LP |
9 | <refentry id="systemd.unit" |
10 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
d1ab0ca0 | 11 | |
798d3a52 ZJS |
12 | <refentryinfo> |
13 | <title>systemd.unit</title> | |
14 | <productname>systemd</productname> | |
798d3a52 ZJS |
15 | </refentryinfo> |
16 | ||
17 | <refmeta> | |
18 | <refentrytitle>systemd.unit</refentrytitle> | |
19 | <manvolnum>5</manvolnum> | |
20 | </refmeta> | |
21 | ||
22 | <refnamediv> | |
23 | <refname>systemd.unit</refname> | |
24 | <refpurpose>Unit configuration</refpurpose> | |
25 | </refnamediv> | |
26 | ||
27 | <refsynopsisdiv> | |
28 | <para><filename><replaceable>service</replaceable>.service</filename>, | |
29 | <filename><replaceable>socket</replaceable>.socket</filename>, | |
30 | <filename><replaceable>device</replaceable>.device</filename>, | |
31 | <filename><replaceable>mount</replaceable>.mount</filename>, | |
32 | <filename><replaceable>automount</replaceable>.automount</filename>, | |
33 | <filename><replaceable>swap</replaceable>.swap</filename>, | |
34 | <filename><replaceable>target</replaceable>.target</filename>, | |
35 | <filename><replaceable>path</replaceable>.path</filename>, | |
36 | <filename><replaceable>timer</replaceable>.timer</filename>, | |
798d3a52 ZJS |
37 | <filename><replaceable>slice</replaceable>.slice</filename>, |
38 | <filename><replaceable>scope</replaceable>.scope</filename></para> | |
39 | ||
2ace445d LP |
40 | <refsect2> |
41 | <title>System Unit Search Path</title> | |
42 | ||
43 | <para><literallayout><filename>/etc/systemd/system.control/*</filename> | |
b82f27e7 ZJS |
44 | <filename>/run/systemd/system.control/*</filename> |
45 | <filename>/run/systemd/transient/*</filename> | |
46 | <filename>/run/systemd/generator.early/*</filename> | |
47 | <filename>/etc/systemd/system/*</filename> | |
e4d54220 | 48 | <filename>/etc/systemd/system.attached/*</filename> |
13219b7f | 49 | <filename>/run/systemd/system/*</filename> |
e4d54220 | 50 | <filename>/run/systemd/system.attached/*</filename> |
b82f27e7 | 51 | <filename>/run/systemd/generator/*</filename> |
f8b68539 | 52 | <filename index='false'>…</filename> |
b82f27e7 | 53 | <filename>/usr/lib/systemd/system/*</filename> |
2ace445d LP |
54 | <filename>/run/systemd/generator.late/*</filename></literallayout></para> |
55 | </refsect2> | |
13219b7f | 56 | |
2ace445d LP |
57 | <refsect2> |
58 | <title>User Unit Search Path</title> | |
59 | <para><literallayout><filename>~/.config/systemd/user.control/*</filename> | |
b82f27e7 ZJS |
60 | <filename>$XDG_RUNTIME_DIR/systemd/user.control/*</filename> |
61 | <filename>$XDG_RUNTIME_DIR/systemd/transient/*</filename> | |
62 | <filename>$XDG_RUNTIME_DIR/systemd/generator.early/*</filename> | |
aa96ef86 | 63 | <filename>~/.config/systemd/user/*</filename> |
e3820eea | 64 | <filename>$XDG_CONFIG_DIRS/systemd/user/*</filename> |
12b42c76 | 65 | <filename>/etc/systemd/user/*</filename> |
aa08982d | 66 | <filename>$XDG_RUNTIME_DIR/systemd/user/*</filename> |
13219b7f | 67 | <filename>/run/systemd/user/*</filename> |
b82f27e7 | 68 | <filename>$XDG_RUNTIME_DIR/systemd/generator/*</filename> |
e3820eea PATS |
69 | <filename>$XDG_DATA_HOME/systemd/user/*</filename> |
70 | <filename>$XDG_DATA_DIRS/systemd/user/*</filename> | |
f8b68539 | 71 | <filename index='false'>…</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 | |
675fa6ea | 86 | <citerefentry><refentrytitle>systemd.syntax</refentrytitle><manvolnum>7</manvolnum></citerefentry> |
0f943ae4 | 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 | ||
13dcc96f ZJS |
110 | <para>Unit files are loaded from a set of paths determined during compilation, described in the next |
111 | section.</para> | |
112 | ||
113 | <para>Valid unit names consist of a "name prefix" and a dot and a suffix specifying the unit type. The | |
114 | "unit prefix" must consist of one or more valid characters (ASCII letters, digits, <literal>:</literal>, | |
115 | <literal>-</literal>, <literal>_</literal>, <literal>.</literal>, and <literal>\</literal>). The total | |
116 | length of the unit name including the suffix must not exceed 256 characters. The type suffix must be one | |
117 | of <literal>.service</literal>, <literal>.socket</literal>, <literal>.device</literal>, | |
118 | <literal>.mount</literal>, <literal>.automount</literal>, <literal>.swap</literal>, | |
119 | <literal>.target</literal>, <literal>.path</literal>, <literal>.timer</literal>, | |
120 | <literal>.slice</literal>, or <literal>.scope</literal>.</para> | |
121 | ||
122 | <para>Units names can be parameterized by a single argument called the "instance name". The unit is then | |
123 | constructed based on a "template file" which serves as the definition of multiple services or other | |
124 | units. A template unit must have a single <literal>@</literal> at the end of the name (right before the | |
125 | type suffix). The name of the full unit is formed by inserting the instance name between | |
126 | <literal>@</literal> and the unit type suffix. In the unit file itself, the instance parameter may be | |
127 | referred to using <literal>%i</literal> and other specifiers, see below.</para> | |
75695fb7 | 128 | |
798d3a52 ZJS |
129 | <para>Unit files may contain additional options on top of those |
130 | listed here. If systemd encounters an unknown option, it will | |
131 | write a warning log message but continue loading the unit. If an | |
132 | option or section name is prefixed with <option>X-</option>, it is | |
133 | ignored completely by systemd. Options within an ignored section | |
134 | do not need the prefix. Applications may use this to include | |
135 | additional information in the unit files.</para> | |
136 | ||
b5328434 ZJS |
137 | <para>Units can be aliased (have an alternative name), by creating a symlink from the new name to the |
138 | existing name in one of the unit search paths. For example, <filename>systemd-networkd.service</filename> | |
139 | has the alias <filename>dbus-org.freedesktop.network1.service</filename>, created during installation as | |
140 | a symlink, so when <command>systemd</command> is asked through D-Bus to load | |
141 | <filename>dbus-org.freedesktop.network1.service</filename>, it'll load | |
2e93770f ZJS |
142 | <filename>systemd-networkd.service</filename>. As another example, <filename>default.target</filename> — |
143 | the default system target started at boot — is commonly symlinked (aliased) to either | |
144 | <filename>multi-user.target</filename> or <filename>graphical.target</filename> to select what is started | |
145 | by default. Alias names may be used in commands like <command>disable</command>, | |
146 | <command>start</command>, <command>stop</command>, <command>status</command>, and similar, and in all | |
147 | unit dependency directives, including <varname>Wants=</varname>, <varname>Requires=</varname>, | |
148 | <varname>Before=</varname>, <varname>After=</varname>. Aliases cannot be used with the | |
149 | <command>preset</command> command.</para> | |
150 | ||
151 | <para>Aliases obey the following restrictions: a unit of a certain type (<literal>.service</literal>, | |
152 | <literal>.socket</literal>, …) can only be aliased by a name with the same type suffix. A plain unit (not | |
153 | a template or an instance), may only be aliased by a plain name. A template instance may only be aliased | |
154 | by another template instance, and the instance part must be identical. A template may be aliased by | |
155 | another template (in which case the alias applies to all instances of the template). As a special case, a | |
156 | template instance (e.g. <literal>alias@inst.service</literal>) may be a symlink to different template | |
157 | (e.g. <literal>template@inst.service</literal>). In that case, just this specific instance is aliased, | |
158 | while other instances of the template (e.g. <literal>alias@foo.service</literal>, | |
159 | <literal>alias@bar.service</literal>) are not aliased. Those rule preserve the requirement that the | |
160 | instance (if any) is always uniquely defined for a given unit and all its aliases.</para> | |
b5328434 ZJS |
161 | |
162 | <para>Unit files may specify aliases through the <varname>Alias=</varname> directive in the [Install] | |
163 | section. When the unit is enabled, symlinks will be created for those names, and removed when the unit is | |
164 | disabled. For example, <filename>reboot.target</filename> specifies | |
165 | <varname>Alias=ctrl-alt-del.target</varname>, so when enabled, the symlink | |
57733518 | 166 | <filename>/etc/systemd/system/ctrl-alt-del.service</filename> pointing to the |
b5328434 ZJS |
167 | <filename>reboot.target</filename> file will be created, and when |
168 | <keycombo><keycap>Ctrl</keycap><keycap>Alt</keycap><keycap>Del</keycap></keycombo> is invoked, | |
169 | <command>systemd</command> will look for the <filename>ctrl-alt-del.service</filename> and execute | |
170 | <filename>reboot.service</filename>. <command>systemd</command> does not look at the [Install] section at | |
171 | all during normal operation, so any directives in that section only have an effect through the symlinks | |
172 | created during enablement.</para> | |
bac150e9 ZJS |
173 | |
174 | <para>Along with a unit file <filename>foo.service</filename>, the directory | |
b5328434 ZJS |
175 | <filename>foo.service.wants/</filename> may exist. All unit files symlinked from such a directory are |
176 | implicitly added as dependencies of type <varname>Wants=</varname> to the unit. Similar functionality | |
177 | exists for <varname>Requires=</varname> type dependencies as well, the directory suffix is | |
178 | <filename>.requires/</filename> in this case. This functionality is useful to hook units into the | |
179 | start-up of other units, without having to modify their unit files. For details about the semantics of | |
180 | <varname>Wants=</varname>, see below. The preferred way to create symlinks in the | |
181 | <filename>.wants/</filename> or <filename>.requires/</filename> directory of a unit file is by embedding | |
182 | the dependency in [Install] section of the target unit, and creating the symlink in the file system with | |
ff7cfff0 | 183 | the <command>enable</command> or <command>preset</command> commands of |
b5328434 | 184 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para> |
798d3a52 | 185 | |
be73bb48 | 186 | <para>Along with a unit file <filename>foo.service</filename>, a "drop-in" directory |
e6655fbe YW |
187 | <filename>foo.service.d/</filename> may exist. All files with the suffix |
188 | <literal>.conf</literal> from this directory will be merged in the alphanumeric order and parsed | |
189 | after the main unit file itself has been parsed. This is useful to alter or add configuration | |
190 | settings for a unit, without having to modify unit files. Each drop-in file must contain appropriate | |
191 | section headers. For instantiated units, this logic will first look for the instance | |
192 | <literal>.d/</literal> subdirectory (e.g. <literal>foo@bar.service.d/</literal>) and read its | |
193 | <literal>.conf</literal> files, followed by the template <literal>.d/</literal> subdirectory (e.g. | |
194 | <literal>foo@.service.d/</literal>) and the <literal>.conf</literal> files there. Moreover for unit | |
195 | names containing dashes (<literal>-</literal>), the set of directories generated by repeatedly | |
196 | truncating the unit name after all dashes is searched too. Specifically, for a unit name | |
1b2ad5d9 | 197 | <filename>foo-bar-baz.service</filename> not only the regular drop-in directory |
6c0a7795 LP |
198 | <filename>foo-bar-baz.service.d/</filename> is searched but also both <filename>foo-bar-.service.d/</filename> and |
199 | <filename>foo-.service.d/</filename>. This is useful for defining common drop-ins for a set of related units, whose | |
200 | names begin with a common prefix. This scheme is particularly useful for mount, automount and slice units, whose | |
201 | systematic naming structure is built around dashes as component separators. Note that equally named drop-in files | |
202 | further down the prefix hierarchy override those further up, | |
203 | i.e. <filename>foo-bar-.service.d/10-override.conf</filename> overrides | |
204 | <filename>foo-.service.d/10-override.conf</filename>.</para> | |
205 | ||
2e93770f ZJS |
206 | <para>In cases of unit aliases (described above), dropins for the aliased name and all aliases are |
207 | loaded. In the example of <filename>default.target</filename> aliasing | |
208 | <filename>graphical.target</filename>, <filename>default.target.d/</filename>, | |
209 | <filename>default.target.wants/</filename>, <filename>default.target.requires/</filename>, | |
210 | <filename>graphical.target.d/</filename>, <filename>graphical.target.wants/</filename>, | |
211 | <filename>graphical.target.requires/</filename> would all be read. For templates, dropins for the | |
212 | template, any template aliases, the template instance, and all alias instances are read. When just a | |
213 | specific template instance is aliased, then the dropins for the target template, the target template | |
214 | instance, and the alias template instance are read.</para> | |
6c0a7795 LP |
215 | |
216 | <para>In addition to <filename>/etc/systemd/system</filename>, the drop-in <literal>.d/</literal> | |
bac150e9 | 217 | directories for system services can be placed in <filename>/usr/lib/systemd/system</filename> or |
3b121157 ZJS |
218 | <filename>/run/systemd/system</filename> directories. Drop-in files in <filename>/etc/</filename> |
219 | take precedence over those in <filename>/run/</filename> which in turn take precedence over those | |
220 | in <filename>/usr/lib/</filename>. Drop-in files under any of these directories take precedence | |
8331eaab LW |
221 | over unit files wherever located. Multiple drop-in files with different names are applied in |
222 | lexicographic order, regardless of which of the directories they reside in.</para> | |
bac150e9 | 223 | |
3e1db806 AZ |
224 | <para>Units also support a top-level drop-in with <filename><replaceable>type</replaceable>.d/</filename>, |
225 | where <replaceable>type</replaceable> may be e.g. <literal>service</literal> or <literal>socket</literal>, | |
226 | that allows altering or adding to the settings of all corresponding unit files on the system. | |
227 | The formatting and precedence of applying drop-in configurations follow what is defined above. | |
228 | Configurations in <filename><replaceable>type</replaceable>.d/</filename> have the lowest precedence | |
229 | compared to settings in the name specific override directories. So the contents of | |
230 | <filename>foo-.service.d/10-override.conf</filename> would override | |
231 | <filename>service.d/10-override.conf</filename>.</para> | |
d2724678 | 232 | |
bbe0b4a8 JL |
233 | <para>Note that while systemd offers a flexible dependency system |
234 | between units it is recommended to use this functionality only | |
235 | sparingly and instead rely on techniques such as bus-based or | |
236 | socket-based activation which make dependencies implicit, | |
237 | resulting in a both simpler and more flexible system.</para> | |
238 | ||
75695fb7 ZJS |
239 | <para>As mentioned above, a unit may be instantiated from a template file. This allows creation |
240 | of multiple units from a single configuration file. If systemd looks for a unit configuration | |
241 | file, it will first search for the literal unit name in the file system. If that yields no | |
242 | success and the unit name contains an <literal>@</literal> character, systemd will look for a | |
243 | unit template that shares the same name but with the instance string (i.e. the part between the | |
244 | <literal>@</literal> character and the suffix) removed. Example: if a service | |
245 | <filename>getty@tty3.service</filename> is requested and no file by that name is found, systemd | |
246 | will look for <filename>getty@.service</filename> and instantiate a service from that | |
247 | configuration file if it is found.</para> | |
798d3a52 ZJS |
248 | |
249 | <para>To refer to the instance string from within the | |
250 | configuration file you may use the special <literal>%i</literal> | |
251 | specifier in many of the configuration options. See below for | |
252 | details.</para> | |
253 | ||
254 | <para>If a unit file is empty (i.e. has the file size 0) or is | |
255 | symlinked to <filename>/dev/null</filename>, its configuration | |
256 | will not be loaded and it appears with a load state of | |
257 | <literal>masked</literal>, and cannot be activated. Use this as an | |
258 | effective way to fully disable a unit, making it impossible to | |
259 | start it even manually.</para> | |
260 | ||
261 | <para>The unit file format is covered by the | |
f856778b | 262 | <ulink url="https://systemd.io/PORTABILITY_AND_STABILITY/">Interface |
263 | Portability and Stability Promise</ulink>.</para> | |
798d3a52 ZJS |
264 | |
265 | </refsect1> | |
266 | ||
2651d037 LP |
267 | <refsect1> |
268 | <title>String Escaping for Inclusion in Unit Names</title> | |
269 | ||
270 | <para>Sometimes it is useful to convert arbitrary strings into unit names. To facilitate this, a method of string | |
6b44ad0b YW |
271 | escaping is used, in order to map strings containing arbitrary byte values (except <constant>NUL</constant>) into |
272 | valid unit names and their restricted character set. A common special case are unit names that reflect paths to | |
273 | objects in the file system hierarchy. Example: a device unit <filename>dev-sda.device</filename> refers to a device | |
274 | with the device node <filename index="false">/dev/sda</filename> in the file system.</para> | |
2651d037 | 275 | |
aa6dc3ec LP |
276 | <para>The escaping algorithm operates as follows: given a string, any <literal>/</literal> character is |
277 | replaced by <literal>-</literal>, and all other characters which are not ASCII alphanumerics, | |
278 | <literal>:</literal>, <literal>_</literal> or <literal>.</literal> are replaced by C-style | |
279 | <literal>\x2d</literal> escapes. In addition, <literal>.</literal> is replaced with such a C-style escape | |
280 | when it would appear as the first character in the escaped string.</para> | |
2651d037 LP |
281 | |
282 | <para>When the input qualifies as absolute file system path, this algorithm is extended slightly: the path to the | |
283 | root directory <literal>/</literal> is encoded as single dash <literal>-</literal>. In addition, any leading, | |
284 | trailing or duplicate <literal>/</literal> characters are removed from the string before transformation. Example: | |
211c99c7 | 285 | <filename index="false">/foo//bar/baz/</filename> becomes <literal>foo-bar-baz</literal>.</para> |
2651d037 LP |
286 | |
287 | <para>This escaping is fully reversible, as long as it is known whether the escaped string was a path (the | |
288 | unescaping results are different for paths and non-path strings). The | |
289 | <citerefentry><refentrytitle>systemd-escape</refentrytitle><manvolnum>1</manvolnum></citerefentry> command may be | |
290 | used to apply and reverse escaping on arbitrary strings. Use <command>systemd-escape --path</command> to escape | |
291 | path strings, and <command>systemd-escape</command> without <option>--path</option> otherwise.</para> | |
292 | </refsect1> | |
293 | ||
c129bd5d | 294 | <refsect1> |
aed5cb03 ZJS |
295 | <title>Automatic dependencies</title> |
296 | ||
297 | <refsect2> | |
298 | <title>Implicit Dependencies</title> | |
299 | ||
300 | <para>A number of unit dependencies are implicitly established, depending on unit type and | |
301 | unit configuration. These implicit dependencies can make unit configuration file cleaner. For | |
302 | the implicit dependencies in each unit type, please refer to section "Implicit Dependencies" | |
303 | in respective man pages.</para> | |
304 | ||
305 | <para>For example, service units with <varname>Type=dbus</varname> automatically acquire | |
306 | dependencies of type <varname>Requires=</varname> and <varname>After=</varname> on | |
307 | <filename>dbus.socket</filename>. See | |
308 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
309 | for details.</para> | |
310 | </refsect2> | |
311 | ||
312 | <refsect2> | |
313 | <title>Default Dependencies</title> | |
314 | ||
315 | <para>Default dependencies are similar to implicit dependencies, but can be turned on and off | |
316 | by setting <varname>DefaultDependencies=</varname> to <varname>yes</varname> (the default) and | |
317 | <varname>no</varname>, while implicit dependencies are always in effect. See section "Default | |
318 | Dependencies" in respective man pages for the effect of enabling | |
319 | <varname>DefaultDependencies=</varname> in each unit types.</para> | |
320 | ||
321 | <para>For example, target units will complement all configured dependencies of type | |
322 | <varname>Wants=</varname> or <varname>Requires=</varname> with dependencies of type | |
323 | <varname>After=</varname> unless <varname>DefaultDependencies=no</varname> is set in the | |
324 | specified units. See | |
325 | <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
326 | for details. Note that this behavior can be turned off by setting | |
327 | <varname>DefaultDependencies=no</varname>.</para> | |
328 | </refsect2> | |
45f09f93 JL |
329 | </refsect1> |
330 | ||
798d3a52 | 331 | <refsect1> |
f757855e | 332 | <title>Unit File Load Path</title> |
798d3a52 ZJS |
333 | |
334 | <para>Unit files are loaded from a set of paths determined during | |
335 | compilation, described in the two tables below. Unit files found | |
336 | in directories listed earlier override files with the same name in | |
337 | directories lower in the list.</para> | |
338 | ||
aa3e4400 EV |
339 | <para>When the variable <varname>$SYSTEMD_UNIT_PATH</varname> is set, |
340 | the contents of this variable overrides the unit load path. If | |
798d3a52 ZJS |
341 | <varname>$SYSTEMD_UNIT_PATH</varname> ends with an empty component |
342 | (<literal>:</literal>), the usual unit load path will be appended | |
343 | to the contents of the variable.</para> | |
344 | ||
345 | <table> | |
346 | <title> | |
347 | Load path when running in system mode (<option>--system</option>). | |
348 | </title> | |
349 | ||
350 | <tgroup cols='2'> | |
351 | <colspec colname='path' /> | |
352 | <colspec colname='expl' /> | |
353 | <thead> | |
354 | <row> | |
5a15caf4 ZJS |
355 | <entry>Path</entry> |
356 | <entry>Description</entry> | |
798d3a52 ZJS |
357 | </row> |
358 | </thead> | |
359 | <tbody> | |
b82f27e7 ZJS |
360 | <row> |
361 | <entry><filename>/etc/systemd/system.control</filename></entry> | |
362 | <entry morerows="1">Persistent and transient configuration created using the dbus API</entry> | |
363 | </row> | |
364 | <row> | |
365 | <entry><filename>/run/systemd/system.control</filename></entry> | |
366 | </row> | |
367 | <row> | |
368 | <entry><filename>/run/systemd/transient</filename></entry> | |
369 | <entry>Dynamic configuration for transient units</entry> | |
370 | </row> | |
371 | <row> | |
372 | <entry><filename>/run/systemd/generator.early</filename></entry> | |
373 | <entry>Generated units with high priority (see <replaceable>early-dir</replaceable> in <citerefentry | |
631e393a | 374 | ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> |
b82f27e7 | 375 | </row> |
798d3a52 | 376 | <row> |
5a15caf4 | 377 | <entry><filename>/etc/systemd/system</filename></entry> |
565026b4 | 378 | <entry>System units created by the administrator</entry> |
798d3a52 ZJS |
379 | </row> |
380 | <row> | |
5a15caf4 ZJS |
381 | <entry><filename>/run/systemd/system</filename></entry> |
382 | <entry>Runtime units</entry> | |
798d3a52 | 383 | </row> |
b82f27e7 ZJS |
384 | <row> |
385 | <entry><filename>/run/systemd/generator</filename></entry> | |
386 | <entry>Generated units with medium priority (see <replaceable>normal-dir</replaceable> in <citerefentry | |
631e393a | 387 | ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> |
b82f27e7 ZJS |
388 | </row> |
389 | <row> | |
390 | <entry><filename>/usr/local/lib/systemd/system</filename></entry> | |
565026b4 | 391 | <entry>System units installed by the administrator </entry> |
b82f27e7 | 392 | </row> |
798d3a52 | 393 | <row> |
5a15caf4 | 394 | <entry><filename>/usr/lib/systemd/system</filename></entry> |
565026b4 | 395 | <entry>System units installed by the distribution package manager</entry> |
b82f27e7 ZJS |
396 | </row> |
397 | <row> | |
398 | <entry><filename>/run/systemd/generator.late</filename></entry> | |
399 | <entry>Generated units with low priority (see <replaceable>late-dir</replaceable> in <citerefentry | |
631e393a | 400 | ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> |
798d3a52 ZJS |
401 | </row> |
402 | </tbody> | |
403 | </tgroup> | |
404 | </table> | |
405 | ||
406 | <table> | |
407 | <title> | |
408 | Load path when running in user mode (<option>--user</option>). | |
409 | </title> | |
410 | ||
411 | <tgroup cols='2'> | |
412 | <colspec colname='path' /> | |
413 | <colspec colname='expl' /> | |
414 | <thead> | |
415 | <row> | |
5a15caf4 ZJS |
416 | <entry>Path</entry> |
417 | <entry>Description</entry> | |
798d3a52 ZJS |
418 | </row> |
419 | </thead> | |
420 | <tbody> | |
421 | <row> | |
b82f27e7 ZJS |
422 | <entry><filename>$XDG_CONFIG_HOME/systemd/user.control</filename> or <filename |
423 | >~/.config/systemd/user.control</filename></entry> | |
424 | <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> | |
425 | </row> | |
426 | <row> | |
427 | <entry><filename>$XDG_RUNTIME_DIR/systemd/user.control</filename></entry> | |
428 | </row> | |
429 | <row> | |
430 | <entry><filename>/run/systemd/transient</filename></entry> | |
431 | <entry>Dynamic configuration for transient units</entry> | |
432 | </row> | |
433 | <row> | |
434 | <entry><filename>/run/systemd/generator.early</filename></entry> | |
435 | <entry>Generated units with high priority (see <replaceable>early-dir</replaceable> in <citerefentry | |
631e393a | 436 | ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> |
798d3a52 ZJS |
437 | </row> |
438 | <row> | |
b82f27e7 ZJS |
439 | <entry><filename>$XDG_CONFIG_HOME/systemd/user</filename> or <filename>$HOME/.config/systemd/user</filename></entry> |
440 | <entry>User configuration (<varname>$XDG_CONFIG_HOME</varname> is used if set, <filename>~/.config</filename> otherwise)</entry> | |
798d3a52 | 441 | </row> |
e3820eea PATS |
442 | <row> |
443 | <entry><filename>$XDG_CONFIG_DIRS/systemd/user</filename> or <filename>/etc/xdg/systemd/user</filename></entry> | |
444 | <entry>Additional configuration directories as specified by the XDG base directory specification (<varname>$XDG_CONFIG_DIRS</varname> is used if set, <filename>/etc/xdg</filename> otherwise)</entry> | |
445 | </row> | |
798d3a52 | 446 | <row> |
5a15caf4 | 447 | <entry><filename>/etc/systemd/user</filename></entry> |
565026b4 | 448 | <entry>User units created by the administrator</entry> |
798d3a52 ZJS |
449 | </row> |
450 | <row> | |
5a15caf4 ZJS |
451 | <entry><filename>$XDG_RUNTIME_DIR/systemd/user</filename></entry> |
452 | <entry>Runtime units (only used when $XDG_RUNTIME_DIR is set)</entry> | |
798d3a52 ZJS |
453 | </row> |
454 | <row> | |
5a15caf4 ZJS |
455 | <entry><filename>/run/systemd/user</filename></entry> |
456 | <entry>Runtime units</entry> | |
798d3a52 ZJS |
457 | </row> |
458 | <row> | |
b82f27e7 ZJS |
459 | <entry><filename>$XDG_RUNTIME_DIR/systemd/generator</filename></entry> |
460 | <entry>Generated units with medium priority (see <replaceable>normal-dir</replaceable> in <citerefentry | |
631e393a | 461 | ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> |
798d3a52 ZJS |
462 | </row> |
463 | <row> | |
b82f27e7 ZJS |
464 | <entry><filename>$XDG_DATA_HOME/systemd/user</filename> or <filename>$HOME/.local/share/systemd/user</filename></entry> |
465 | <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> | |
466 | </row> | |
e3820eea PATS |
467 | <row> |
468 | <entry><filename>$XDG_DATA_DIRS/systemd/user</filename> or <filename>/usr/local/share/systemd/user</filename> and <filename>/usr/share/systemd/user</filename></entry> | |
469 | <entry>Additional data directories as specified by the XDG base directory specification (<varname>$XDG_DATA_DIRS</varname> is used if set, <filename>/usr/local/share</filename> and <filename>/usr/share</filename> otherwise)</entry> | |
470 | </row> | |
b82f27e7 | 471 | <row> |
b0343f8c | 472 | <entry><filename>$dir/systemd/user</filename> for each <varname index="false">$dir</varname> in <varname>$XDG_DATA_DIRS</varname></entry> |
b82f27e7 ZJS |
473 | <entry>Additional locations for installed user units, one for each entry in <varname>$XDG_DATA_DIRS</varname></entry> |
474 | </row> | |
475 | <row> | |
476 | <entry><filename>/usr/local/lib/systemd/user</filename></entry> | |
565026b4 | 477 | <entry>User units installed by the administrator</entry> |
798d3a52 ZJS |
478 | </row> |
479 | <row> | |
5a15caf4 | 480 | <entry><filename>/usr/lib/systemd/user</filename></entry> |
565026b4 | 481 | <entry>User units installed by the distribution package manager</entry> |
b82f27e7 ZJS |
482 | </row> |
483 | <row> | |
484 | <entry><filename>$XDG_RUNTIME_DIR/systemd/generator.late</filename></entry> | |
485 | <entry>Generated units with low priority (see <replaceable>late-dir</replaceable> in <citerefentry | |
631e393a | 486 | ><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>)</entry> |
798d3a52 ZJS |
487 | </row> |
488 | </tbody> | |
489 | </tgroup> | |
490 | </table> | |
491 | ||
b82f27e7 ZJS |
492 | <para>The set of load paths for the user manager instance may be augmented or |
493 | changed using various environment variables. And environment variables may in | |
494 | turn be set using environment generators, see | |
930362ab | 495 | <citerefentry><refentrytitle>systemd.environment-generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>. |
b82f27e7 ZJS |
496 | In particular, <varname>$XDG_DATA_HOME</varname> and |
497 | <varname>$XDG_DATA_DIRS</varname> may be easily set using | |
498 | <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>. | |
499 | Thus, directories listed here are just the defaults. To see the actual list that | |
500 | would be used based on compilation options and current environment use | |
501 | <programlisting>systemd-analyze --user unit-paths</programlisting> | |
502 | </para> | |
503 | ||
b63c88b6 HD |
504 | <para>Moreover, additional units might be loaded into systemd from |
505 | directories not on the unit load path by creating a symlink pointing to a | |
506 | unit file in the directories. You can use <command>systemctl link</command> | |
507 | for this operation. See | |
508 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
509 | for its usage and precaution. | |
798d3a52 ZJS |
510 | </para> |
511 | </refsect1> | |
512 | ||
5afe510c LP |
513 | <refsect1> |
514 | <title>Unit Garbage Collection</title> | |
515 | ||
516 | <para>The system and service manager loads a unit's configuration automatically when a unit is referenced for the | |
517 | first time. It will automatically unload the unit configuration and state again when the unit is not needed anymore | |
518 | ("garbage collection"). A unit may be referenced through a number of different mechanisms:</para> | |
519 | ||
520 | <orderedlist> | |
521 | <listitem><para>Another loaded unit references it with a dependency such as <varname>After=</varname>, | |
522 | <varname>Wants=</varname>, …</para></listitem> | |
523 | ||
524 | <listitem><para>The unit is currently starting, running, reloading or stopping.</para></listitem> | |
525 | ||
526 | <listitem><para>The unit is currently in the <constant>failed</constant> state. (But see below.)</para></listitem> | |
527 | ||
528 | <listitem><para>A job for the unit is pending.</para></listitem> | |
529 | ||
530 | <listitem><para>The unit is pinned by an active IPC client program.</para></listitem> | |
531 | ||
532 | <listitem><para>The unit is a special "perpetual" unit that is always active and loaded. Examples for perpetual | |
533 | units are the root mount unit <filename>-.mount</filename> or the scope unit <filename>init.scope</filename> that | |
534 | the service manager itself lives in.</para></listitem> | |
535 | ||
536 | <listitem><para>The unit has running processes associated with it.</para></listitem> | |
537 | </orderedlist> | |
538 | ||
539 | <para>The garbage collection logic may be altered with the <varname>CollectMode=</varname> option, which allows | |
540 | configuration whether automatic unloading of units that are in <constant>failed</constant> state is permissible, | |
541 | see below.</para> | |
542 | ||
543 | <para>Note that when a unit's configuration and state is unloaded, all execution results, such as exit codes, exit | |
544 | signals, resource consumption and other statistics are lost, except for what is stored in the log subsystem.</para> | |
545 | ||
546 | <para>Use <command>systemctl daemon-reload</command> or an equivalent command to reload unit configuration while | |
547 | the unit is already loaded. In this case all configuration settings are flushed out and replaced with the new | |
548 | configuration (which however might not be in effect immediately), however all runtime state is | |
549 | saved/restored.</para> | |
550 | </refsect1> | |
551 | ||
798d3a52 ZJS |
552 | <refsect1> |
553 | <title>[Unit] Section Options</title> | |
554 | ||
a8eaaee7 | 555 | <para>The unit file may include a [Unit] section, which carries |
798d3a52 ZJS |
556 | generic information about the unit that is not dependent on the |
557 | type of unit:</para> | |
558 | ||
559 | <variablelist class='unit-directives'> | |
798d3a52 ZJS |
560 | <varlistentry> |
561 | <term><varname>Description=</varname></term> | |
c43acf69 ZJS |
562 | <listitem><para>A human readable name for the unit. This is used by |
563 | <command>systemd</command> (and other UIs) as the label for the unit, so this string should | |
564 | identify the unit rather than describe it, despite the name. <literal>Apache2 Web | |
565 | Server</literal> is a good example. Bad examples are <literal>high-performance light-weight | |
566 | HTTP server</literal> (too generic) or <literal>Apache2</literal> (too specific and | |
567 | meaningless for people who do not know Apache). <command>systemd</command> will use this | |
568 | string as a noun in status messages (<literal>Starting | |
569 | <replaceable>description</replaceable>...</literal>, <literal>Started | |
570 | <replaceable>description</replaceable>.</literal>, <literal>Reached target | |
571 | <replaceable>description</replaceable>.</literal>, <literal>Failed to start | |
572 | <replaceable>description</replaceable>.</literal>), so it should be capitalized, and should | |
5238e957 | 573 | not be a full sentence or a phrase with a continuous verb. Bad examples include |
c43acf69 ZJS |
574 | <literal>exiting the container</literal> or <literal>updating the database once per |
575 | day.</literal>.</para> | |
576 | </listitem> | |
798d3a52 ZJS |
577 | </varlistentry> |
578 | ||
579 | <varlistentry> | |
580 | <term><varname>Documentation=</varname></term> | |
581 | <listitem><para>A space-separated list of URIs referencing | |
582 | documentation for this unit or its configuration. Accepted are | |
583 | only URIs of the types <literal>http://</literal>, | |
584 | <literal>https://</literal>, <literal>file:</literal>, | |
585 | <literal>info:</literal>, <literal>man:</literal>. For more | |
586 | information about the syntax of these URIs, see <citerefentry | |
587 | project='man-pages'><refentrytitle>uri</refentrytitle><manvolnum>7</manvolnum></citerefentry>. | |
588 | The URIs should be listed in order of relevance, starting with | |
589 | the most relevant. It is a good idea to first reference | |
590 | documentation that explains what the unit's purpose is, | |
591 | followed by how it is configured, followed by any other | |
592 | related documentation. This option may be specified more than | |
593 | once, in which case the specified list of URIs is merged. If | |
594 | the empty string is assigned to this option, the list is reset | |
595 | and all prior assignments will have no | |
596 | effect.</para></listitem> | |
597 | </varlistentry> | |
598 | ||
d19cd71a ZJS |
599 | <varlistentry> |
600 | <term><varname>Wants=</varname></term> | |
601 | ||
c024f320 LP |
602 | <listitem><para>Configures (weak) requirement dependencies on other units. This option may be |
603 | specified more than once or multiple space-separated units may be specified in one option in which | |
604 | case dependencies for all listed names will be created. Dependencies of this type may also be | |
605 | configured outside of the unit configuration file by adding a symlink to a | |
606 | <filename>.wants/</filename> directory accompanying the unit file. For details, see above.</para> | |
d19cd71a ZJS |
607 | |
608 | <para>Units listed in this option will be started if the configuring unit is. However, if the listed | |
609 | units fail to start or cannot be added to the transaction, this has no impact on the validity of the | |
610 | transaction as a whole, and this unit will still be started. This is the recommended way to hook | |
1ad44867 | 611 | the start-up of one unit to the start-up of another unit.</para> |
d19cd71a ZJS |
612 | |
613 | <para>Note that requirement dependencies do not influence the order in which services are started or | |
614 | stopped. This has to be configured independently with the <varname>After=</varname> or | |
615 | <varname>Before=</varname> options. If unit <filename>foo.service</filename> pulls in unit | |
616 | <filename>bar.service</filename> as configured with <varname>Wants=</varname> and no ordering is | |
617 | configured with <varname>After=</varname> or <varname>Before=</varname>, then both units will be | |
618 | started simultaneously and without any delay between them if <filename>foo.service</filename> is | |
619 | activated.</para></listitem> | |
620 | </varlistentry> | |
621 | ||
798d3a52 ZJS |
622 | <varlistentry> |
623 | <term><varname>Requires=</varname></term> | |
624 | ||
c024f320 | 625 | <listitem><para>Similar to <varname>Wants=</varname>, but declares a stronger requirement |
d19cd71a ZJS |
626 | dependency. Dependencies of this type may also be configured by adding a symlink to a |
627 | <filename>.requires/</filename> directory accompanying the unit file.</para> | |
628 | ||
629 | <para>If this unit gets activated, the units listed will be activated as well. If one of | |
630 | the other units fails to activate, and an ordering dependency <varname>After=</varname> on the | |
631 | failing unit is set, this unit will not be started. Besides, with or without specifying | |
632 | <varname>After=</varname>, this unit will be stopped if one of the other units is explicitly | |
633 | stopped.</para> | |
634 | ||
635 | <para>Often, it is a better choice to use <varname>Wants=</varname> instead of | |
636 | <varname>Requires=</varname> in order to achieve a system that is more robust when dealing with | |
62d3ca24 LP |
637 | failing services.</para> |
638 | ||
639 | <para>Note that this dependency type does not imply that the other unit always has to be in active state when | |
640 | this unit is running. Specifically: failing condition checks (such as <varname>ConditionPathExists=</varname>, | |
6b5bb2f9 | 641 | <varname>ConditionPathIsSymbolicLink=</varname>, … — see below) do not cause the start job of a unit with a |
62d3ca24 LP |
642 | <varname>Requires=</varname> dependency on it to fail. Also, some unit types may deactivate on their own (for |
643 | example, a service process may decide to exit cleanly, or a device may be unplugged by the user), which is not | |
644 | propagated to units having a <varname>Requires=</varname> dependency. Use the <varname>BindsTo=</varname> | |
645 | dependency type together with <varname>After=</varname> to ensure that a unit may never be in active state | |
d19cd71a | 646 | without a specific other unit also in active state (see below).</para></listitem> |
798d3a52 ZJS |
647 | </varlistentry> |
648 | ||
798d3a52 ZJS |
649 | <varlistentry> |
650 | <term><varname>Requisite=</varname></term> | |
798d3a52 | 651 | |
706a3df4 ZJS |
652 | <listitem><para>Similar to <varname>Requires=</varname>. However, if the units listed here |
653 | are not started already, they will not be started and the starting of this unit will fail | |
654 | immediately. <varname>Requisite=</varname> does not imply an ordering dependency, even if | |
655 | both units are started in the same transaction. Hence this setting should usually be | |
656 | combined with <varname>After=</varname>, to ensure this unit is not started before the other | |
657 | unit.</para> | |
b2920668 ZJS |
658 | |
659 | <para>When <varname>Requisite=b.service</varname> is used on | |
660 | <filename>a.service</filename>, this dependency will show as | |
661 | <varname>RequisiteOf=a.service</varname> in property listing of | |
662 | <filename>b.service</filename>. <varname>RequisiteOf=</varname> | |
663 | dependency cannot be specified directly.</para> | |
664 | </listitem> | |
798d3a52 ZJS |
665 | </varlistentry> |
666 | ||
798d3a52 ZJS |
667 | <varlistentry> |
668 | <term><varname>BindsTo=</varname></term> | |
669 | ||
62d3ca24 LP |
670 | <listitem><para>Configures requirement dependencies, very similar in style to |
671 | <varname>Requires=</varname>. However, this dependency type is stronger: in addition to the effect of | |
672 | <varname>Requires=</varname> it declares that if the unit bound to is stopped, this unit will be stopped | |
673 | too. This means a unit bound to another unit that suddenly enters inactive state will be stopped too. | |
674 | Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit | |
675 | might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of | |
676 | a mount unit might be unmounted without involvement of the system and service manager.</para> | |
677 | ||
678 | <para>When used in conjunction with <varname>After=</varname> on the same unit the behaviour of | |
679 | <varname>BindsTo=</varname> is even stronger. In this case, the unit bound to strictly has to be in active | |
680 | state for this unit to also be in active state. This not only means a unit bound to another unit that suddenly | |
681 | enters inactive state, but also one that is bound to another unit that gets skipped due to a failed condition | |
682 | check (such as <varname>ConditionPathExists=</varname>, <varname>ConditionPathIsSymbolicLink=</varname>, … — | |
683 | see below) will be stopped, should it be running. Hence, in many cases it is best to combine | |
b2920668 ZJS |
684 | <varname>BindsTo=</varname> with <varname>After=</varname>.</para> |
685 | ||
686 | <para>When <varname>BindsTo=b.service</varname> is used on | |
687 | <filename>a.service</filename>, this dependency will show as | |
688 | <varname>BoundBy=a.service</varname> in property listing of | |
689 | <filename>b.service</filename>. <varname>BoundBy=</varname> | |
690 | dependency cannot be specified directly.</para> | |
691 | </listitem> | |
798d3a52 ZJS |
692 | </varlistentry> |
693 | ||
694 | <varlistentry> | |
695 | <term><varname>PartOf=</varname></term> | |
696 | ||
697 | <listitem><para>Configures dependencies similar to | |
698 | <varname>Requires=</varname>, but limited to stopping and | |
699 | restarting of units. When systemd stops or restarts the units | |
700 | listed here, the action is propagated to this unit. Note that | |
701 | this is a one-way dependency — changes to this unit do not | |
b2920668 ZJS |
702 | affect the listed units.</para> |
703 | ||
704 | <para>When <varname>PartOf=b.service</varname> is used on | |
705 | <filename>a.service</filename>, this dependency will show as | |
706 | <varname>ConsistsOf=a.service</varname> in property listing of | |
707 | <filename>b.service</filename>. <varname>ConsistsOf=</varname> | |
708 | dependency cannot be specified directly.</para> | |
709 | </listitem> | |
798d3a52 ZJS |
710 | </varlistentry> |
711 | ||
0bc488c9 LP |
712 | <varlistentry> |
713 | <term><varname>Upholds=</varname></term> | |
714 | ||
715 | <listitem><para>Configures dependencies similar to <varname>Wants=</varname>, but as long a this unit | |
716 | is up, all units listed in <varname>Upholds=</varname> are started whenever found to be inactive or | |
717 | failed, and no job is queued for them. While a <varname>Wants=</varname> dependency on another unit | |
718 | has a one-time effect when this units started, a <varname>Upholds=</varname> dependency on it has a | |
719 | continuous effect, constantly restarting the unit if necessary. This is an alternative to the | |
720 | <varname>Restart=</varname> setting of service units, to ensure they are kept running whatever | |
721 | happens.</para> | |
722 | ||
723 | <para>When <varname>Upholds=b.service</varname> is used on <filename>a.service</filename>, this | |
724 | dependency will show as <varname>UpheldBy=a.service</varname> in the property listing of | |
725 | <filename>b.service</filename>. The <varname>UpheldBy=</varname> dependency cannot be specified | |
726 | directly.</para> | |
727 | </listitem> | |
728 | </varlistentry> | |
729 | ||
798d3a52 ZJS |
730 | <varlistentry> |
731 | <term><varname>Conflicts=</varname></term> | |
732 | ||
38c432b3 ZJS |
733 | <listitem><para>A space-separated list of unit names. Configures negative requirement |
734 | dependencies. If a unit has a <varname>Conflicts=</varname> setting on another unit, starting the | |
735 | former will stop the latter and vice versa.</para> | |
736 | ||
737 | <para>Note that this setting does not imply an ordering dependency, similarly to the | |
738 | <varname>Wants=</varname> and <varname>Requires=</varname> dependencies described above. This means | |
739 | that to ensure that the conflicting unit is stopped before the other unit is started, an | |
740 | <varname>After=</varname> or <varname>Before=</varname> dependency must be declared. It doesn't | |
741 | matter which of the two ordering dependencies is used, because stop jobs are always ordered before | |
742 | start jobs, see the discussion in <varname>Before=</varname>/<varname>After=</varname> below.</para> | |
798d3a52 | 743 | |
d19cd71a | 744 | <para>If unit A that conflicts with unit B is scheduled to |
798d3a52 | 745 | be started at the same time as B, the transaction will either |
46054ac0 | 746 | fail (in case both are required parts of the transaction) or be |
798d3a52 ZJS |
747 | modified to be fixed (in case one or both jobs are not a |
748 | required part of the transaction). In the latter case, the job | |
46054ac0 | 749 | that is not required will be removed, or in case both are |
798d3a52 ZJS |
750 | not required, the unit that conflicts will be started and the |
751 | unit that is conflicted is stopped.</para></listitem> | |
752 | </varlistentry> | |
753 | ||
754 | <varlistentry> | |
755 | <term><varname>Before=</varname></term> | |
756 | <term><varname>After=</varname></term> | |
757 | ||
d19cd71a ZJS |
758 | <listitem><para>These two settings expect a space-separated list of unit names. They may be specified |
759 | more than once, in which case dependencies for all listed names are created.</para> | |
760 | ||
d5d5b3f4 | 761 | <para>Those two settings configure ordering dependencies between units. If unit |
d19cd71a ZJS |
762 | <filename>foo.service</filename> contains the setting <option>Before=bar.service</option> and both |
763 | units are being started, <filename>bar.service</filename>'s start-up is delayed until | |
764 | <filename>foo.service</filename> has finished starting up. <varname>After=</varname> is the inverse | |
765 | of <varname>Before=</varname>, i.e. while <varname>Before=</varname> ensures that the configured unit | |
766 | is started before the listed unit begins starting up, <varname>After=</varname> ensures the opposite, | |
767 | that the listed unit is fully started up before the configured unit is started.</para> | |
768 | ||
769 | <para>When two units with an ordering dependency between them are shut down, the inverse of the | |
e9dd6984 | 770 | start-up order is applied. I.e. if a unit is configured with <varname>After=</varname> on another |
d19cd71a ZJS |
771 | unit, the former is stopped before the latter if both are shut down. Given two units with any |
772 | ordering dependency between them, if one unit is shut down and the other is started up, the shutdown | |
773 | is ordered before the start-up. It doesn't matter if the ordering dependency is | |
774 | <varname>After=</varname> or <varname>Before=</varname>, in this case. It also doesn't matter which | |
775 | of the two is shut down, as long as one is shut down and the other is started up; the shutdown is | |
776 | ordered before the start-up in all cases. If two units have no ordering dependencies between them, | |
777 | they are shut down or started up simultaneously, and no ordering takes place. It depends on the unit | |
778 | type when precisely a unit has finished starting up. Most importantly, for service units start-up is | |
779 | considered completed for the purpose of <varname>Before=</varname>/<varname>After=</varname> when all | |
780 | its configured start-up commands have been invoked and they either failed or reported start-up | |
a1db42eb LB |
781 | success. Note that this does includes <varname>ExecStartPost=</varname> (or |
782 | <varname>ExecStopPost=</varname> for the shutdown case).</para> | |
d19cd71a ZJS |
783 | |
784 | <para>Note that those settings are independent of and orthogonal to the requirement dependencies as | |
785 | configured by <varname>Requires=</varname>, <varname>Wants=</varname>, <varname>Requisite=</varname>, | |
786 | or <varname>BindsTo=</varname>. It is a common pattern to include a unit name in both the | |
787 | <varname>After=</varname> and <varname>Wants=</varname> options, in which case the unit listed will | |
eec68a1a LP |
788 | be started before the unit that is configured with these options.</para> |
789 | ||
790 | <para>Note that <varname>Before=</varname> dependencies on device units have no effect and are not | |
791 | supported. Devices generally become available as a result of an external hotplug event, and systemd | |
792 | creates the corresponding device unit without delay.</para></listitem> | |
798d3a52 ZJS |
793 | </varlistentry> |
794 | ||
795 | <varlistentry> | |
796 | <term><varname>OnFailure=</varname></term> | |
797 | ||
294446dc LP |
798 | <listitem><para>A space-separated list of one or more units that are activated when this unit enters |
799 | the <literal>failed</literal> state. A service unit using <varname>Restart=</varname> enters the | |
800 | failed state only after the start limits are reached.</para></listitem> | |
801 | </varlistentry> | |
802 | ||
803 | <varlistentry> | |
804 | <term><varname>OnSuccess=</varname></term> | |
805 | ||
806 | <listitem><para>A space-separated list of one or more units that are activated when this unit enters | |
807 | the <literal>inactive</literal> state.</para></listitem> | |
798d3a52 ZJS |
808 | </varlistentry> |
809 | ||
810 | <varlistentry> | |
811 | <term><varname>PropagatesReloadTo=</varname></term> | |
812 | <term><varname>ReloadPropagatedFrom=</varname></term> | |
813 | ||
ffec78c0 LP |
814 | <listitem><para>A space-separated list of one or more units to which reload requests from this unit |
815 | shall be propagated to, or units from which reload requests shall be propagated to this unit, | |
816 | respectively. Issuing a reload request on a unit will automatically also enqueue reload requests on | |
817 | all units that are linked to it using these two settings.</para></listitem> | |
818 | </varlistentry> | |
819 | ||
820 | <varlistentry> | |
821 | <term><varname>PropagatesStopTo=</varname></term> | |
822 | <term><varname>StopPropagatedFrom=</varname></term> | |
823 | ||
824 | <listitem><para>A space-separated list of one or more units to which stop requests from this unit | |
825 | shall be propagated to, or units from which stop requests shall be propagated to this unit, | |
826 | respectively. Issuing a stop request on a unit will automatically also enqueue stop requests on all | |
827 | units that are linked to it using these two settings.</para></listitem> | |
798d3a52 ZJS |
828 | </varlistentry> |
829 | ||
830 | <varlistentry> | |
831 | <term><varname>JoinsNamespaceOf=</varname></term> | |
832 | ||
4107452e LP |
833 | <listitem><para>For units that start processes (such as service units), lists one or more other units |
834 | whose network and/or temporary file namespace to join. This only applies to unit types which support | |
a70581ff XR |
835 | the <varname>PrivateNetwork=</varname>, <varname>NetworkNamespacePath=</varname>, |
836 | <varname>PrivateIPC=</varname>, <varname>IPCNamespacePath=</varname>, and | |
798d3a52 | 837 | <varname>PrivateTmp=</varname> directives (see |
4107452e LP |
838 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for |
839 | details). If a unit that has this setting set is started, its processes will see the same | |
a70581ff XR |
840 | <filename>/tmp/</filename>, <filename>/var/tmp/</filename>, IPC namespace and network namespace as |
841 | one listed unit that is started. If multiple listed units are already started, it is not defined | |
842 | which namespace is joined. Note that this setting only has an effect if | |
843 | <varname>PrivateNetwork=</varname>/<varname>NetworkNamespacePath=</varname>, | |
844 | <varname>PrivateIPC=</varname>/<varname>IPCNamespacePath=</varname> and/or | |
4107452e LP |
845 | <varname>PrivateTmp=</varname> is enabled for both the unit that joins the namespace and the unit |
846 | whose namespace is joined.</para></listitem> | |
798d3a52 ZJS |
847 | </varlistentry> |
848 | ||
849 | <varlistentry> | |
850 | <term><varname>RequiresMountsFor=</varname></term> | |
851 | ||
852 | <listitem><para>Takes a space-separated list of absolute | |
853 | paths. Automatically adds dependencies of type | |
854 | <varname>Requires=</varname> and <varname>After=</varname> for | |
855 | all mount units required to access the specified path.</para> | |
856 | ||
857 | <para>Mount points marked with <option>noauto</option> are not | |
88e328fd ZJS |
858 | mounted automatically through <filename>local-fs.target</filename>, |
859 | but are still honored for the purposes of this option, i.e. they | |
860 | will be pulled in by this unit.</para></listitem> | |
798d3a52 ZJS |
861 | </varlistentry> |
862 | ||
863 | <varlistentry> | |
864 | <term><varname>OnFailureJobMode=</varname></term> | |
865 | ||
866 | <listitem><para>Takes a value of | |
867 | <literal>fail</literal>, | |
868 | <literal>replace</literal>, | |
869 | <literal>replace-irreversibly</literal>, | |
870 | <literal>isolate</literal>, | |
871 | <literal>flush</literal>, | |
872 | <literal>ignore-dependencies</literal> or | |
873 | <literal>ignore-requirements</literal>. Defaults to | |
874 | <literal>replace</literal>. Specifies how the units listed in | |
875 | <varname>OnFailure=</varname> will be enqueued. See | |
876 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s | |
877 | <option>--job-mode=</option> option for details on the | |
878 | possible values. If this is set to <literal>isolate</literal>, | |
879 | only a single unit may be listed in | |
e9dd6984 | 880 | <varname>OnFailure=</varname>.</para></listitem> |
798d3a52 ZJS |
881 | </varlistentry> |
882 | ||
883 | <varlistentry> | |
884 | <term><varname>IgnoreOnIsolate=</varname></term> | |
885 | ||
68dd195c LP |
886 | <listitem><para>Takes a boolean argument. If <option>true</option>, this unit will not be stopped |
887 | when isolating another unit. Defaults to <option>false</option> for service, target, socket, timer, | |
888 | and path units, and <option>true</option> for slice, scope, device, swap, mount, and automount | |
889 | units.</para></listitem> | |
798d3a52 ZJS |
890 | </varlistentry> |
891 | ||
798d3a52 ZJS |
892 | <varlistentry> |
893 | <term><varname>StopWhenUnneeded=</varname></term> | |
894 | ||
895 | <listitem><para>Takes a boolean argument. If | |
896 | <option>true</option>, this unit will be stopped when it is no | |
b938cb90 | 897 | longer used. Note that, in order to minimize the work to be |
798d3a52 ZJS |
898 | executed, systemd will not stop units by default unless they |
899 | are conflicting with other units, or the user explicitly | |
900 | requested their shut down. If this option is set, a unit will | |
901 | be automatically cleaned up if no other active unit requires | |
902 | it. Defaults to <option>false</option>.</para></listitem> | |
903 | </varlistentry> | |
904 | ||
905 | <varlistentry> | |
906 | <term><varname>RefuseManualStart=</varname></term> | |
907 | <term><varname>RefuseManualStop=</varname></term> | |
908 | ||
909 | <listitem><para>Takes a boolean argument. If | |
910 | <option>true</option>, this unit can only be activated or | |
911 | deactivated indirectly. In this case, explicit start-up or | |
912 | termination requested by the user is denied, however if it is | |
913 | started or stopped as a dependency of another unit, start-up | |
914 | or termination will succeed. This is mostly a safety feature | |
915 | to ensure that the user does not accidentally activate units | |
916 | that are not intended to be activated explicitly, and not | |
917 | accidentally deactivate units that are not intended to be | |
918 | deactivated. These options default to | |
919 | <option>false</option>.</para></listitem> | |
920 | </varlistentry> | |
921 | ||
922 | <varlistentry> | |
923 | <term><varname>AllowIsolate=</varname></term> | |
924 | ||
925 | <listitem><para>Takes a boolean argument. If | |
926 | <option>true</option>, this unit may be used with the | |
927 | <command>systemctl isolate</command> command. Otherwise, this | |
928 | will be refused. It probably is a good idea to leave this | |
929 | disabled except for target units that shall be used similar to | |
930 | runlevels in SysV init systems, just as a precaution to avoid | |
931 | unusable system states. This option defaults to | |
932 | <option>false</option>.</para></listitem> | |
933 | </varlistentry> | |
934 | ||
935 | <varlistentry> | |
936 | <term><varname>DefaultDependencies=</varname></term> | |
937 | ||
938 | <listitem><para>Takes a boolean argument. If | |
c13fb257 | 939 | <option>yes</option>, (the default), a few default |
798d3a52 ZJS |
940 | dependencies will implicitly be created for the unit. The |
941 | actual dependencies created depend on the unit type. For | |
942 | example, for service units, these dependencies ensure that the | |
943 | service is started only after basic system initialization is | |
944 | completed and is properly terminated on system shutdown. See | |
945 | the respective man pages for details. Generally, only services | |
946 | involved with early boot or late shutdown should set this | |
c13fb257 | 947 | option to <option>no</option>. It is highly recommended to |
798d3a52 | 948 | leave this option enabled for the majority of common units. If |
c13fb257 | 949 | set to <option>no</option>, this option does not disable |
798d3a52 ZJS |
950 | all implicit dependencies, just non-essential |
951 | ones.</para></listitem> | |
952 | </varlistentry> | |
953 | ||
5afe510c LP |
954 | <varlistentry> |
955 | <term><varname>CollectMode=</varname></term> | |
956 | ||
957 | <listitem><para>Tweaks the "garbage collection" algorithm for this unit. Takes one of <option>inactive</option> | |
958 | or <option>inactive-or-failed</option>. If set to <option>inactive</option> the unit will be unloaded if it is | |
959 | in the <constant>inactive</constant> state and is not referenced by clients, jobs or other units — however it | |
960 | is not unloaded if it is in the <constant>failed</constant> state. In <option>failed</option> mode, failed | |
961 | units are not unloaded until the user invoked <command>systemctl reset-failed</command> on them to reset the | |
962 | <constant>failed</constant> state, or an equivalent command. This behaviour is altered if this option is set to | |
963 | <option>inactive-or-failed</option>: in this case the unit is unloaded even if the unit is in a | |
964 | <constant>failed</constant> state, and thus an explicitly resetting of the <constant>failed</constant> state is | |
965 | not necessary. Note that if this mode is used unit results (such as exit codes, exit signals, consumed | |
966 | resources, …) are flushed out immediately after the unit completed, except for what is stored in the logging | |
967 | subsystem. Defaults to <option>inactive</option>.</para> | |
968 | </listitem> | |
969 | </varlistentry> | |
970 | ||
454dd6ce ZJS |
971 | <varlistentry> |
972 | <term><varname>FailureAction=</varname></term> | |
973 | <term><varname>SuccessAction=</varname></term> | |
974 | ||
54fcb619 ZJS |
975 | <listitem><para>Configure the action to take when the unit stops and enters a failed state or inactive state. |
976 | Takes one of <option>none</option>, <option>reboot</option>, <option>reboot-force</option>, | |
977 | <option>reboot-immediate</option>, <option>poweroff</option>, <option>poweroff-force</option>, | |
978 | <option>poweroff-immediate</option>, <option>exit</option>, and <option>exit-force</option>. In system mode, | |
a400bd8c ZJS |
979 | all options are allowed. In user mode, only <option>none</option>, <option>exit</option>, and |
980 | <option>exit-force</option> are allowed. Both options default to <option>none</option>.</para> | |
54fcb619 ZJS |
981 | |
982 | <para>If <option>none</option> is set, no action will be triggered. <option>reboot</option> causes a reboot | |
983 | following the normal shutdown procedure (i.e. equivalent to <command>systemctl reboot</command>). | |
984 | <option>reboot-force</option> causes a forced reboot which will terminate all processes forcibly but should | |
985 | cause no dirty file systems on reboot (i.e. equivalent to <command>systemctl reboot -f</command>) and | |
986 | <option>reboot-immediate</option> causes immediate execution of the | |
454dd6ce | 987 | <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call, which |
6a4e939d LP |
988 | might result in data loss (i.e. equivalent to <command>systemctl reboot -ff</command>). Similarly, |
989 | <option>poweroff</option>, <option>poweroff-force</option>, <option>poweroff-immediate</option> have the effect | |
990 | of powering down the system with similar semantics. <option>exit</option> causes the manager to exit following | |
991 | the normal shutdown procedure, and <option>exit-force</option> causes it terminate without shutting down | |
992 | services. When <option>exit</option> or <option>exit-force</option> is used by default the exit status of the | |
5238e957 | 993 | main process of the unit (if this applies) is returned from the service manager. However, this may be overridden |
6a4e939d LP |
994 | with <varname>FailureActionExitStatus=</varname>/<varname>SuccessActionExitStatus=</varname>, see |
995 | below.</para></listitem> | |
996 | </varlistentry> | |
997 | ||
998 | <varlistentry> | |
999 | <term><varname>FailureActionExitStatus=</varname></term> | |
1000 | <term><varname>SuccessActionExitStatus=</varname></term> | |
1001 | ||
1002 | <listitem><para>Controls the exit status to propagate back to an invoking container manager (in case of a | |
1003 | system service) or service manager (in case of a user manager) when the | |
1004 | <varname>FailureAction=</varname>/<varname>SuccessAction=</varname> are set to <option>exit</option> or | |
1005 | <option>exit-force</option> and the action is triggered. By default the exit status of the main process of the | |
1006 | triggering unit (if this applies) is propagated. Takes a value in the range 0…255 or the empty string to | |
1007 | request default behaviour.</para></listitem> | |
454dd6ce ZJS |
1008 | </varlistentry> |
1009 | ||
798d3a52 ZJS |
1010 | <varlistentry> |
1011 | <term><varname>JobTimeoutSec=</varname></term> | |
a2df3ea4 | 1012 | <term><varname>JobRunningTimeoutSec=</varname></term> |
798d3a52 | 1013 | |
fc070a25 ZJS |
1014 | <listitem><para><varname>JobTimeoutSec=</varname> specifies a timeout for the whole job that starts |
1015 | running when the job is queued. <varname>JobRunningTimeoutSec=</varname> specifies a timeout that | |
1016 | starts running when the queued job is actually started. If either limit is reached, the job will be | |
1017 | cancelled, the unit however will not change state or even enter the <literal>failed</literal> mode. | |
1018 | </para> | |
1019 | ||
1020 | <para>Both settings take a time span with the default unit of seconds, but other units may be | |
1021 | specified, see | |
1022 | <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
1023 | The default is <literal>infinity</literal> (job timeouts disabled), except for device units where | |
1024 | <varname>JobRunningTimeoutSec=</varname> defaults to <varname>DefaultTimeoutStartSec=</varname>. | |
1025 | </para> | |
1026 | ||
1027 | <para>Note: these timeouts are independent from any unit-specific timeouts (for example, the timeout | |
1028 | set with <varname>TimeoutStartSec=</varname> in service units). The job timeout has no effect on the | |
1029 | unit itself. Or in other words: unit-specific timeouts are useful to abort unit state changes, and | |
1030 | revert them. The job timeout set with this option however is useful to abort only the job waiting for | |
1031 | the unit state to change.</para> | |
de597248 ZJS |
1032 | </listitem> |
1033 | </varlistentry> | |
1034 | ||
1035 | <varlistentry> | |
1036 | <term><varname>JobTimeoutAction=</varname></term> | |
1037 | <term><varname>JobTimeoutRebootArgument=</varname></term> | |
798d3a52 | 1038 | |
fc070a25 ZJS |
1039 | <listitem><para><varname>JobTimeoutAction=</varname> optionally configures an additional action to |
1040 | take when the timeout is hit, see description of <varname>JobTimeoutSec=</varname> and | |
de597248 | 1041 | <varname>JobRunningTimeoutSec=</varname> above. It takes the same values as |
fc070a25 ZJS |
1042 | <varname>StartLimitAction=</varname>. Defaults to <option>none</option>.</para> |
1043 | ||
1044 | <para><varname>JobTimeoutRebootArgument=</varname> configures an optional reboot string to pass to | |
1045 | the <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system | |
1046 | call.</para></listitem> | |
798d3a52 ZJS |
1047 | </varlistentry> |
1048 | ||
6bf0f408 | 1049 | <varlistentry> |
fc5ffacd ZJS |
1050 | <term><varname>StartLimitIntervalSec=<replaceable>interval</replaceable></varname></term> |
1051 | <term><varname>StartLimitBurst=<replaceable>burst</replaceable></varname></term> | |
6bf0f408 | 1052 | |
fc5ffacd | 1053 | <listitem><para>Configure unit start rate limiting. Units which are started more than |
fc070a25 ZJS |
1054 | <replaceable>burst</replaceable> times within an <replaceable>interval</replaceable> time span are |
1055 | not permitted to start any more. Use <varname>StartLimitIntervalSec=</varname> to configure the | |
1056 | checking interval and <varname>StartLimitBurst=</varname> to configure how many starts per interval | |
1057 | are allowed.</para> | |
1058 | ||
1059 | <para><replaceable>interval</replaceable> is a time span with the default unit of seconds, but other | |
1060 | units may be specified, see | |
1061 | <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
1062 | Defaults to <varname>DefaultStartLimitIntervalSec=</varname> in manager configuration file, and may | |
1063 | be set to 0 to disable any kind of rate limiting. <replaceable>burst</replaceable> is a number and | |
1064 | defaults to <varname>DefaultStartLimitBurst=</varname> in manager configuration file.</para> | |
1065 | ||
1066 | <para>These configuration options are particularly useful in conjunction with the service setting | |
b94f4313 | 1067 | <varname>Restart=</varname> (see |
fc070a25 ZJS |
1068 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>); |
1069 | however, they apply to all kinds of starts (including manual), not just those triggered by the | |
1070 | <varname>Restart=</varname> logic.</para> | |
1071 | ||
1072 | <para>Note that units which are configured for <varname>Restart=</varname>, and which reach the start | |
3babb816 CH |
1073 | limit are not attempted to be restarted anymore; however, they may still be restarted manually or |
1074 | from a timer or socket at a later point, after the <replaceable>interval</replaceable> has passed. | |
1075 | From that point on, the restart logic is activated again. <command>systemctl reset-failed</command> | |
1076 | will cause the restart rate counter for a service to be flushed, which is useful if the administrator | |
1077 | wants to manually start a unit and the start limit interferes with that. Rate-limiting is enforced | |
1078 | after any unit condition checks are executed, and hence unit activations with failing conditions do | |
1079 | not count towards the rate limit.</para> | |
fc070a25 ZJS |
1080 | |
1081 | <para>When a unit is unloaded due to the garbage collection logic (see above) its rate limit counters | |
1082 | are flushed out too. This means that configuring start rate limiting for a unit that is not | |
1083 | referenced continuously has no effect.</para> | |
1084 | ||
1085 | <para>This setting does not apply to slice, target, device, and scope units, since they are unit | |
1086 | types whose activation may either never fail, or may succeed only a single time.</para></listitem> | |
6bf0f408 LP |
1087 | </varlistentry> |
1088 | ||
1089 | <varlistentry> | |
1090 | <term><varname>StartLimitAction=</varname></term> | |
1091 | ||
454dd6ce | 1092 | <listitem><para>Configure an additional action to take if the rate limit configured with |
e9dd6984 ZJS |
1093 | <varname>StartLimitIntervalSec=</varname> and <varname>StartLimitBurst=</varname> is hit. Takes the same |
1094 | values as the <varname>FailureAction=</varname>/<varname>SuccessAction=</varname> settings. If | |
1095 | <option>none</option> is set, hitting the rate limit will trigger no action except that | |
454dd6ce | 1096 | the start will not be permitted. Defaults to <option>none</option>.</para></listitem> |
6bf0f408 LP |
1097 | </varlistentry> |
1098 | ||
1099 | <varlistentry> | |
1100 | <term><varname>RebootArgument=</varname></term> | |
1101 | <listitem><para>Configure the optional argument for the | |
1102 | <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call if | |
53c35a76 | 1103 | <varname>StartLimitAction=</varname> or <varname>FailureAction=</varname> is a reboot action. This |
6bf0f408 LP |
1104 | works just like the optional argument to <command>systemctl reboot</command> command.</para></listitem> |
1105 | </varlistentry> | |
1106 | ||
798d3a52 ZJS |
1107 | <varlistentry> |
1108 | <term><varname>SourcePath=</varname></term> | |
1109 | <listitem><para>A path to a configuration file this unit has | |
1110 | been generated from. This is primarily useful for | |
1111 | implementation of generator tools that convert configuration | |
1112 | from an external configuration file format into native unit | |
1113 | files. This functionality should not be used in normal | |
1114 | units.</para></listitem> | |
1115 | </varlistentry> | |
1116 | </variablelist> | |
337b7334 ZJS |
1117 | |
1118 | <refsect2> | |
1119 | <title>Conditions and Asserts</title> | |
1120 | ||
0a6aa7a2 LP |
1121 | <para>Unit files may also include a number of <varname index="false">Condition…=</varname> and <varname |
1122 | index="false">Assert…=</varname> settings. Before the unit is started, systemd will verify that the | |
1123 | specified conditions and asserts are true. If not, the starting of the unit will be (mostly silently) | |
1124 | skipped (in case of conditions), or aborted with an error message (in case of asserts). Failing | |
1125 | conditions or asserts will not result in the unit being moved into the <literal>failed</literal> | |
1126 | state. The conditions and asserts are checked at the time the queued start job is to be executed. The | |
1127 | ordering dependencies are still respected, so other units are still pulled in and ordered as if this | |
1128 | unit was successfully activated, and the conditions and asserts are executed the precise moment the | |
1129 | unit would normally start and thus can validate system state after the units ordered before completed | |
1130 | initialization. Use condition expressions for skipping units that do not apply to the local system, for | |
1131 | example because the kernel or runtime environment doesn't require their functionality. | |
337b7334 ZJS |
1132 | </para> |
1133 | ||
1134 | <para>If multiple conditions are specified, the unit will be executed if all of them apply (i.e. a | |
54166cee | 1135 | logical AND is applied). Condition checks can use a pipe symbol (<literal>|</literal>) after the equals |
0a6aa7a2 LP |
1136 | sign (<literal>Condition…=|…</literal>), which causes the condition to become a |
1137 | <emphasis>triggering</emphasis> condition. If at least one triggering condition is defined for a unit, | |
1138 | then the unit will be started if at least one of the triggering conditions of the unit applies and all | |
1139 | of the regular (i.e. non-triggering) conditions apply. If you prefix an argument with the pipe symbol | |
1140 | and an exclamation mark, the pipe symbol must be passed first, the exclamation second. If any of these | |
1141 | options is assigned the empty string, the list of conditions is reset completely, all previous | |
1142 | condition settings (of any kind) will have no effect.</para> | |
337b7334 ZJS |
1143 | |
1144 | <para>The <varname>AssertArchitecture=</varname>, <varname>AssertVirtualization=</varname>, … options | |
0a6aa7a2 LP |
1145 | are similar to conditions but cause the start job to fail (instead of being skipped). The failed check |
1146 | is logged. Units with failed conditions are considered to be in a clean state and will be garbage | |
337b7334 ZJS |
1147 | collected if they are not referenced. This means that when queried, the condition failure may or may |
1148 | not show up in the state of the unit.</para> | |
1149 | ||
1150 | <para>Note that neither assertion nor condition expressions result in unit state changes. Also note | |
1151 | that both are checked at the time the job is to be executed, i.e. long after depending jobs and it | |
1152 | itself were queued. Thus, neither condition nor assertion expressions are suitable for conditionalizing | |
1153 | unit dependencies.</para> | |
1154 | ||
1155 | <para>The <command>condition</command> verb of | |
1156 | <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry> can | |
1157 | be used to test condition and assert expressions.</para> | |
1158 | ||
1159 | <para>Except for <varname>ConditionPathIsSymbolicLink=</varname>, all path checks follow symlinks.</para> | |
1160 | ||
1161 | <variablelist class='unit-directives'> | |
337b7334 ZJS |
1162 | <varlistentry> |
1163 | <term><varname>ConditionArchitecture=</varname></term> | |
1164 | ||
1165 | <listitem><para>Check whether the system is running on a specific architecture. Takes one of | |
1166 | <literal>x86</literal>, | |
1167 | <literal>x86-64</literal>, | |
1168 | <literal>ppc</literal>, | |
1169 | <literal>ppc-le</literal>, | |
1170 | <literal>ppc64</literal>, | |
1171 | <literal>ppc64-le</literal>, | |
1172 | <literal>ia64</literal>, | |
1173 | <literal>parisc</literal>, | |
1174 | <literal>parisc64</literal>, | |
1175 | <literal>s390</literal>, | |
1176 | <literal>s390x</literal>, | |
1177 | <literal>sparc</literal>, | |
1178 | <literal>sparc64</literal>, | |
1179 | <literal>mips</literal>, | |
1180 | <literal>mips-le</literal>, | |
1181 | <literal>mips64</literal>, | |
1182 | <literal>mips64-le</literal>, | |
1183 | <literal>alpha</literal>, | |
1184 | <literal>arm</literal>, | |
1185 | <literal>arm-be</literal>, | |
1186 | <literal>arm64</literal>, | |
1187 | <literal>arm64-be</literal>, | |
1188 | <literal>sh</literal>, | |
1189 | <literal>sh64</literal>, | |
1190 | <literal>m68k</literal>, | |
1191 | <literal>tilegx</literal>, | |
1192 | <literal>cris</literal>, | |
1193 | <literal>arc</literal>, | |
1194 | <literal>arc-be</literal>, or | |
1195 | <literal>native</literal>.</para> | |
1196 | ||
1197 | <para>The architecture is determined from the information returned by | |
1198 | <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry> | |
1199 | and is thus subject to | |
1200 | <citerefentry><refentrytitle>personality</refentrytitle><manvolnum>2</manvolnum></citerefentry>. | |
1201 | Note that a <varname>Personality=</varname> setting in the same unit file has no effect on this | |
1202 | condition. A special architecture name <literal>native</literal> is mapped to the architecture the | |
1203 | system manager itself is compiled for. The test may be negated by prepending an exclamation | |
1204 | mark.</para> | |
1205 | </listitem> | |
1206 | </varlistentry> | |
1207 | ||
cbcdcaaa UKK |
1208 | <varlistentry> |
1209 | <term><varname>ConditionFirmware=</varname></term> | |
1210 | ||
1211 | <listitem><para>Check whether the system's firmware is of a certain type. Possible values are: | |
1212 | <literal>uefi</literal> (for systems with EFI), | |
1213 | <literal>device-tree</literal> (for systems with a device tree) and | |
1214 | <literal>device-tree-compatible(xyz)</literal> (for systems with a device tree that is compatible to <literal>xyz</literal>).</para> | |
1215 | </listitem> | |
1216 | </varlistentry> | |
1217 | ||
337b7334 | 1218 | <varlistentry> |
81a41081 | 1219 | <term><varname>ConditionVirtualization=</varname></term> |
337b7334 ZJS |
1220 | |
1221 | <listitem><para>Check whether the system is executed in a virtualized environment and optionally | |
1222 | test whether it is a specific implementation. Takes either boolean value to check if being executed | |
1223 | in any virtualized environment, or one of | |
1224 | <literal>vm</literal> and | |
1225 | <literal>container</literal> to test against a generic type of virtualization solution, or one of | |
1226 | <literal>qemu</literal>, | |
1227 | <literal>kvm</literal>, | |
b6eca373 | 1228 | <literal>amazon</literal>, |
337b7334 ZJS |
1229 | <literal>zvm</literal>, |
1230 | <literal>vmware</literal>, | |
1231 | <literal>microsoft</literal>, | |
1232 | <literal>oracle</literal>, | |
3224e38b | 1233 | <literal>powervm</literal>, |
337b7334 ZJS |
1234 | <literal>xen</literal>, |
1235 | <literal>bochs</literal>, | |
1236 | <literal>uml</literal>, | |
1237 | <literal>bhyve</literal>, | |
1238 | <literal>qnx</literal>, | |
1239 | <literal>openvz</literal>, | |
1240 | <literal>lxc</literal>, | |
1241 | <literal>lxc-libvirt</literal>, | |
1242 | <literal>systemd-nspawn</literal>, | |
1243 | <literal>docker</literal>, | |
1244 | <literal>podman</literal>, | |
1245 | <literal>rkt</literal>, | |
1246 | <literal>wsl</literal>, | |
80cc3e3e | 1247 | <literal>proot</literal>, |
abac810b | 1248 | <literal>pouch</literal>, |
337b7334 ZJS |
1249 | <literal>acrn</literal> to test |
1250 | against a specific implementation, or | |
1251 | <literal>private-users</literal> to check whether we are running in a user namespace. See | |
1252 | <citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
1253 | for a full list of known virtualization technologies and their identifiers. If multiple | |
1254 | virtualization technologies are nested, only the innermost is considered. The test may be negated | |
1255 | by prepending an exclamation mark.</para> | |
1256 | </listitem> | |
1257 | </varlistentry> | |
1258 | ||
1259 | <varlistentry> | |
1260 | <term><varname>ConditionHost=</varname></term> | |
1261 | ||
1262 | <listitem><para><varname>ConditionHost=</varname> may be used to match against the hostname or | |
1263 | machine ID of the host. This either takes a hostname string (optionally with shell style globs) | |
1264 | which is tested against the locally set hostname as returned by | |
1265 | <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>, or | |
1266 | a machine ID formatted as string (see | |
1267 | <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>). | |
1268 | The test may be negated by prepending an exclamation mark.</para> | |
1269 | </listitem> | |
1270 | </varlistentry> | |
1271 | ||
1272 | <varlistentry> | |
1273 | <term><varname>ConditionKernelCommandLine=</varname></term> | |
1274 | ||
1275 | <listitem><para><varname>ConditionKernelCommandLine=</varname> may be used to check whether a | |
1276 | specific kernel command line option is set (or if prefixed with the exclamation mark — unset). The | |
1277 | argument must either be a single word, or an assignment (i.e. two words, separated by | |
1278 | <literal>=</literal>). In the former case the kernel command line is searched for the word | |
1279 | appearing as is, or as left hand side of an assignment. In the latter case, the exact assignment is | |
af4b8f80 LP |
1280 | looked for with right and left hand side matching. This operates on the kernel command line |
1281 | communicated to userspace via <filename>/proc/cmdline</filename>, except when the service manager | |
1282 | is invoked as payload of a container manager, in which case the command line of <filename>PID | |
1283 | 1</filename> is used instead (i.e. <filename>/proc/1/cmdline</filename>).</para> | |
337b7334 ZJS |
1284 | </listitem> |
1285 | </varlistentry> | |
1286 | ||
1287 | <varlistentry> | |
1288 | <term><varname>ConditionKernelVersion=</varname></term> | |
1289 | ||
1290 | <listitem><para><varname>ConditionKernelVersion=</varname> may be used to check whether the kernel | |
1291 | version (as reported by <command>uname -r</command>) matches a certain expression (or if prefixed | |
1292 | with the exclamation mark does not match it). The argument must be a list of (potentially quoted) | |
1293 | expressions. For each of the expressions, if it starts with one of <literal><</literal>, | |
1294 | <literal><=</literal>, <literal>=</literal>, <literal>!=</literal>, <literal>>=</literal>, | |
1295 | <literal>></literal> a relative version comparison is done, otherwise the specified string is | |
1296 | matched with shell-style globs.</para> | |
1297 | ||
1298 | <para>Note that using the kernel version string is an unreliable way to determine which features | |
1299 | are supported by a kernel, because of the widespread practice of backporting drivers, features, and | |
1300 | fixes from newer upstream kernels into older versions provided by distributions. Hence, this check | |
1301 | is inherently unportable and should not be used for units which may be used on different | |
1302 | distributions.</para> | |
1303 | </listitem> | |
1304 | </varlistentry> | |
1305 | ||
410abf83 LP |
1306 | <varlistentry> |
1307 | <term><varname>ConditionEnvironment=</varname></term> | |
1308 | ||
1309 | <listitem><para><varname>ConditionEnvironment=</varname> may be used to check whether a specific | |
1310 | environment variable is set (or if prefixed with the exclamation mark — unset) in the service | |
1311 | manager's environment block. | |
1312 | ||
1313 | The argument may be a single word, to check if the variable with this name is defined in the | |
1314 | environment block, or an assignment | |
1315 | (<literal><replaceable>name</replaceable>=<replaceable>value</replaceable></literal>), to check if | |
1316 | the variable with this exact value is defined. Note that the environment block of the service | |
1317 | manager itself is checked, i.e. not any variables defined with <varname>Environment=</varname> or | |
1318 | <varname>EnvironmentFile=</varname>, as described above. This is particularly useful when the | |
1319 | service manager runs inside a containerized environment or as per-user service manager, in order to | |
1320 | check for variables passed in by the enclosing container manager or PAM.</para> | |
1321 | </listitem> | |
1322 | </varlistentry> | |
1323 | ||
337b7334 ZJS |
1324 | <varlistentry> |
1325 | <term><varname>ConditionSecurity=</varname></term> | |
1326 | ||
1327 | <listitem><para><varname>ConditionSecurity=</varname> may be used to check whether the given | |
1328 | security technology is enabled on the system. Currently, the recognized values are | |
1329 | <literal>selinux</literal>, <literal>apparmor</literal>, <literal>tomoyo</literal>, | |
bce334a3 LP |
1330 | <literal>ima</literal>, <literal>smack</literal>, <literal>audit</literal>, |
1331 | <literal>uefi-secureboot</literal> and <literal>tpm2</literal>. The test may be negated by prepending | |
1332 | an exclamation mark.</para> | |
337b7334 ZJS |
1333 | </listitem> |
1334 | </varlistentry> | |
1335 | ||
1336 | <varlistentry> | |
1337 | <term><varname>ConditionCapability=</varname></term> | |
1338 | ||
1339 | <listitem><para>Check whether the given capability exists in the capability bounding set of the | |
1340 | service manager (i.e. this does not check whether capability is actually available in the permitted | |
1341 | or effective sets, see | |
1342 | <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
1343 | for details). Pass a capability name such as <literal>CAP_MKNOD</literal>, possibly prefixed with | |
1344 | an exclamation mark to negate the check.</para> | |
1345 | </listitem> | |
1346 | </varlistentry> | |
1347 | ||
1348 | <varlistentry> | |
1349 | <term><varname>ConditionACPower=</varname></term> | |
1350 | ||
1351 | <listitem><para>Check whether the system has AC power, or is exclusively battery powered at the | |
1352 | time of activation of the unit. This takes a boolean argument. If set to <literal>true</literal>, | |
1353 | the condition will hold only if at least one AC connector of the system is connected to a power | |
1354 | source, or if no AC connectors are known. Conversely, if set to <literal>false</literal>, the | |
1355 | condition will hold only if there is at least one AC connector known and all AC connectors are | |
1356 | disconnected from a power source.</para> | |
1357 | </listitem> | |
1358 | </varlistentry> | |
1359 | ||
1360 | <varlistentry> | |
1361 | <term><varname>ConditionNeedsUpdate=</varname></term> | |
1362 | ||
3b121157 | 1363 | <listitem><para>Takes one of <filename>/var/</filename> or <filename>/etc/</filename> as argument, |
bf1abf1a | 1364 | possibly prefixed with a <literal>!</literal> (to invert the condition). This condition may be |
337b7334 | 1365 | used to conditionalize units on whether the specified directory requires an update because |
3b121157 | 1366 | <filename>/usr/</filename>'s modification time is newer than the stamp file |
337b7334 | 1367 | <filename>.updated</filename> in the specified directory. This is useful to implement offline |
3b121157 ZJS |
1368 | updates of the vendor operating system resources in <filename>/usr/</filename> that require updating |
1369 | of <filename>/etc/</filename> or <filename>/var/</filename> on the next following boot. Units making | |
337b7334 ZJS |
1370 | use of this condition should order themselves before |
1371 | <citerefentry><refentrytitle>systemd-update-done.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, | |
1372 | to make sure they run before the stamp file's modification time gets reset indicating a completed | |
1373 | update.</para> | |
f8b4ae29 LP |
1374 | |
1375 | <para>If the <varname>systemd.condition-needs-update=</varname> option is specified on the kernel | |
1376 | command line (taking a boolean), it will override the result of this condition check, taking | |
1377 | precedence over any file modification time checks. If it is used | |
1378 | <filename>systemd-update-done.service</filename> will not have immediate effect on any following | |
1379 | <varname>ConditionNeedsUpdate=</varname> checks, until the system is rebooted where the kernel | |
1380 | command line option is not specified anymore.</para> | |
337b7334 ZJS |
1381 | </listitem> |
1382 | </varlistentry> | |
1383 | ||
1384 | <varlistentry> | |
1385 | <term><varname>ConditionFirstBoot=</varname></term> | |
1386 | ||
1387 | <listitem><para>Takes a boolean argument. This condition may be used to conditionalize units on | |
a48627ef HS |
1388 | whether the system is booting up for the first time. This roughly means that <filename>/etc/</filename> |
1389 | is unpopulated (for details, see "First Boot Semantics" in | |
1390 | <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>). | |
1391 | This may be used to populate <filename>/etc/</filename> on the first boot after factory reset, or | |
1392 | when a new system instance boots up for the first time.</para> | |
1393 | ||
1394 | <para>For robustness, units with <varname>ConditionFirstBoot=yes</varname> should order themselves | |
1395 | before <filename>first-boot-complete.target</filename> and pull in this passive target with | |
1396 | <varname>Wants=</varname>. This ensures that in a case of an aborted first boot, these units will | |
1397 | be re-run during the next system startup.</para> | |
814872e9 LP |
1398 | |
1399 | <para>If the <varname>systemd.condition-first-boot=</varname> option is specified on the kernel | |
1400 | command line (taking a boolean), it will override the result of this condition check, taking | |
1401 | precedence over <filename>/etc/machine-id</filename> existence checks.</para> | |
337b7334 ZJS |
1402 | </listitem> |
1403 | </varlistentry> | |
1404 | ||
1405 | <varlistentry> | |
1406 | <term><varname>ConditionPathExists=</varname></term> | |
1407 | ||
d0fd1149 | 1408 | <listitem><para>Check for the existence of a file. If the specified absolute path name does not exist, |
337b7334 ZJS |
1409 | the condition will fail. If the absolute path name passed to |
1410 | <varname>ConditionPathExists=</varname> is prefixed with an exclamation mark | |
1411 | (<literal>!</literal>), the test is negated, and the unit is only started if the path does not | |
1412 | exist.</para> | |
1413 | </listitem> | |
1414 | </varlistentry> | |
1415 | ||
1416 | <varlistentry> | |
1417 | <term><varname>ConditionPathExistsGlob=</varname></term> | |
1418 | ||
1419 | <listitem><para><varname>ConditionPathExistsGlob=</varname> is similar to | |
1420 | <varname>ConditionPathExists=</varname>, but checks for the existence of at least one file or | |
1421 | directory matching the specified globbing pattern.</para> | |
1422 | </listitem> | |
1423 | </varlistentry> | |
1424 | ||
1425 | <varlistentry> | |
1426 | <term><varname>ConditionPathIsDirectory=</varname></term> | |
1427 | ||
1428 | <listitem><para><varname>ConditionPathIsDirectory=</varname> is similar to | |
1429 | <varname>ConditionPathExists=</varname> but verifies that a certain path exists and is a | |
1430 | directory.</para> | |
1431 | </listitem> | |
1432 | </varlistentry> | |
1433 | ||
1434 | <varlistentry> | |
1435 | <term><varname>ConditionPathIsSymbolicLink=</varname></term> | |
1436 | ||
1437 | <listitem><para><varname>ConditionPathIsSymbolicLink=</varname> is similar to | |
1438 | <varname>ConditionPathExists=</varname> but verifies that a certain path exists and is a symbolic | |
1439 | link.</para> | |
1440 | </listitem> | |
1441 | </varlistentry> | |
1442 | ||
1443 | <varlistentry> | |
1444 | <term><varname>ConditionPathIsMountPoint=</varname></term> | |
1445 | ||
1446 | <listitem><para><varname>ConditionPathIsMountPoint=</varname> is similar to | |
1447 | <varname>ConditionPathExists=</varname> but verifies that a certain path exists and is a mount | |
1448 | point.</para> | |
1449 | </listitem> | |
1450 | </varlistentry> | |
1451 | ||
1452 | <varlistentry> | |
1453 | <term><varname>ConditionPathIsReadWrite=</varname></term> | |
1454 | ||
1455 | <listitem><para><varname>ConditionPathIsReadWrite=</varname> is similar to | |
1456 | <varname>ConditionPathExists=</varname> but verifies that the underlying file system is readable | |
1457 | and writable (i.e. not mounted read-only).</para> | |
1458 | </listitem> | |
1459 | </varlistentry> | |
1460 | ||
410abf83 LP |
1461 | <varlistentry> |
1462 | <term><varname>ConditionPathIsEncrypted=</varname></term> | |
1463 | ||
1464 | <listitem><para><varname>ConditionPathIsEncrypted=</varname> is similar to | |
1465 | <varname>ConditionPathExists=</varname> but verifies that the underlying file system's backing | |
1466 | block device is encrypted using dm-crypt/LUKS. Note that this check does not cover ext4 | |
1467 | per-directory encryption, and only detects block level encryption. Moreover, if the specified path | |
1468 | resides on a file system on top of a loopback block device, only encryption above the loopback device is | |
1469 | detected. It is not detected whether the file system backing the loopback block device is encrypted.</para> | |
1470 | </listitem> | |
1471 | </varlistentry> | |
1472 | ||
337b7334 ZJS |
1473 | <varlistentry> |
1474 | <term><varname>ConditionDirectoryNotEmpty=</varname></term> | |
1475 | ||
1476 | <listitem><para><varname>ConditionDirectoryNotEmpty=</varname> is similar to | |
1477 | <varname>ConditionPathExists=</varname> but verifies that a certain path exists and is a non-empty | |
1478 | directory.</para> | |
1479 | </listitem> | |
1480 | </varlistentry> | |
1481 | ||
1482 | <varlistentry> | |
1483 | <term><varname>ConditionFileNotEmpty=</varname></term> | |
1484 | ||
1485 | <listitem><para><varname>ConditionFileNotEmpty=</varname> is similar to | |
1486 | <varname>ConditionPathExists=</varname> but verifies that a certain path exists and refers to a | |
1487 | regular file with a non-zero size.</para> | |
1488 | </listitem> | |
1489 | </varlistentry> | |
1490 | ||
1491 | <varlistentry> | |
1492 | <term><varname>ConditionFileIsExecutable=</varname></term> | |
1493 | ||
1494 | <listitem><para><varname>ConditionFileIsExecutable=</varname> is similar to | |
1495 | <varname>ConditionPathExists=</varname> but verifies that a certain path exists, is a regular file, | |
1496 | and marked executable.</para> | |
1497 | </listitem> | |
1498 | </varlistentry> | |
1499 | ||
1500 | <varlistentry> | |
1501 | <term><varname>ConditionUser=</varname></term> | |
1502 | ||
1503 | <listitem><para><varname>ConditionUser=</varname> takes a numeric <literal>UID</literal>, a UNIX | |
1504 | user name, or the special value <literal>@system</literal>. This condition may be used to check | |
1505 | whether the service manager is running as the given user. The special value | |
1506 | <literal>@system</literal> can be used to check if the user id is within the system user | |
1507 | range. This option is not useful for system services, as the system manager exclusively runs as the | |
1508 | root user, and thus the test result is constant.</para> | |
1509 | </listitem> | |
1510 | </varlistentry> | |
1511 | ||
1512 | <varlistentry> | |
1513 | <term><varname>ConditionGroup=</varname></term> | |
1514 | ||
1515 | <listitem><para><varname>ConditionGroup=</varname> is similar to <varname>ConditionUser=</varname> | |
1516 | but verifies that the service manager's real or effective group, or any of its auxiliary groups, | |
1517 | match the specified group or GID. This setting does not support the special value | |
1518 | <literal>@system</literal>.</para> | |
1519 | </listitem> | |
1520 | </varlistentry> | |
1521 | ||
1522 | <varlistentry> | |
1523 | <term><varname>ConditionControlGroupController=</varname></term> | |
1524 | ||
8ebfd50a ZJS |
1525 | <listitem><para>Check whether given cgroup controllers (eg. <literal>cpu</literal>) are available |
1526 | for use on the system or whether the legacy v1 cgroup or the modern v2 cgroup hierarchy is used. | |
1527 | </para> | |
1528 | ||
1529 | <para>Multiple controllers may be passed with a space separating them; in this case the condition | |
1530 | will only pass if all listed controllers are available for use. Controllers unknown to systemd are | |
1531 | ignored. Valid controllers are <literal>cpu</literal>, <literal>cpuacct</literal>, | |
1532 | <literal>io</literal>, <literal>blkio</literal>, <literal>memory</literal>, | |
1533 | <literal>devices</literal>, and <literal>pids</literal>. Even if available in the kernel, a | |
1534 | particular controller may not be available if it was disabled on the kernel command line with | |
1535 | <varname>cgroup_disable=controller</varname>.</para> | |
1536 | ||
1537 | <para>Alternatively, two special strings <literal>v1</literal> and <literal>v2</literal> may be | |
1538 | specified (without any controller names). <literal>v2</literal> will pass if the unified v2 cgroup | |
b49bb286 | 1539 | hierarchy is used, and <literal>v1</literal> will pass if the legacy v1 hierarchy or the hybrid |
8ebfd50a ZJS |
1540 | hierarchy are used (see the discussion of <varname>systemd.unified_cgroup_hierarchy</varname> and |
1541 | <varname>systemd.legacy_systemd_cgroup_controller</varname> in | |
1542 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
1543 | for more information).</para> | |
337b7334 ZJS |
1544 | </listitem> |
1545 | </varlistentry> | |
1546 | ||
1547 | <varlistentry> | |
1548 | <term><varname>ConditionMemory=</varname></term> | |
1549 | ||
1550 | <listitem><para>Verify that the specified amount of system memory is available to the current | |
1551 | system. Takes a memory size in bytes as argument, optionally prefixed with a comparison operator | |
1552 | <literal><</literal>, <literal><=</literal>, <literal>=</literal>, <literal>!=</literal>, | |
1553 | <literal>>=</literal>, <literal>></literal>. On bare-metal systems compares the amount of | |
1554 | physical memory in the system with the specified size, adhering to the specified comparison | |
1555 | operator. In containers compares the amount of memory assigned to the container instead.</para> | |
1556 | </listitem> | |
1557 | </varlistentry> | |
1558 | ||
1559 | <varlistentry> | |
1560 | <term><varname>ConditionCPUs=</varname></term> | |
1561 | ||
1562 | <listitem><para>Verify that the specified number of CPUs is available to the current system. Takes | |
1563 | a number of CPUs as argument, optionally prefixed with a comparison operator | |
1564 | <literal><</literal>, <literal><=</literal>, <literal>=</literal>, <literal>!=</literal>, | |
1565 | <literal>>=</literal>, <literal>></literal>. Compares the number of CPUs in the CPU affinity | |
1566 | mask configured of the service manager itself with the specified number, adhering to the specified | |
1567 | comparison operator. On physical systems the number of CPUs in the affinity mask of the service | |
1568 | manager usually matches the number of physical CPUs, but in special and virtual environments might | |
1569 | differ. In particular, in containers the affinity mask usually matches the number of CPUs assigned | |
1570 | to the container and not the physically available ones.</para></listitem> | |
1571 | </varlistentry> | |
1572 | ||
68337e55 GS |
1573 | <varlistentry> |
1574 | <term><varname>ConditionCPUFeature=</varname></term> | |
1575 | ||
1576 | <listitem><para>Verify that a given CPU feature is available via the <literal>CPUID</literal> | |
1577 | instruction. This condition only does something on i386 and x86-64 processors. On other | |
1578 | processors it is assumed that the CPU does not support the given feature. It checks the leaves | |
1579 | <literal>1</literal>, <literal>7</literal>, <literal>0x80000001</literal>, and | |
1580 | <literal>0x80000007</literal>. Valid values are: | |
1581 | <literal>fpu</literal>, | |
1582 | <literal>vme</literal>, | |
1583 | <literal>de</literal>, | |
1584 | <literal>pse</literal>, | |
1585 | <literal>tsc</literal>, | |
1586 | <literal>msr</literal>, | |
1587 | <literal>pae</literal>, | |
1588 | <literal>mce</literal>, | |
1589 | <literal>cx8</literal>, | |
1590 | <literal>apic</literal>, | |
1591 | <literal>sep</literal>, | |
1592 | <literal>mtrr</literal>, | |
1593 | <literal>pge</literal>, | |
1594 | <literal>mca</literal>, | |
1595 | <literal>cmov</literal>, | |
1596 | <literal>pat</literal>, | |
1597 | <literal>pse36</literal>, | |
1598 | <literal>clflush</literal>, | |
1599 | <literal>mmx</literal>, | |
1600 | <literal>fxsr</literal>, | |
1601 | <literal>sse</literal>, | |
1602 | <literal>sse2</literal>, | |
1603 | <literal>ht</literal>, | |
1604 | <literal>pni</literal>, | |
1605 | <literal>pclmul</literal>, | |
1606 | <literal>monitor</literal>, | |
1607 | <literal>ssse3</literal>, | |
1608 | <literal>fma3</literal>, | |
1609 | <literal>cx16</literal>, | |
1610 | <literal>sse4_1</literal>, | |
1611 | <literal>sse4_2</literal>, | |
1612 | <literal>movbe</literal>, | |
1613 | <literal>popcnt</literal>, | |
1614 | <literal>aes</literal>, | |
1615 | <literal>xsave</literal>, | |
1616 | <literal>osxsave</literal>, | |
1617 | <literal>avx</literal>, | |
1618 | <literal>f16c</literal>, | |
1619 | <literal>rdrand</literal>, | |
1620 | <literal>bmi1</literal>, | |
1621 | <literal>avx2</literal>, | |
1622 | <literal>bmi2</literal>, | |
1623 | <literal>rdseed</literal>, | |
1624 | <literal>adx</literal>, | |
1625 | <literal>sha_ni</literal>, | |
1626 | <literal>syscall</literal>, | |
1627 | <literal>rdtscp</literal>, | |
1628 | <literal>lm</literal>, | |
1629 | <literal>lahf_lm</literal>, | |
1630 | <literal>abm</literal>, | |
1631 | <literal>constant_tsc</literal>.</para> | |
1632 | </listitem> | |
1633 | </varlistentry> | |
1634 | ||
337b7334 ZJS |
1635 | <varlistentry> |
1636 | <term><varname>AssertArchitecture=</varname></term> | |
1637 | <term><varname>AssertVirtualization=</varname></term> | |
1638 | <term><varname>AssertHost=</varname></term> | |
1639 | <term><varname>AssertKernelCommandLine=</varname></term> | |
1640 | <term><varname>AssertKernelVersion=</varname></term> | |
7d27d39a | 1641 | <term><varname>AssertEnvironment=</varname></term> |
337b7334 ZJS |
1642 | <term><varname>AssertSecurity=</varname></term> |
1643 | <term><varname>AssertCapability=</varname></term> | |
1644 | <term><varname>AssertACPower=</varname></term> | |
1645 | <term><varname>AssertNeedsUpdate=</varname></term> | |
1646 | <term><varname>AssertFirstBoot=</varname></term> | |
1647 | <term><varname>AssertPathExists=</varname></term> | |
1648 | <term><varname>AssertPathExistsGlob=</varname></term> | |
1649 | <term><varname>AssertPathIsDirectory=</varname></term> | |
1650 | <term><varname>AssertPathIsSymbolicLink=</varname></term> | |
1651 | <term><varname>AssertPathIsMountPoint=</varname></term> | |
1652 | <term><varname>AssertPathIsReadWrite=</varname></term> | |
7d27d39a | 1653 | <term><varname>AssertPathIsEncrypted=</varname></term> |
337b7334 ZJS |
1654 | <term><varname>AssertDirectoryNotEmpty=</varname></term> |
1655 | <term><varname>AssertFileNotEmpty=</varname></term> | |
1656 | <term><varname>AssertFileIsExecutable=</varname></term> | |
1657 | <term><varname>AssertUser=</varname></term> | |
1658 | <term><varname>AssertGroup=</varname></term> | |
1659 | <term><varname>AssertControlGroupController=</varname></term> | |
7d27d39a SR |
1660 | <term><varname>AssertMemory=</varname></term> |
1661 | <term><varname>AssertCPUs=</varname></term> | |
337b7334 ZJS |
1662 | |
1663 | <listitem><para>Similar to the <varname>ConditionArchitecture=</varname>, | |
1664 | <varname>ConditionVirtualization=</varname>, …, condition settings described above, these settings | |
1665 | add assertion checks to the start-up of the unit. However, unlike the conditions settings, any | |
1666 | assertion setting that is not met results in failure of the start job (which means this is logged | |
1667 | loudly). Note that hitting a configured assertion does not cause the unit to enter the | |
1668 | <literal>failed</literal> state (or in fact result in any state change of the unit), it affects | |
1669 | only the job queued for it. Use assertion expressions for units that cannot operate when specific | |
1670 | requirements are not met, and when this is something the administrator or user should look | |
1671 | into.</para> | |
1672 | </listitem> | |
1673 | </varlistentry> | |
1674 | </variablelist> | |
1675 | </refsect2> | |
2bf92506 ZJS |
1676 | </refsect1> |
1677 | ||
1678 | <refsect1> | |
1679 | <title>Mapping of unit properties to their inverses</title> | |
1680 | ||
1681 | <para>Unit settings that create a relationship with a second unit usually show up | |
1682 | in properties of both units, for example in <command>systemctl show</command> | |
1683 | output. In some cases the name of the property is the same as the name of the | |
2116134b | 1684 | configuration setting, but not always. This table lists the properties |
2bf92506 ZJS |
1685 | that are shown on two units which are connected through some dependency, and shows |
1686 | which property on "source" unit corresponds to which property on the "target" unit. | |
1687 | </para> | |
1688 | ||
1689 | <table> | |
1690 | <title> | |
1691 | "Forward" and "reverse" unit properties | |
1692 | </title> | |
1693 | ||
2eca7635 | 1694 | <tgroup cols='4'> |
2bf92506 ZJS |
1695 | <colspec colname='forward' /> |
1696 | <colspec colname='reverse' /> | |
2eca7635 ZJS |
1697 | <colspec colname='fuse' /> |
1698 | <colspec colname='ruse' /> | |
2bf92506 ZJS |
1699 | <thead> |
1700 | <row> | |
1701 | <entry>"Forward" property</entry> | |
1702 | <entry>"Reverse" property</entry> | |
2eca7635 | 1703 | <entry namest='fuse' nameend='ruse' valign='middle'>Where used</entry> |
2bf92506 ZJS |
1704 | </row> |
1705 | </thead> | |
1706 | <tbody> | |
1707 | <row> | |
1708 | <entry><varname>Before=</varname></entry> | |
1709 | <entry><varname>After=</varname></entry> | |
2eca7635 | 1710 | <entry morerows='1' namest='fuse' nameend='ruse' valign='middle'>[Unit] section</entry> |
2bf92506 ZJS |
1711 | </row> |
1712 | <row> | |
1713 | <entry><varname>After=</varname></entry> | |
1714 | <entry><varname>Before=</varname></entry> | |
1715 | </row> | |
1716 | <row> | |
1717 | <entry><varname>Requires=</varname></entry> | |
1718 | <entry><varname>RequiredBy=</varname></entry> | |
2eca7635 ZJS |
1719 | <entry>[Unit] section</entry> |
1720 | <entry>[Install] section</entry> | |
2bf92506 ZJS |
1721 | </row> |
1722 | <row> | |
1723 | <entry><varname>Wants=</varname></entry> | |
1724 | <entry><varname>WantedBy=</varname></entry> | |
2eca7635 ZJS |
1725 | <entry>[Unit] section</entry> |
1726 | <entry>[Install] section</entry> | |
2bf92506 ZJS |
1727 | </row> |
1728 | <row> | |
1729 | <entry><varname>PartOf=</varname></entry> | |
1730 | <entry><varname>ConsistsOf=</varname></entry> | |
2eca7635 ZJS |
1731 | <entry>[Unit] section</entry> |
1732 | <entry>an automatic property</entry> | |
2bf92506 ZJS |
1733 | </row> |
1734 | <row> | |
1735 | <entry><varname>BindsTo=</varname></entry> | |
1736 | <entry><varname>BoundBy=</varname></entry> | |
2eca7635 ZJS |
1737 | <entry>[Unit] section</entry> |
1738 | <entry>an automatic property</entry> | |
2bf92506 ZJS |
1739 | </row> |
1740 | <row> | |
1741 | <entry><varname>Requisite=</varname></entry> | |
1742 | <entry><varname>RequisiteOf=</varname></entry> | |
2eca7635 ZJS |
1743 | <entry>[Unit] section</entry> |
1744 | <entry>an automatic property</entry> | |
2bf92506 ZJS |
1745 | </row> |
1746 | <row> | |
1747 | <entry><varname>Triggers=</varname></entry> | |
1748 | <entry><varname>TriggeredBy=</varname></entry> | |
2eca7635 | 1749 | <entry namest='fuse' nameend='ruse' valign='middle'>Automatic properties, see notes below</entry> |
2bf92506 ZJS |
1750 | </row> |
1751 | <row> | |
1752 | <entry><varname>Conflicts=</varname></entry> | |
1753 | <entry><varname>ConflictedBy=</varname></entry> | |
2eca7635 ZJS |
1754 | <entry>[Unit] section</entry> |
1755 | <entry>an automatic property</entry> | |
2bf92506 ZJS |
1756 | </row> |
1757 | <row> | |
1758 | <entry><varname>PropagatesReloadTo=</varname></entry> | |
1759 | <entry><varname>ReloadPropagatedFrom=</varname></entry> | |
2eca7635 | 1760 | <entry morerows='1' namest='fuse' nameend='ruse' valign='middle'>[Unit] section</entry> |
2bf92506 ZJS |
1761 | </row> |
1762 | <row> | |
1763 | <entry><varname>ReloadPropagatedFrom=</varname></entry> | |
1764 | <entry><varname>PropagatesReloadTo=</varname></entry> | |
1765 | </row> | |
2116134b ZJS |
1766 | <row> |
1767 | <entry><varname>Following=</varname></entry> | |
1768 | <entry>n/a</entry> | |
1769 | <entry>An automatic property</entry> | |
1770 | </row> | |
2bf92506 ZJS |
1771 | </tbody> |
1772 | </tgroup> | |
1773 | </table> | |
798d3a52 | 1774 | |
2bf92506 ZJS |
1775 | <para>Note: <varname>WantedBy=</varname> and <varname>RequiredBy=</varname> are |
1776 | used in the [Install] section to create symlinks in <filename>.wants/</filename> | |
1777 | and <filename>.requires/</filename> directories. They cannot be used directly as a | |
1778 | unit configuration setting.</para> | |
1779 | ||
1780 | <para>Note: <varname>ConsistsOf=</varname>, <varname>BoundBy=</varname>, | |
1781 | <varname>RequisiteOf=</varname>, <varname>ConflictedBy=</varname> are created | |
95522092 | 1782 | implicitly along with their reverses and cannot be specified directly.</para> |
2bf92506 ZJS |
1783 | |
1784 | <para>Note: <varname>Triggers=</varname> is created implicitly between a socket, | |
1785 | path unit, or an automount unit, and the unit they activate. By default a unit | |
1b2ad5d9 | 1786 | with the same name is triggered, but this can be overridden using |
2bf92506 ZJS |
1787 | <varname>Sockets=</varname>, <varname>Service=</varname>, and <varname>Unit=</varname> |
1788 | settings. See | |
1789 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1790 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1791 | <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1792 | and | |
1793 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
95522092 | 1794 | for details. <varname>TriggeredBy=</varname> is created implicitly on the |
2bf92506 | 1795 | triggered unit.</para> |
2116134b ZJS |
1796 | |
1797 | <para>Note: <varname>Following=</varname> is used to group device aliases and points to the | |
1798 | "primary" device unit that systemd is using to track device state, usually corresponding to a | |
1799 | sysfs path. It does not show up in the "target" unit.</para> | |
798d3a52 ZJS |
1800 | </refsect1> |
1801 | ||
1802 | <refsect1> | |
1803 | <title>[Install] Section Options</title> | |
1804 | ||
bdac5608 | 1805 | <para>Unit files may include an [Install] section, which carries installation information for |
be73bb48 LP |
1806 | the unit. This section is not interpreted by |
1807 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> during runtime; it is | |
1808 | used by the <command>enable</command> and <command>disable</command> commands of the | |
1809 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool during | |
caa45f5b | 1810 | installation of a unit.</para> |
798d3a52 ZJS |
1811 | |
1812 | <variablelist class='unit-directives'> | |
1813 | <varlistentry> | |
1814 | <term><varname>Alias=</varname></term> | |
1815 | ||
f4bf8d2f | 1816 | <listitem><para>A space-separated list of additional names this unit shall be installed under. The names listed |
1245e413 | 1817 | here must have the same suffix (i.e. type) as the unit filename. This option may be specified more than once, |
f4bf8d2f LP |
1818 | in which case all listed names are used. At installation time, <command>systemctl enable</command> will create |
1819 | symlinks from these names to the unit filename. Note that not all unit types support such alias names, and this | |
1820 | setting is not supported for them. Specifically, mount, slice, swap, and automount units do not support | |
1821 | aliasing.</para></listitem> | |
798d3a52 ZJS |
1822 | </varlistentry> |
1823 | ||
1824 | <varlistentry> | |
1825 | <term><varname>WantedBy=</varname></term> | |
1826 | <term><varname>RequiredBy=</varname></term> | |
1827 | ||
1828 | <listitem><para>This option may be used more than once, or a | |
1829 | space-separated list of unit names may be given. A symbolic | |
1830 | link is created in the <filename>.wants/</filename> or | |
1831 | <filename>.requires/</filename> directory of each of the | |
1832 | listed units when this unit is installed by <command>systemctl | |
1833 | enable</command>. This has the effect that a dependency of | |
1834 | type <varname>Wants=</varname> or <varname>Requires=</varname> | |
1835 | is added from the listed unit to the current unit. The primary | |
1836 | result is that the current unit will be started when the | |
1837 | listed unit is started. See the description of | |
1838 | <varname>Wants=</varname> and <varname>Requires=</varname> in | |
1839 | the [Unit] section for details.</para> | |
1840 | ||
1841 | <para><command>WantedBy=foo.service</command> in a service | |
1842 | <filename>bar.service</filename> is mostly equivalent to | |
1843 | <command>Alias=foo.service.wants/bar.service</command> in the | |
1844 | same file. In case of template units, <command>systemctl | |
1845 | enable</command> must be called with an instance name, and | |
1846 | this instance will be added to the | |
1847 | <filename>.wants/</filename> or | |
1848 | <filename>.requires/</filename> list of the listed unit. E.g. | |
1849 | <command>WantedBy=getty.target</command> in a service | |
1850 | <filename>getty@.service</filename> will result in | |
1851 | <command>systemctl enable getty@tty2.service</command> | |
1852 | creating a | |
1853 | <filename>getty.target.wants/getty@tty2.service</filename> | |
1854 | link to <filename>getty@.service</filename>. | |
1855 | </para></listitem> | |
1856 | </varlistentry> | |
1857 | ||
1858 | <varlistentry> | |
1859 | <term><varname>Also=</varname></term> | |
1860 | ||
1861 | <listitem><para>Additional units to install/deinstall when | |
1862 | this unit is installed/deinstalled. If the user requests | |
1863 | installation/deinstallation of a unit with this option | |
1864 | configured, <command>systemctl enable</command> and | |
1865 | <command>systemctl disable</command> will automatically | |
1866 | install/uninstall units listed in this option as well.</para> | |
1867 | ||
1868 | <para>This option may be used more than once, or a | |
1869 | space-separated list of unit names may be | |
1870 | given.</para></listitem> | |
1871 | </varlistentry> | |
1872 | ||
1873 | <varlistentry> | |
1874 | <term><varname>DefaultInstance=</varname></term> | |
1875 | ||
1876 | <listitem><para>In template unit files, this specifies for | |
1877 | which instance the unit shall be enabled if the template is | |
1878 | enabled without any explicitly set instance. This option has | |
1879 | no effect in non-template unit files. The specified string | |
1880 | must be usable as instance identifier.</para></listitem> | |
1881 | </varlistentry> | |
1882 | </variablelist> | |
1883 | ||
46a3adee YW |
1884 | <para>The following specifiers are interpreted in the Install section: |
1885 | %a, %b, %B, %g, %G, %H, %i, %j, %l, %m, %n, %N, %o, %p, %u, %U, %v, %w, %W, %%. | |
1886 | For their meaning see the next section.</para> | |
798d3a52 ZJS |
1887 | </refsect1> |
1888 | ||
1889 | <refsect1> | |
1890 | <title>Specifiers</title> | |
1891 | ||
1892 | <para>Many settings resolve specifiers which may be used to write | |
1893 | generic unit files referring to runtime or unit parameters that | |
751223fe ZJS |
1894 | are replaced when the unit files are loaded. Specifiers must be known |
1895 | and resolvable for the setting to be valid. The following | |
798d3a52 ZJS |
1896 | specifiers are understood:</para> |
1897 | ||
0d525a3e | 1898 | <table class='specifiers'> |
798d3a52 ZJS |
1899 | <title>Specifiers available in unit files</title> |
1900 | <tgroup cols='3' align='left' colsep='1' rowsep='1'> | |
1901 | <colspec colname="spec" /> | |
1902 | <colspec colname="mean" /> | |
1903 | <colspec colname="detail" /> | |
1904 | <thead> | |
1905 | <row> | |
5a15caf4 ZJS |
1906 | <entry>Specifier</entry> |
1907 | <entry>Meaning</entry> | |
1908 | <entry>Details</entry> | |
798d3a52 ZJS |
1909 | </row> |
1910 | </thead> | |
1911 | <tbody> | |
503298b7 | 1912 | <row> |
0d525a3e ZJS |
1913 | <!-- We do not use the common definition from standard-specifiers.xml here since it includes a |
1914 | reference onto our own man page, which would make the rendered version self-referential. --> | |
503298b7 LP |
1915 | <entry><literal>%a</literal></entry> |
1916 | <entry>Architecture</entry> | |
1917 | <entry>A short string identifying the architecture of the local system. A string such as <constant>x86</constant>, <constant>x86-64</constant> or <constant>arm64</constant>. See the architectures defined for <varname>ConditionArchitecture=</varname> above for a full list.</entry> | |
1918 | </row> | |
9a515f0a | 1919 | <xi:include href="standard-specifiers.xml" xpointer="A"/> |
c83347b4 | 1920 | <xi:include href="standard-specifiers.xml" xpointer="b"/> |
503298b7 | 1921 | <xi:include href="standard-specifiers.xml" xpointer="B"/> |
798d3a52 | 1922 | <row> |
709f4c47 LP |
1923 | <entry><literal>%C</literal></entry> |
1924 | <entry>Cache directory root</entry> | |
1925 | <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 | 1926 | </row> |
969309c2 YW |
1927 | <row> |
1928 | <entry><literal>%E</literal></entry> | |
1929 | <entry>Configuration directory root</entry> | |
3b121157 | 1930 | <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> |
969309c2 | 1931 | </row> |
798d3a52 | 1932 | <row> |
709f4c47 LP |
1933 | <entry><literal>%f</literal></entry> |
1934 | <entry>Unescaped filename</entry> | |
1935 | <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 | 1936 | </row> |
55318801 YW |
1937 | <row> |
1938 | <entry><literal>%g</literal></entry> | |
1939 | <entry>User group</entry> | |
1940 | <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> | |
1941 | </row> | |
1942 | <row> | |
1943 | <entry><literal>%G</literal></entry> | |
1944 | <entry>User GID</entry> | |
1945 | <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> | |
1946 | </row> | |
798d3a52 | 1947 | <row> |
709f4c47 LP |
1948 | <entry><literal>%h</literal></entry> |
1949 | <entry>User home directory</entry> | |
b4e24077 ZJS |
1950 | <entry>This is the home directory of the <emphasis>user running the service manager instance</emphasis>. In case of the system manager this resolves to <literal>/root</literal>. |
1951 | ||
1952 | Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry> | |
709f4c47 LP |
1953 | </row> |
1954 | <row> | |
0d525a3e ZJS |
1955 | <!-- We do not use the common definition from standard-specifiers.xml here since we want a |
1956 | slightly more verbose explanation here, referring to the reload cycle. --> | |
709f4c47 LP |
1957 | <entry><literal>%H</literal></entry> |
1958 | <entry>Host name</entry> | |
1959 | <entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry> | |
798d3a52 ZJS |
1960 | </row> |
1961 | <row> | |
5a15caf4 ZJS |
1962 | <entry><literal>%i</literal></entry> |
1963 | <entry>Instance name</entry> | |
e1a7f622 | 1964 | <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 |
1965 | </row> |
1966 | <row> | |
5a15caf4 ZJS |
1967 | <entry><literal>%I</literal></entry> |
1968 | <entry>Unescaped instance name</entry> | |
e1a7f622 | 1969 | <entry>Same as <literal>%i</literal>, but with escaping undone.</entry> |
798d3a52 | 1970 | </row> |
250e9fad ZJS |
1971 | <row> |
1972 | <entry><literal>%j</literal></entry> | |
1973 | <entry>Final component of the prefix</entry> | |
1974 | <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> | |
1975 | </row> | |
1976 | <row> | |
1977 | <entry><literal>%J</literal></entry> | |
1978 | <entry>Unescaped final component of the prefix</entry> | |
1979 | <entry>Same as <literal>%j</literal>, but with escaping undone.</entry> | |
1980 | </row> | |
55318801 YW |
1981 | <row> |
1982 | <entry><literal>%l</literal></entry> | |
1983 | <entry>Short host name</entry> | |
1984 | <entry>The hostname of the running system at the point in time the unit configuration is loaded, truncated at the first dot to remove any domain component.</entry> | |
1985 | </row> | |
798d3a52 | 1986 | <row> |
709f4c47 LP |
1987 | <entry><literal>%L</literal></entry> |
1988 | <entry>Log directory root</entry> | |
b0343f8c | 1989 | <entry>This is either <filename>/var/log</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to with <filename index="false">/log</filename> appended (for user managers).</entry> |
14068e17 | 1990 | </row> |
c83347b4 | 1991 | <xi:include href="standard-specifiers.xml" xpointer="m"/> |
9a515f0a | 1992 | <xi:include href="standard-specifiers.xml" xpointer="M"/> |
14068e17 | 1993 | <row> |
709f4c47 LP |
1994 | <entry><literal>%n</literal></entry> |
1995 | <entry>Full unit name</entry> | |
1996 | <entry></entry> | |
14068e17 LP |
1997 | </row> |
1998 | <row> | |
709f4c47 LP |
1999 | <entry><literal>%N</literal></entry> |
2000 | <entry>Full unit name</entry> | |
2001 | <entry>Same as <literal>%n</literal>, but with the type suffix removed.</entry> | |
798d3a52 | 2002 | </row> |
55318801 | 2003 | <xi:include href="standard-specifiers.xml" xpointer="o"/> |
798d3a52 | 2004 | <row> |
709f4c47 LP |
2005 | <entry><literal>%p</literal></entry> |
2006 | <entry>Prefix name</entry> | |
2007 | <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 |
2008 | </row> |
2009 | <row> | |
709f4c47 LP |
2010 | <entry><literal>%P</literal></entry> |
2011 | <entry>Unescaped prefix name</entry> | |
2012 | <entry>Same as <literal>%p</literal>, but with escaping undone.</entry> | |
798d3a52 ZJS |
2013 | </row> |
2014 | <row> | |
5a15caf4 ZJS |
2015 | <entry><literal>%s</literal></entry> |
2016 | <entry>User shell</entry> | |
2017 | <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 |
2018 | </row> |
2019 | <row> | |
709f4c47 LP |
2020 | <entry><literal>%S</literal></entry> |
2021 | <entry>State directory root</entry> | |
2022 | <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 |
2023 | </row> |
2024 | <row> | |
709f4c47 LP |
2025 | <entry><literal>%t</literal></entry> |
2026 | <entry>Runtime directory root</entry> | |
3b121157 | 2027 | <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> |
b294e594 | 2028 | </row> |
806d919c | 2029 | <xi:include href="standard-specifiers.xml" xpointer="T"/> |
798d3a52 | 2030 | <row> |
709f4c47 LP |
2031 | <entry><literal>%u</literal></entry> |
2032 | <entry>User name</entry> | |
b4e24077 ZJS |
2033 | <entry>This is the name of the <emphasis>user running the service manager instance</emphasis>. In case of the system manager this resolves to <literal>root</literal>. |
2034 | ||
2035 | Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry> | |
709f4c47 LP |
2036 | </row> |
2037 | <row> | |
2038 | <entry><literal>%U</literal></entry> | |
2039 | <entry>User UID</entry> | |
b4e24077 ZJS |
2040 | <entry>This is the numeric UID of the <emphasis>user running the service manager instance</emphasis>. In case of the system manager this resolves to <literal>0</literal>. |
2041 | ||
2042 | Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry> | |
798d3a52 | 2043 | </row> |
c83347b4 | 2044 | <xi:include href="standard-specifiers.xml" xpointer="v"/> |
806d919c | 2045 | <xi:include href="standard-specifiers.xml" xpointer="V"/> |
503298b7 LP |
2046 | <xi:include href="standard-specifiers.xml" xpointer="w"/> |
2047 | <xi:include href="standard-specifiers.xml" xpointer="W"/> | |
c83347b4 | 2048 | <xi:include href="standard-specifiers.xml" xpointer="percent"/> |
798d3a52 ZJS |
2049 | </tbody> |
2050 | </tgroup> | |
2051 | </table> | |
798d3a52 ZJS |
2052 | </refsect1> |
2053 | ||
2054 | <refsect1> | |
2055 | <title>Examples</title> | |
2056 | ||
2057 | <example> | |
2058 | <title>Allowing units to be enabled</title> | |
2059 | ||
2060 | <para>The following snippet (highlighted) allows a unit (e.g. | |
2061 | <filename>foo.service</filename>) to be enabled via | |
2062 | <command>systemctl enable</command>:</para> | |
2063 | ||
2064 | <programlisting>[Unit] | |
92b1e225 CS |
2065 | Description=Foo |
2066 | ||
2067 | [Service] | |
2068 | ExecStart=/usr/sbin/foo-daemon | |
2069 | ||
2070 | <emphasis>[Install]</emphasis> | |
2071 | <emphasis>WantedBy=multi-user.target</emphasis></programlisting> | |
2072 | ||
798d3a52 ZJS |
2073 | <para>After running <command>systemctl enable</command>, a |
2074 | symlink | |
211c99c7 | 2075 | <filename index="false">/etc/systemd/system/multi-user.target.wants/foo.service</filename> |
798d3a52 ZJS |
2076 | linking to the actual unit will be created. It tells systemd to |
2077 | pull in the unit when starting | |
2078 | <filename>multi-user.target</filename>. The inverse | |
2079 | <command>systemctl disable</command> will remove that symlink | |
2080 | again.</para> | |
2081 | </example> | |
2082 | ||
2083 | <example> | |
2084 | <title>Overriding vendor settings</title> | |
2085 | ||
2086 | <para>There are two methods of overriding vendor settings in | |
2087 | unit files: copying the unit file from | |
12b42c76 TG |
2088 | <filename>/usr/lib/systemd/system</filename> to |
2089 | <filename>/etc/systemd/system</filename> and modifying the | |
798d3a52 ZJS |
2090 | chosen settings. Alternatively, one can create a directory named |
2091 | <filename><replaceable>unit</replaceable>.d/</filename> within | |
12b42c76 | 2092 | <filename>/etc/systemd/system</filename> and place a drop-in |
798d3a52 ZJS |
2093 | file <filename><replaceable>name</replaceable>.conf</filename> |
2094 | there that only changes the specific settings one is interested | |
2095 | in. Note that multiple such drop-in files are read if | |
8331eaab | 2096 | present, processed in lexicographic order of their filename.</para> |
798d3a52 ZJS |
2097 | |
2098 | <para>The advantage of the first method is that one easily | |
2099 | overrides the complete unit, the vendor unit is not parsed at | |
2100 | all anymore. It has the disadvantage that improvements to the | |
2101 | unit file by the vendor are not automatically incorporated on | |
2102 | updates.</para> | |
2103 | ||
2104 | <para>The advantage of the second method is that one only | |
2105 | overrides the settings one specifically wants, where updates to | |
2106 | the unit by the vendor automatically apply. This has the | |
2107 | disadvantage that some future updates by the vendor might be | |
2108 | incompatible with the local changes.</para> | |
2109 | ||
798d3a52 ZJS |
2110 | <para>This also applies for user instances of systemd, but with |
2111 | different locations for the unit files. See the section on unit | |
2112 | load paths for further details.</para> | |
2113 | ||
2114 | <para>Suppose there is a vendor-supplied unit | |
12b42c76 | 2115 | <filename>/usr/lib/systemd/system/httpd.service</filename> with |
798d3a52 ZJS |
2116 | the following contents:</para> |
2117 | ||
2118 | <programlisting>[Unit] | |
92b1e225 CS |
2119 | Description=Some HTTP server |
2120 | After=remote-fs.target sqldb.service | |
2121 | Requires=sqldb.service | |
2122 | AssertPathExists=/srv/webserver | |
2123 | ||
2124 | [Service] | |
2125 | Type=notify | |
2126 | ExecStart=/usr/sbin/some-fancy-httpd-server | |
2127 | Nice=5 | |
2128 | ||
2129 | [Install] | |
2130 | WantedBy=multi-user.target</programlisting> | |
2131 | ||
798d3a52 ZJS |
2132 | <para>Now one wants to change some settings as an administrator: |
2133 | firstly, in the local setup, <filename>/srv/webserver</filename> | |
e2acdb6b | 2134 | might not exist, because the HTTP server is configured to use |
798d3a52 ZJS |
2135 | <filename>/srv/www</filename> instead. Secondly, the local |
2136 | configuration makes the HTTP server also depend on a memory | |
2137 | cache service, <filename>memcached.service</filename>, that | |
2138 | should be pulled in (<varname>Requires=</varname>) and also be | |
2139 | ordered appropriately (<varname>After=</varname>). Thirdly, in | |
2140 | order to harden the service a bit more, the administrator would | |
2141 | like to set the <varname>PrivateTmp=</varname> setting (see | |
912f003f | 2142 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
798d3a52 ZJS |
2143 | for details). And lastly, the administrator would like to reset |
2144 | the niceness of the service to its default value of 0.</para> | |
2145 | ||
2146 | <para>The first possibility is to copy the unit file to | |
12b42c76 | 2147 | <filename>/etc/systemd/system/httpd.service</filename> and |
798d3a52 ZJS |
2148 | change the chosen settings:</para> |
2149 | ||
2150 | <programlisting>[Unit] | |
92b1e225 CS |
2151 | Description=Some HTTP server |
2152 | After=remote-fs.target sqldb.service <emphasis>memcached.service</emphasis> | |
2153 | Requires=sqldb.service <emphasis>memcached.service</emphasis> | |
2154 | AssertPathExists=<emphasis>/srv/www</emphasis> | |
2155 | ||
2156 | [Service] | |
2157 | Type=notify | |
2158 | ExecStart=/usr/sbin/some-fancy-httpd-server | |
2159 | <emphasis>Nice=0</emphasis> | |
2160 | <emphasis>PrivateTmp=yes</emphasis> | |
2161 | ||
2162 | [Install] | |
2163 | WantedBy=multi-user.target</programlisting> | |
2164 | ||
798d3a52 ZJS |
2165 | <para>Alternatively, the administrator could create a drop-in |
2166 | file | |
12b42c76 | 2167 | <filename>/etc/systemd/system/httpd.service.d/local.conf</filename> |
798d3a52 | 2168 | with the following contents:</para> |
92b1e225 | 2169 | |
798d3a52 | 2170 | <programlisting>[Unit] |
92b1e225 CS |
2171 | After=memcached.service |
2172 | Requires=memcached.service | |
2173 | # Reset all assertions and then re-add the condition we want | |
2174 | AssertPathExists= | |
2175 | AssertPathExists=/srv/www | |
2176 | ||
2177 | [Service] | |
2178 | Nice=0 | |
2179 | PrivateTmp=yes</programlisting> | |
2180 | ||
afbc75e6 DB |
2181 | <para>Note that for drop-in files, if one wants to remove |
2182 | entries from a setting that is parsed as a list (and is not a | |
2183 | dependency), such as <varname>AssertPathExists=</varname> (or | |
2184 | e.g. <varname>ExecStart=</varname> in service units), one needs | |
2185 | to first clear the list before re-adding all entries except the | |
2186 | one that is to be removed. Dependencies (<varname>After=</varname>, etc.) | |
798d3a52 ZJS |
2187 | cannot be reset to an empty list, so dependencies can only be |
2188 | added in drop-ins. If you want to remove dependencies, you have | |
2189 | to override the entire unit.</para> | |
0cf4c0d1 | 2190 | |
798d3a52 ZJS |
2191 | </example> |
2192 | </refsect1> | |
2193 | ||
2194 | <refsect1> | |
2195 | <title>See Also</title> | |
2196 | <para> | |
2197 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
2198 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
d1698b82 | 2199 | <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
798d3a52 ZJS |
2200 | <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>, |
2201 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
2202 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
2203 | <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
2204 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
2205 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
2206 | <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
2207 | <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
2208 | <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
2209 | <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
798d3a52 ZJS |
2210 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
2211 | <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
2212 | <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
2213 | <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
2214 | <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
2215 | <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
3ba3a79d | 2216 | <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
798d3a52 ZJS |
2217 | </para> |
2218 | </refsect1> | |
d1ab0ca0 LP |
2219 | |
2220 | </refentry> |