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