1SYSTEMD.UNIT(5) systemd.unit SYSTEMD.UNIT(5)
2
3
4
6 systemd.unit - systemd unit configuration files
7
9 systemd.service, systemd.socket, systemd.device, systemd.mount,
10 systemd.automount, systemd.swap, systemd.target, systemd.path,
11 systemd.timer, systemd.snapshot
12
14 A unit configuration file encodes information about a service, a
15 socket, a device, a mount point, an automount point, a swap file or
16 partition, a start-up target, a file system path or a timer controlled
17 and supervised by systemd(1). The syntax is inspired by XDG Desktop
18 Entry Specification[1] .desktop files, which are in turn inspired by
19 Microsoft Windows .ini files.
20
21 This man pages lists the common configuration options of all the unit
22 types. These options need to be configured in the [Unit] resp.
23 [Install] section of the unit files.
24
25 In addition to the generic [Unit] and [Install] sections described
26 here, each unit should have a type-specific section, e.g. [Service] for
27 a service unit. See the respective man pages for more information.
28
29 Unit files may contain additional options on top of those listed here.
30 If systemd encounters an unknown option it will write a warning log
31 message but continue loading the unit. If an option is prefixed with X-
32 it is ignored completely by systemd. Applications may use this to
33 include additional information in the unit files.
34
35 Boolean arguments used in unit files can be written in various formats.
36 For positive settings the strings 1, yes, true and on are equivalent.
37 For negative settings the strings 0, no, false and off are equivalent.
38
39 Time span values encoded in unit files can be written in various
40 formats. A stand-alone number specifies a time in seconds. If suffixed
41 with a time unit, the unit is honored. A concatenation of multiple
42 values with units is supported, in which case the values are added up.
43 Example: "50" refers to 50 seconds; "2min 200ms" refers to 2 minutes
44 plus 200 milliseconds, i.e. 120200ms. The following time units are
45 understood: s, min, h, d, w, ms, us.
46
47 Empty lines and lines starting with # or ; are ignored. This may be
48 used for commenting. Lines ending in a backslash are concatenated with
49 the following line while reading and the backslash is replaced by a
50 space character. This may be used to wrap long lines.
51
52 If a line starts with .include followed by a file name, the specified
53 file will be read as if its contents were listed in place of the
54 .include directive.
55
56 Along with a unit file foo.service a directory foo.service.wants/ may
57 exist. All units symlinked from such a directory are implicitly added
58 as dependencies of type Wanted= to the unit. This is useful to hook
59 units into the start-up of other units, without having to modify their
60 unit configuration files. For details about the semantics of Wanted=
61 see below. The preferred way to create symlinks in the .wants/
62 directory of a service is with the enable command of the systemctl(1)
63 tool which reads information from the [Install] section of unit files.
64 (See below.)
65
66 Note that while systemd offers a flexible dependency system between
67 units it is recommended to use this functionality only sparsely and
68 instead rely on techniques such as bus-based or socket-based activation
69 which makes dependencies implicit, which both results in a simpler and
70 more flexible system.
71
72 Some unit names reflect paths existing in the file system name space.
73 Example: a device unit dev-sda.device refers to a device with the
74 device node /dev/sda in the file system namespace. If this applies a
75 special way to escape the path name is used, so that the result is
76 usable as part of a file name. Basically, given a path, "/" is replaced
77 by "-", and all unprintable characters and the "-" are replaced by
78 C-style "\x20" escapes. The root directory "/" is encoded as single
79 dash, while otherwise the initial and ending "/" is removed from all
80 paths during transformation. This escaping is reversible.
81
82 Optionally, units may be instantiated from a template file at runtime.
83 This allows creation of multiple units from a single configuration
84 file. If systemd looks for a unit configuration file it will first
85 search for the literal unit name in the filesystem. If that yields no
86 success and the unit name contains an @ character, systemd will look
87 for a unit template that shares the same name but with the instance
88 string (i.e. the part between the @ character and the suffix) removed.
89 Example: if a service getty@tty3.service is requested and no file by
90 that name is found, systemd will look for getty@.service and
91 instantiate a service from that configuration file if it is found. To
92 refer to the instance string from within the configuration file you may
93 use the special %i specifier in many of the configuration options.
94 Other specifiers that may be used are %n, %N, %p, %P and %I, for the
95 full unit name, the unescaped unit name, the prefix name, the unescaped
96 prefix name and the unescaped instance name, respectively. The prefix
97 name here refers to the string before the @, i.e. "getty" in the
98 example above, where "tty3" is the instance name.
99
101 Unit file may include a [Unit] section, which carries generic
102 information about the unit that is not dependent on the type of unit:
103
104 Names=
105 Additional names for this unit. The names listed here must have the
106 same suffix (i.e. type) as the unit file name. This option may be
107 specified more than once, in which case all listed names are used.
108 Note that this option is different from the Alias= option from the
109 [Install] section mentioned below. See below for details.
110
111 Description=
112 A free-form string describing the unit. This is intended for use in
113 UIs to show descriptive information along with the unit name.
114
115 Requires=
116 Configures requirement dependencies on other units. If this unit
117 gets activated, the units listed here will be activated as well. If
118 one of the other units gets deactivated or its activation fails,
119 this unit will be deactivated. This option may be specified more
120 than once, in which case requirement dependencies for all listed
121 names are created. Note that requirement dependencies do not
122 influence the order in which services are started or stopped. This
123 has to be configured independently with the After= or Before=
124 options. If a unit foo.service requires a unit bar.service as
125 configured with Requires= and no ordering is configured with After=
126 or Before=, then both units will be started simultaneously and
127 without any delay between them if foo.service is activated. Often
128 it is a better choice to use Wants= instead of Requires= in order
129 to achieve a system that is more robust when dealing with failing
130 services.
131
132 RequiresOverridable=
133 Similar to Requires=. Dependencies listed in RequiresOverridable=
134 which cannot be fulfilled or fail to start are ignored if the
135 startup was explicitly requested by the user. If the start-up was
136 pulled in indirectly by some dependency or automatic start-up of
137 units that is not requested by the user this dependency must be
138 fulfilled and otherwise the transaction fails. Hence, this option
139 may be used to configure dependencies that are normally honored
140 unless the user explicitly starts up the unit, in which case
141 whether they failed or not is irrelevant.
142
143 Requisite=, RequisiteOverridable=
144 Similar to Requires= resp. RequiresOverridable=. However, if a
145 unit listed here is not started already it will not be started and
146 the transaction fails immediately.
147
148 Wants=
149 A weaker version of Requires=. A unit listed in this option will be
150 started if the configuring unit is. However, if the listed unit
151 fails to start up or cannot be added to the transaction this has no
152 impact on the validity of the transaction as a whole. This is the
153 recommended way to hook start-up of one unit to the start-up of
154 another unit. Note that dependencies of this type may also be
155 configured outside of the unit configuration file by adding a
156 symlink to a .wants/ directory accompanying the unit file. For
157 details see above.
158
159 Conflicts=
160 Configures negative requirement dependencies. If a unit has a
161 Conflicts= setting on another unit, starting the former will stop
162 the latter and vice versa. Note that this setting is independent of
163 and orthogonal to the After= and Before= ordering dependencies.
164
165 If a unit A that conflicts with a unit B is scheduled to be started
166 at the same time as B, the transaction will either fail (in case
167 both are required part of the transaction) or be modified to be
168 fixed (in case one or both jobs are not a required part of the
169 transaction). In the latter case the job that is not the required
170 will be removed, or in case both are not required the unit that
171 conflicts will be started and the unit that is conflicted is
172 stopped.
173
174 Before=, After=
175 Configures ordering dependencies between units. If a unit
176 foo.service contains a setting Before=bar.service and both units
177 are being started, bar.service´s start-up is delayed until
178 foo.service is started up. Note that this setting is independent of
179 and orthogonal to the requirement dependencies as configured by
180 Requires=. It is a common pattern to include a unit name in both
181 the After= and Requires= option in which case the unit listed will
182 be started before the unit that is configured with these options.
183 This option may be specified more than once, in which case ordering
184 dependencies for all listed names are created. After= is the
185 inverse of Before=, i.e. while After= ensures that the configured
186 unit is started after the listed unit finished starting up, Before=
187 ensures the opposite, i.e. that the configured unit is fully
188 started up before the listed unit is started. Note that when two
189 units with an ordering dependency between them are shut down, the
190 inverse of the start-up order is applied. i.e. if a unit is
191 configured with After= on another unit, the former is stopped
192 before the latter if both are shut down. If one unit with an
193 ordering dependency on another unit is shut down while the latter
194 is started up, the shut down is ordered before the start-up
195 regardless whether the ordering dependency is actually of type
196 After= or Before=. If two units have no ordering dependencies
197 between them they are shut down resp. started up simultaneously,
198 and no ordering takes place.
199
200 OnFailure=
201 Lists one or more units that are activated when this unit enters
202 the ´failed´ state.
203
204 RecursiveStop=
205 Takes a boolean argument. If true and the unit stops without being
206 requested by the user, all units depending on it will be stopped as
207 well. (e.g. if a service exits or crashes on its own behalf, units
208 using it will be stopped) Note that normally if a unit stops
209 without a user request, units depending on it will not be
210 terminated. Only if the user requested shutdown of a unit, all
211 units depending on that unit will be shut down as well and at the
212 same time. Defaults to false.
213
214 StopWhenUnneeded=
215 Takes a boolean argument. If true this unit will be stopped when it
216 is no longer used. Note that in order to minimize the work to be
217 executed, systemd will not stop units by default unless they are
218 conflicting with other units, or the user explicitly requested
219 their shut down. If this option is set, a unit will be
220 automatically cleaned up if no other active unit requires it.
221 Defaults to false.
222
223 RefuseManualStart=, RefuseManualStop=
224 Takes a boolean argument. If true this unit can only be activated
225 (resp. deactivated) indirectly. In this case explicit start-up
226 (resp. termination) requested by the user is denied, however if it
227 is started (resp. stopped) as a dependency of another unit,
228 start-up (resp. termination) will succeed. This is mostly a safety
229 feature to ensure that the user does not accidentally activate
230 units that are not intended to be activated explicitly, and not
231 accidentally deactivate units that are not intended to be
232 deactivated. These options default to false.
233
234 AllowIsolate=
235 Takes a boolean argument. If true this unit may be used with the
236 systemctl isolate command. Otherwise this will be refused. It
237 probably is a good idea to leave this disabled except for target
238 units that shall be used similar to runlevels in SysV init systems,
239 just as a precaution to avoid unusable system states. This option
240 defaults to false.
241
242 DefaultDependencies=
243 Takes a boolean argument. If true (the default), a few default
244 dependencies will implicitly be created for the unit. The actual
245 dependencies created depend on the unit type. For example, for
246 service units, these dependencies ensure that the service is
247 started only after basic system initialization is completed and is
248 properly terminated on system shutdown. See the respective man
249 pages for details. Generally, only services involved with early
250 boot or late shutdown should set this option to false. It is highly
251 recommended to leave this option enabled for the majority of common
252 units. If set to false this option does not disable all implicit
253 dependencies, just non-essential ones.
254
255 IgnoreDependencyFailure=
256 Takes a boolean argument. If true and a requirement dependency of
257 this unit fails to start up this unit will be started nonetheless,
258 ignoring that failure. If false (the default) and a dependency unit
259 fails the unit will immediately fail too and the job is removed.
260
261 JobTimeoutSec=
262 When clients are waiting for a job of this unit to complete, time
263 out after the specified time. If this time limit is reached the job
264 will be cancelled, the unit however will not change state or even
265 enter the ´failed´ mode. This value defaults to 0 (job timeouts
266 disabled), except for device units. NB: this timeout is independent
267 from any unit-specific timeout (for example, the timeout set with
268 Timeout= in service units) as the job timeout has no effect on the
269 unit itself, only on the job that might be pending for it. Or in
270 other words: unit-specific timeouts are useful to abort unit state
271 changes, and revert them. The job timeout set with this option
272 however is useful to abort only the job waiting for the unit state
273 to change.
274
275 Unit file may include a [Install] section, which carries installation
276 information for the unit. This section is not interpreted by systemd(1)
277 during runtime. It is used exclusively by the enable and disable
278 commands of the systemctl(1) tool during installation of a unit:
279
280 Alias=
281 Additional names this unit shall be installed under. The names
282 listed here must have the same suffix (i.e. type) as the unit file
283 name. This option may be specified more than once, in which case
284 all listed names are used. At installation time, systemctl enable
285 will create symlinks from these names to the unit file name. Note
286 that this is different from the Names= option from the [Unit]
287 section mentioned above: The names from Names= apply
288 unconditionally if the unit is loaded. The names from Alias= apply
289 only if the unit has actually been installed with the systemctl
290 enable command. Also, if systemd searches for a unit, it will
291 discover symlinked alias names as configured with Alias=, but not
292 names configured with Names= only. It is a common pattern to list a
293 name in both options. In this case, a unit will be active under all
294 names if installed, but also if not installed but requested
295 explicitly under its main name.
296
297 WantedBy=
298 Installs a symlink in the .wants/ subdirectory for a unit. This has
299 the effect that when the listed unit name is activated the unit
300 listing it is activated too. WantedBy=foo.service in a service
301 bar.service is mostly equivalent to
302 Alias=foo.service.wants/bar.service in the same file.
303
304 Also=
305 Additional units to install when this unit is installed. If the
306 user requests installation of a unit with this option configured,
307 systemctl enable will automatically install units listed in this
308 option as well.
309
311 systemd(1), systemctl(8), systemd.special(7), systemd.service(5),
312 systemd.socket(5), systemd.device(5), systemd.mount(5),
313 systemd.automount(5), systemd.swap(5), systemd.target(5),
314 systemd.path(5), systemd.timer(5), systemd.snapshot(5)
315
317 Lennart Poettering <lennart@poettering.net>
318 Developer
319
321 1. XDG Desktop Entry Specification
322 http://standards.freedesktop.org/desktop-entry-spec/latest/
323
324
325
326systemd 09/14/2010 SYSTEMD.UNIT(5)