]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/udev.xml
man: networkd - clarify that multiple addresses/routes are supported
[thirdparty/systemd.git] / man / udev.xml
CommitLineData
7b86ada7 1<?xml version='1.0'?>
63749b1a
KS
2<?xml-stylesheet type="text/xsl" href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?>
3<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
7b86ada7
KS
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5
63749b1a
KS
6<refentry id="udev">
7 <refentryinfo>
7b86ada7 8 <title>udev</title>
d3a2386d
KS
9 <productname>systemd</productname>
10 <authorgroup>
11 <author>
12 <contrib>Developer</contrib>
13 <firstname>Greg</firstname>
14 <surname>Kroah-Hartmann</surname>
15 <email>greg@kroah.com</email>
16 </author>
17 <author>
18 <contrib>Developer</contrib>
19 <firstname>Kay</firstname>
20 <surname>Sievers</surname>
21 <email>kay@vrfy.org</email>
22 </author>
23 </authorgroup>
63749b1a
KS
24 </refentryinfo>
25
26 <refmeta>
27 <refentrytitle>udev</refentrytitle>
28 <manvolnum>7</manvolnum>
29 </refmeta>
30
31 <refnamediv>
32 <refname>udev</refname>
eb75d0ed 33 <refpurpose>Dynamic device management</refpurpose>
63749b1a
KS
34 </refnamediv>
35
36 <refsect1><title>Description</title>
37 <para>udev supplies the system software with device events, manages permissions
38 of device nodes and may create additional symlinks in the <filename>/dev</filename>
39 directory, or renames network interfaces. The kernel usually just assigns unpredictable
40 device names based on the order of discovery. Meaningful symlinks or network device
41 names provide a way to reliably identify devices based on their properties or
42 current configuration.</para>
43
b79f817b 44 <para>The udev daemon, <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle>
0e4fa2ab 45 <manvolnum>8</manvolnum></citerefentry>, receives device uevents directly from
63749b1a
KS
46 the kernel whenever a device is added or removed from the system, or it changes its
47 state. When udev receives a device event, it matches its configured set of rules
0e846301
MW
48 against various device attributes to identify the device. Rules that match may
49 provide additional device information to be stored in the udev database or
63749b1a
KS
50 to be used to create meaningful symlink names.</para>
51
0e846301 52 <para>All device information udev processes is stored in the udev database and
63749b1a 53 sent out to possible event subscribers. Access to all stored data and the event
17fd0f60 54 sources is provided by the library libudev.</para>
63749b1a
KS
55 </refsect1>
56
eb75d0ed 57 <refsect1><title>Rules Files</title>
63749b1a 58 <para>The udev rules are read from the files located in the
12a362be 59 system rules directory <filename>/usr/lib/udev/rules.d</filename>,
91418155
KS
60 the volatile runtime directory <filename>/run/udev/rules.d</filename>
61 and the local administration directory <filename>/etc/udev/rules.d</filename>.
1021e6df
KS
62 All rules files are collectively sorted and processed in lexical order,
63 regardless of the directories in which they live. However, files with
e9dd9f95 64 identical filenames replace each other. Files in <filename>/etc</filename>
91418155 65 have the highest priority, files in <filename>/run</filename> take precedence
e0e009c0 66 over files with the same name in <filename>/usr/lib</filename>. This can be
91418155
KS
67 used to override a system-supplied rules file with a local file if needed;
68 a symlink in <filename>/etc</filename> with the same name as a rules file in
e0e009c0 69 <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
eb75d0ed
KS
70 disables the rules file entirely. Rule files must have the extension
71 <filename>.rules</filename>; other extensions are ignored.</para>
63749b1a 72
feedf8f3 73 <para>Every line in the rules file contains at least one key-value pair.
909f413d 74 Except for empty lines or lines beginning with <literal>#</literal>, which are ignored.
bb31a4ac 75 There are two kinds of keys: match and assignment.
6ec0ac43
TG
76 If all match keys match against their values, the rule gets applied and the
77 assignment keys get the specified values assigned.</para>
63749b1a
KS
78
79 <para>A matching rule may rename a network interface, add symlinks
80 pointing to the device node, or run a specified program as part of
81 the event handling.</para>
82
55f5037c
MW
83 <para>A rule consists of a comma-separated list of one or more key-value pairs.
84 Each key has a distinct operation, depending on the used operator. Valid
63749b1a
KS
85 operators are:</para>
86 <variablelist>
87 <varlistentry>
6b76fa66 88 <term><literal>==</literal></term>
63749b1a
KS
89 <listitem>
90 <para>Compare for equality.</para>
91 </listitem>
92 </varlistentry>
93
94 <varlistentry>
6b76fa66 95 <term><literal>!=</literal></term>
63749b1a
KS
96 <listitem>
97 <para>Compare for inequality.</para>
98 </listitem>
99 </varlistentry>
100
101 <varlistentry>
6b76fa66 102 <term><literal>=</literal></term>
63749b1a 103 <listitem>
0e846301 104 <para>Assign a value to a key. Keys that represent a list are reset
63749b1a
KS
105 and only this single value is assigned.</para>
106 </listitem>
107 </varlistentry>
108
109 <varlistentry>
6b76fa66 110 <term><literal>+=</literal></term>
63749b1a
KS
111 <listitem>
112 <para>Add the value to a key that holds a list of entries.</para>
113 </listitem>
114 </varlistentry>
115
116 <varlistentry>
6b76fa66 117 <term><literal>:=</literal></term>
63749b1a 118 <listitem>
2bf11540 119 <para>Assign a value to a key finally; disallow any later changes.</para>
63749b1a
KS
120 </listitem>
121 </varlistentry>
122 </variablelist>
123
124 <para>The following key names can be used to match against device properties.
125 Some of the keys also match against properties of the parent devices in sysfs,
126 not only the device that has generated the event. If multiple keys that match
127 a parent device are specified in a single rule, all these keys must match at
128 one and the same parent device.</para>
ccc9a4f9 129 <variablelist class='udev-directives'>
63749b1a 130 <varlistentry>
909f413d 131 <term><varname>ACTION</varname></term>
63749b1a
KS
132 <listitem>
133 <para>Match the name of the event action.</para>
134 </listitem>
135 </varlistentry>
136
137 <varlistentry>
909f413d 138 <term><varname>DEVPATH</varname></term>
63749b1a
KS
139 <listitem>
140 <para>Match the devpath of the event device.</para>
141 </listitem>
142 </varlistentry>
143
144 <varlistentry>
909f413d 145 <term><varname>KERNEL</varname></term>
63749b1a
KS
146 <listitem>
147 <para>Match the name of the event device.</para>
148 </listitem>
149 </varlistentry>
150
151 <varlistentry>
909f413d 152 <term><varname>NAME</varname></term>
63749b1a 153 <listitem>
220893b3
KS
154 <para>Match the name of a network interface. It can be used once the
155 NAME key has been set in one of the preceding rules.</para>
63749b1a
KS
156 </listitem>
157 </varlistentry>
158
159 <varlistentry>
909f413d 160 <term><varname>SYMLINK</varname></term>
63749b1a
KS
161 <listitem>
162 <para>Match the name of a symlink targeting the node. It can
163 be used once a SYMLINK key has been set in one of the preceding
164 rules. There may be multiple symlinks; only one needs to match.
165 </para>
166 </listitem>
167 </varlistentry>
168
169 <varlistentry>
909f413d 170 <term><varname>SUBSYSTEM</varname></term>
63749b1a
KS
171 <listitem>
172 <para>Match the subsystem of the event device.</para>
173 </listitem>
174 </varlistentry>
175 <varlistentry>
909f413d 176 <term><varname>DRIVER</varname></term>
63749b1a 177 <listitem>
2e7f69eb 178 <para>Match the driver name of the event device. Only set this key for devices
63749b1a
KS
179 which are bound to a driver at the time the event is generated.</para>
180 </listitem>
181 </varlistentry>
182 <varlistentry>
909f413d 183 <term><varname>ATTR{<replaceable>filename</replaceable>}</varname></term>
63749b1a
KS
184 <listitem>
185 <para>Match sysfs attribute values of the event device. Trailing
65e039c2
MW
186 whitespace in the attribute values is ignored unless the specified match
187 value itself contains trailing whitespace.
63749b1a
KS
188 </para>
189 </listitem>
190 </varlistentry>
191
192 <varlistentry>
909f413d 193 <term><varname>KERNELS</varname></term>
63749b1a
KS
194 <listitem>
195 <para>Search the devpath upwards for a matching device name.</para>
196 </listitem>
197 </varlistentry>
198
199 <varlistentry>
909f413d 200 <term><varname>SUBSYSTEMS</varname></term>
63749b1a
KS
201 <listitem>
202 <para>Search the devpath upwards for a matching device subsystem name.</para>
203 </listitem>
204 </varlistentry>
205
206 <varlistentry>
909f413d 207 <term><varname>DRIVERS</varname></term>
63749b1a
KS
208 <listitem>
209 <para>Search the devpath upwards for a matching device driver name.</para>
210 </listitem>
211 </varlistentry>
212
213 <varlistentry>
909f413d 214 <term><varname>ATTRS{<replaceable>filename</replaceable>}</varname></term>
63749b1a
KS
215 <listitem>
216 <para>Search the devpath upwards for a device with matching sysfs attribute values.
909f413d 217 If multiple <varname>ATTRS</varname> matches are specified, all of them
65e039c2
MW
218 must match on the same device. Trailing whitespace in the attribute values is ignored
219 unless the specified match value itself contains trailing whitespace.</para>
63749b1a
KS
220 </listitem>
221 </varlistentry>
222
7df0ed83 223 <varlistentry>
909f413d 224 <term><varname>TAGS</varname></term>
7df0ed83
KS
225 <listitem>
226 <para>Search the devpath upwards for a device with matching tag.</para>
227 </listitem>
228 </varlistentry>
229
63749b1a 230 <varlistentry>
909f413d 231 <term><varname>ENV{<replaceable>key</replaceable>}</varname></term>
63749b1a
KS
232 <listitem>
233 <para>Match against a device property value.</para>
234 </listitem>
235 </varlistentry>
236
237 <varlistentry>
909f413d 238 <term><varname>TAG</varname></term>
63749b1a
KS
239 <listitem>
240 <para>Match against a device tag.</para>
241 </listitem>
242 </varlistentry>
243
244 <varlistentry>
909f413d 245 <term><varname>TEST{<replaceable>octal mode mask</replaceable>}</varname></term>
63749b1a
KS
246 <listitem>
247 <para>Test the existence of a file. An octal mode mask can be specified
248 if needed.</para>
249 </listitem>
250 </varlistentry>
251
252 <varlistentry>
909f413d 253 <term><varname>PROGRAM</varname></term>
63749b1a 254 <listitem>
2e9820e3
MW
255 <para>Execute a program to determine whether there
256 is a match; the key is true if the program returns
63749b1a 257 successfully. The device properties are made available to the
6db27428 258 executed program in the environment. The program's standard ouput
bcddd5bf
JSJ
259 is available in the <varname>RESULT</varname> key.</para>
260 <para>This can only be used for very short-running foreground tasks. For details,
909f413d 261 see <varname>RUN</varname>.</para>
63749b1a
KS
262 </listitem>
263 </varlistentry>
264
265 <varlistentry>
909f413d 266 <term><varname>RESULT</varname></term>
63749b1a 267 <listitem>
bcddd5bf
JSJ
268 <para>Match the returned string of the last <varname>PROGRAM</varname> call.
269 This key can be used in the same or in any later rule after a
270 <varname>PROGRAM</varname> call.</para>
63749b1a
KS
271 </listitem>
272 </varlistentry>
273 </variablelist>
274
eb75d0ed 275 <para>Most of the fields support shell glob pattern matching. The following
63749b1a
KS
276 pattern characters are supported:</para>
277 <variablelist>
278 <varlistentry>
6b76fa66 279 <term><literal>*</literal></term>
63749b1a 280 <listitem>
954e9c52 281 <para>Matches zero or more characters.</para>
63749b1a
KS
282 </listitem>
283 </varlistentry>
284 <varlistentry>
6b76fa66 285 <term><literal>?</literal></term>
63749b1a
KS
286 <listitem>
287 <para>Matches any single character.</para>
288 </listitem>
289 </varlistentry>
290 <varlistentry>
6b76fa66 291 <term><literal>[]</literal></term>
63749b1a
KS
292 <listitem>
293 <para>Matches any single character specified within the brackets. For
909f413d
ZJS
294 example, the pattern string <literal>tty[SR]</literal>
295 would match either <literal>ttyS</literal> or <literal>ttyR</literal>.
296 Ranges are also supported via the <literal>-</literal> character.
bcddd5bf
JSJ
297 For example, to match on the range of all digits, the pattern
298 <literal>[0-9]</literal> could be used. If the first character
299 following the <literal>[</literal> is a <literal>!</literal>,
300 any characters not enclosed are matched.</para>
63749b1a
KS
301 </listitem>
302 </varlistentry>
303 </variablelist>
304
305 <para>The following keys can get values assigned:</para>
ccc9a4f9 306 <variablelist class='udev-directives'>
63749b1a 307 <varlistentry>
909f413d 308 <term><varname>NAME</varname></term>
63749b1a 309 <listitem>
220893b3 310 <para>The name to use for a network interface. The name of a device node
bb31a4ac 311 cannot be changed by udev, only additional symlinks can be created.</para>
63749b1a
KS
312 </listitem>
313 </varlistentry>
314
315 <varlistentry>
909f413d 316 <term><varname>SYMLINK</varname></term>
63749b1a 317 <listitem>
933b5623 318 <para>The name of a symlink targeting the node. Every matching rule adds
b1239c3f
KS
319 this value to the list of symlinks to be created.</para>
320 <para>The set of characters to name a symlink is limited. Allowed
909f413d
ZJS
321 characters are <literal>0-9A-Za-z#+-.:=@_/</literal>, valid UTF-8 character
322 sequences, and <literal>\x00</literal> hex encoding. All other
323 characters are replaced by a <literal>_</literal> character.</para>
b1239c3f
KS
324 <para>Multiple symlinks may be specified by separating the names by the
325 space character. In case multiple devices claim the same name, the link
326 always points to the device with the highest link_priority. If the current
327 device goes away, the links are re-evaluated and the device with the
328 next highest link_priority becomes the owner of the link. If no
329 link_priority is specified, the order of the devices (and which one of
330 them owns the link) is undefined.</para>
331 <para>Symlink names must never conflict with the kernel's default device
332 node names, as that would result in unpredictable behavior.
63749b1a
KS
333 </para>
334 </listitem>
335 </varlistentry>
336
337 <varlistentry>
909f413d 338 <term><varname>OWNER</varname>, <varname>GROUP</varname>, <varname>MODE</varname></term>
63749b1a 339 <listitem>
91418155 340 <para>The permissions for the device node. Every specified value overrides
63749b1a
KS
341 the compiled-in default value.</para>
342 </listitem>
343 </varlistentry>
344
c26547d6
KS
345 <varlistentry>
346 <term><varname>SECLABEL{<replaceable>module</replaceable>}</varname></term>
347 <listitem>
348 <para>Applies the specified Linux Security Module label to the device node.</para>
349 </listitem>
350 </varlistentry>
351
63749b1a 352 <varlistentry>
909f413d 353 <term><varname>ATTR{<replaceable>key</replaceable>}</varname></term>
63749b1a
KS
354 <listitem>
355 <para>The value that should be written to a sysfs attribute of the
356 event device.</para>
357 </listitem>
358 </varlistentry>
359
360 <varlistentry>
909f413d 361 <term><varname>ENV{<replaceable>key</replaceable>}</varname></term>
63749b1a 362 <listitem>
909f413d 363 <para>Set a device property value. Property names with a leading <literal>.</literal>
ed9c5fb7 364 are neither stored in the database nor exported to events or
bcddd5bf
JSJ
365 external tools (run by, for example, the <varname>PROGRAM</varname>
366 match key).</para>
63749b1a
KS
367 </listitem>
368 </varlistentry>
369
370 <varlistentry>
909f413d 371 <term><varname>TAG</varname></term>
63749b1a
KS
372 <listitem>
373 <para>Attach a tag to a device. This is used to filter events for users
374 of libudev's monitor functionality, or to enumerate a group of tagged
375 devices. The implementation can only work efficiently if only a few
376 tags are attached to a device. It is only meant to be used in
377 contexts with specific device filter requirements, and not as a
378 general-purpose flag. Excessive use might result in inefficient event
379 handling.</para>
380 </listitem>
381 </varlistentry>
382
383 <varlistentry>
909f413d 384 <term><varname>RUN{<replaceable>type</replaceable>}</varname></term>
63749b1a 385 <listitem>
bcddd5bf
JSJ
386 <para>Add a program to the list of programs to be executed after
387 processing all the rules for a specific event, depending on
388 <literal>type</literal>:</para>
72c6cf8f
TG
389 <variablelist>
390 <varlistentry>
391 <term><literal>program</literal></term>
392 <listitem>
393 <para>Execute an external program specified as the assigned
bcddd5bf
JSJ
394 value. If no absolute path is given, the program is expected
395 to live in <filename>/usr/lib/udev</filename>; otherwise, the
396 absolute path must be specified.</para>
397 <para>This is the default if no <replaceable>type</replaceable>
398 is specified.</para>
72c6cf8f
TG
399 </listitem>
400 </varlistentry>
401 <varlistentry>
402 <term><literal>builtin</literal></term>
403 <listitem>
bcddd5bf
JSJ
404 <para>As <varname>program</varname>, but use one of the
405 built-in programs rather than an external one.</para>
72c6cf8f
TG
406 </listitem>
407 </varlistentry>
408 </variablelist>
409 <para>The program name and following arguments are separated by spaces.
410 Single quotes can be used to specify arguments with spaces.</para>
b45f770f 411 <para>This can only be used for very short-running foreground tasks. Running an
2b76eb68 412 event process for a long period of time may block all further events for
b45f770f 413 this or a dependent device.</para>
bcddd5bf 414 <para>Starting daemons or other long-running processes is not appropriate
b45f770f
KS
415 for udev; the forked processes, detached or not, will be unconditionally
416 killed after the event handling has finished.</para>
63749b1a
KS
417 </listitem>
418 </varlistentry>
419
420 <varlistentry>
909f413d 421 <term><varname>LABEL</varname></term>
63749b1a 422 <listitem>
bcddd5bf 423 <para>A named label to which a <varname>GOTO</varname> may jump.</para>
63749b1a
KS
424 </listitem>
425 </varlistentry>
426
427 <varlistentry>
909f413d 428 <term><varname>GOTO</varname></term>
63749b1a 429 <listitem>
bcddd5bf 430 <para>Jumps to the next <varname>LABEL</varname> with a matching name.</para>
63749b1a
KS
431 </listitem>
432 </varlistentry>
433
434 <varlistentry>
909f413d 435 <term><varname>IMPORT{<replaceable>type</replaceable>}</varname></term>
63749b1a
KS
436 <listitem>
437 <para>Import a set of variables as device properties,
6b76fa66 438 depending on <literal>type</literal>:</para>
63749b1a
KS
439 <variablelist>
440 <varlistentry>
6b76fa66 441 <term><literal>program</literal></term>
63749b1a
KS
442 <listitem>
443 <para>Execute an external program specified as the assigned value and
444 import its output, which must be in environment key
445 format. Path specification, command/argument separation,
909f413d 446 and quoting work like in <varname>RUN</varname>.</para>
63749b1a
KS
447 </listitem>
448 </varlistentry>
449 <varlistentry>
72c6cf8f
TG
450 <term><literal>builtin</literal></term>
451 <listitem>
909f413d
ZJS
452 <para>Similar to <literal>program</literal>, but use one of the
453 built-in programs rather than an external one.</para>
72c6cf8f
TG
454 </listitem>
455 </varlistentry>
456 <varlistentry>
6b76fa66 457 <term><literal>file</literal></term>
63749b1a 458 <listitem>
b6a49cd6
MW
459 <para>Import a text file specified as the assigned value, the content
460 of which must be in environment key format.</para>
63749b1a
KS
461 </listitem>
462 </varlistentry>
463 <varlistentry>
6b76fa66 464 <term><literal>db</literal></term>
63749b1a
KS
465 <listitem>
466 <para>Import a single property specified as the assigned value from the
467 current device database. This works only if the database is already populated
468 by an earlier event.</para>
469 </listitem>
470 </varlistentry>
c4f6dcc4 471 <varlistentry>
6b76fa66 472 <term><literal>cmdline</literal></term>
c4f6dcc4 473 <listitem>
ad9c70a8 474 <para>Import a single property from the kernel command line. For simple flags
909f413d 475 the value of the property is set to <literal>1</literal>.</para>
c4f6dcc4
KS
476 </listitem>
477 </varlistentry>
63749b1a 478 <varlistentry>
6b76fa66 479 <term><literal>parent</literal></term>
63749b1a
KS
480 <listitem>
481 <para>Import the stored keys from the parent device by reading
482 the database entry of the parent device. The value assigned to
483 <option>IMPORT{parent}</option> is used as a filter of key names
eb75d0ed 484 to import (with the same shell glob pattern matching used for
63749b1a
KS
485 comparisons).</para>
486 </listitem>
487 </varlistentry>
488 </variablelist>
b45f770f
KS
489 <para>This can only be used for very short-running foreground tasks. For details
490 see <option>RUN</option>.</para>
63749b1a
KS
491 </listitem>
492 </varlistentry>
493
494 <varlistentry>
909f413d 495 <term><varname>WAIT_FOR</varname></term>
63749b1a 496 <listitem>
793681cb
MW
497 <para>Wait for a file to become available or until a timeout of
498 10 seconds expires. The path is relative to the sysfs device;
499 if no path is specified, this waits for an attribute to appear.</para>
63749b1a
KS
500 </listitem>
501 </varlistentry>
502
503 <varlistentry>
909f413d 504 <term><varname>OPTIONS</varname></term>
63749b1a
KS
505 <listitem>
506 <para>Rule and device options:</para>
ccc9a4f9 507 <variablelist class='udev-directives'>
63749b1a
KS
508 <varlistentry>
509 <term><option>link_priority=<replaceable>value</replaceable></option></term>
510 <listitem>
511 <para>Specify the priority of the created symlinks. Devices with higher
512 priorities overwrite existing symlinks of other devices. The default is 0.</para>
513 </listitem>
514 </varlistentry>
515 <varlistentry>
516 <term><option>event_timeout=</option></term>
517 <listitem>
933b5623
MW
518 <para>Number of seconds an event waits for operations to finish before
519 giving up and terminating itself.</para>
63749b1a
KS
520 </listitem>
521 </varlistentry>
522 <varlistentry>
523 <term><option>string_escape=<replaceable>none|replace</replaceable></option></term>
524 <listitem>
525 <para>Usually control and other possibly unsafe characters are replaced
526 in strings used for device naming. The mode of replacement can be specified
527 with this option.</para>
528 </listitem>
529 </varlistentry>
9fa68615
KS
530 <varlistentry>
531 <term><option>static_node=</option></term>
532 <listitem>
bcddd5bf
JSJ
533 <para>Apply the permissions specified in this rule to the
534 static device node with the specified name. Also, for every
535 tag specified in this rule, create a symlink
84b6ad70
TG
536 in the directory
537 <filename>/run/udev/static_node-tags/<replaceable>tag</replaceable></filename>
bcddd5bf
JSJ
538 pointing at the static device node with the specified name.
539 Static device node creation is performed by systemd-tmpfiles
540 before systemd-udevd is started. The static nodes might not
541 have a corresponding kernel device; they are used to trigger
542 automatic kernel module loading when they are accessed.</para>
9fa68615
KS
543 </listitem>
544 </varlistentry>
63749b1a
KS
545 <varlistentry>
546 <term><option>watch</option></term>
547 <listitem>
bcddd5bf
JSJ
548 <para>Watch the device node with inotify; when the node is
549 closed after being opened for writing, a change uevent is
550 synthesized.</para>
63749b1a
KS
551 </listitem>
552 </varlistentry>
3b529da4
KS
553 <varlistentry>
554 <term><option>nowatch</option></term>
555 <listitem>
556 <para>Disable the watching of a device node with inotify.</para>
557 </listitem>
558 </varlistentry>
63749b1a
KS
559 </variablelist>
560 </listitem>
561 </varlistentry>
562 </variablelist>
563
bcddd5bf
JSJ
564 <para>The <varname>NAME</varname>, <varname>SYMLINK</varname>,
565 <varname>PROGRAM</varname>, <varname>OWNER</varname>,
566 <varname>GROUP</varname>, <varname>MODE</varname>, and
567 <varname>RUN</varname> fields support simple string substitutions.
568 The <varname>RUN</varname> substitutions are performed after all rules
569 have been processed, right before the program is executed, allowing for
570 the use of device properties set by earlier matching rules. For all other
571 fields, substitutions are performed while the individual rule is being
572 processed. The available substitutions are:</para>
ccc9a4f9 573 <variablelist class='udev-directives'>
63749b1a
KS
574 <varlistentry>
575 <term><option>$kernel</option>, <option>%k</option></term>
576 <listitem>
577 <para>The kernel name for this device.</para>
578 </listitem>
579 </varlistentry>
580
581 <varlistentry>
582 <term><option>$number</option>, <option>%n</option></term>
583 <listitem>
909f413d 584 <para>The kernel number for this device. For example,
bcddd5bf
JSJ
585 <literal>sda3</literal> has kernel number <literal>3</literal>.
586 </para>
63749b1a
KS
587 </listitem>
588 </varlistentry>
589
590 <varlistentry>
591 <term><option>$devpath</option>, <option>%p</option></term>
592 <listitem>
593 <para>The devpath of the device.</para>
594 </listitem>
595 </varlistentry>
596
597 <varlistentry>
598 <term><option>$id</option>, <option>%b</option></term>
599 <listitem>
bcddd5bf
JSJ
600 <para>The name of the device matched while searching the devpath
601 upwards for <option>SUBSYSTEMS</option>, <option>KERNELS</option>,
602 <option>DRIVERS</option>, and <option>ATTRS</option>.
63749b1a
KS
603 </para>
604 </listitem>
605 </varlistentry>
606
607 <varlistentry>
608 <term><option>$driver</option></term>
609 <listitem>
bcddd5bf
JSJ
610 <para>The driver name of the device matched while searching the
611 devpath upwards for <option>SUBSYSTEMS</option>,
612 <option>KERNELS</option>, <option>DRIVERS</option>, and
613 <option>ATTRS</option>.
63749b1a
KS
614 </para>
615 </listitem>
616 </varlistentry>
617
618 <varlistentry>
619 <term><option>$attr{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>
620 <listitem>
0e846301 621 <para>The value of a sysfs attribute found at the device where
bcddd5bf
JSJ
622 all keys of the rule have matched. If the matching device does not
623 have such an attribute, and a previous <option>KERNELS</option>,
624 <option>SUBSYSTEMS</option>, <option>DRIVERS</option>, or
625 <option>ATTRS</option> test selected a parent device, then the
626 attribute from that parent device is used.
627 </para>
628 <para>If the attribute is a symlink, the last element of the
629 symlink target is returned as the value.
630 </para>
63749b1a
KS
631 </listitem>
632 </varlistentry>
633
634 <varlistentry>
635 <term><option>$env{<replaceable>key</replaceable>}</option>, <option>%E{<replaceable>key</replaceable>}</option></term>
636 <listitem>
637 <para>A device property value.</para>
638 </listitem>
639 </varlistentry>
640
641 <varlistentry>
642 <term><option>$major</option>, <option>%M</option></term>
643 <listitem>
644 <para>The kernel major number for the device.</para>
645 </listitem>
646 </varlistentry>
647
648 <varlistentry>
649 <term><option>$minor</option>, <option>%m</option></term>
650 <listitem>
651 <para>The kernel minor number for the device.</para>
652 </listitem>
653 </varlistentry>
654
655 <varlistentry>
656 <term><option>$result</option>, <option>%c</option></term>
657 <listitem>
bcddd5bf
JSJ
658 <para>The string returned by the external program requested with
659 <varname>PROGRAM</varname>.
21188522 660 A single part of the string, separated by a space character, may be selected
909f413d
ZJS
661 by specifying the part number as an attribute: <literal>%c{N}</literal>.
662 If the number is followed by the <literal>+</literal> character, this part plus all remaining parts
663 of the result string are substituted: <literal>%c{N+}</literal>.</para>
63749b1a
KS
664 </listitem>
665 </varlistentry>
666
667 <varlistentry>
668 <term><option>$parent</option>, <option>%P</option></term>
669 <listitem>
670 <para>The node name of the parent device.</para>
671 </listitem>
672 </varlistentry>
673
674 <varlistentry>
675 <term><option>$name</option></term>
676 <listitem>
220893b3 677 <para>The current name of the device. If not changed by a rule, it is the
63749b1a
KS
678 name of the kernel device.</para>
679 </listitem>
680 </varlistentry>
681
682 <varlistentry>
683 <term><option>$links</option></term>
684 <listitem>
e8b5e4e5 685 <para>A space-separated list of the current symlinks. The value is
2d74bc75 686 only set during a remove event or if an earlier rule assigned a value.</para>
63749b1a
KS
687 </listitem>
688 </varlistentry>
689
690 <varlistentry>
691 <term><option>$root</option>, <option>%r</option></term>
692 <listitem>
693 <para>The udev_root value.</para>
694 </listitem>
695 </varlistentry>
696
697 <varlistentry>
698 <term><option>$sys</option>, <option>%S</option></term>
699 <listitem>
700 <para>The sysfs mount point.</para>
701 </listitem>
702 </varlistentry>
703
704 <varlistentry>
220893b3 705 <term><option>$devnode</option>, <option>%N</option></term>
63749b1a 706 <listitem>
220893b3 707 <para>The name of the device node.</para>
63749b1a
KS
708 </listitem>
709 </varlistentry>
710
711 <varlistentry>
909f413d 712 <term><option>%%</option></term>
63749b1a 713 <listitem>
909f413d 714 <para>The <literal>%</literal> character itself.</para>
63749b1a
KS
715 </listitem>
716 </varlistentry>
717
718 <varlistentry>
909f413d 719 <term><option>$$</option></term>
63749b1a 720 <listitem>
909f413d 721 <para>The <literal>$</literal> character itself.</para>
63749b1a
KS
722 </listitem>
723 </varlistentry>
724 </variablelist>
63749b1a
KS
725 </refsect1>
726
eb75d0ed
KS
727 <refsect1><title>Hardware Database Files</title>
728 <para>The hwdb files are read from the files located in the
729 system hwdb directory <filename>/usr/lib/udev/hwdb.d</filename>,
730 the volatile runtime directory <filename>/run/udev/hwdb.d</filename>
731 and the local administration directory <filename>/etc/udev/hwdb.d</filename>.
0778c3db 732 All hwdb files are collectively sorted and processed in lexical order,
eb75d0ed
KS
733 regardless of the directories in which they live. However, files with
734 identical filenames replace each other. Files in <filename>/etc</filename>
735 have the highest priority, files in <filename>/run</filename> take precedence
e0e009c0 736 over files with the same name in <filename>/usr/lib</filename>. This can be
eb75d0ed 737 used to override a system-supplied hwdb file with a local file if needed;
0778c3db 738 a symlink in <filename>/etc</filename> with the same name as a hwdb file in
e0e009c0 739 <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
0778c3db 740 disables the hwdb file entirely. hwdb files must have the extension
eb75d0ed
KS
741 <filename>.hwdb</filename>; other extensions are ignored.</para>
742
743 <para>The hwdb file contains data records consisting of matches and
744 associated key-value pairs. Every record in the hwdb starts with one or
745 more match string, specifying a shell glob to compare the database
746 lookup string against. Multiple match lines are specified in additional
747 consecutive lines. Every match line is compared indivdually, they are
748 combined by OR. Every match line must start at the first character of
749 the line.</para>
750
751 <para>The match lines are followed by one or more key-value pair lines, which
752 are recognized by a leading space character. The key name and value are separated
753 by <literal>=</literal>. An empty line signifies the end
754 of a record. Lines beginning with <literal>#</literal> are ignored.</para>
755
756 <para>The content of all hwdb files is read by
757 <citerefentry><refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum></citerefentry>
758 and compiled to a binary database located at <filename>/etc/udev/hwdb.bin</filename>.
759 During runtime only the binary database is used.</para>
760 </refsect1>
761
1f06807c 762 <refsect1><title>Network Link Configuration</title>
22925e1a 763 <para>Network link configuration is performed by the <literal>net_setup_link</literal>
1f06807c
TG
764 udev builtin.</para>
765
766 <para>The link files are read from the files located in the
767 system network directory <filename>/usr/lib/systemd/network</filename>,
768 the volatile runtime network directory <filename>/run/systemd/network</filename>
769 and the local administration network directory <filename>/etc/systemd/network</filename>.
22925e1a 770 Link files must have the extension <filename>.link</filename>; other extensions are ignored.
1f06807c
TG
771 All link files are collectively sorted and processed in lexical order,
772 regardless of the directories in which they live. However, files with
773 identical filenames replace each other. Files in <filename>/etc</filename>
774 have the highest priority, files in <filename>/run</filename> take precedence
e0e009c0 775 over files with the same name in <filename>/usr/lib</filename>. This can be
1f06807c
TG
776 used to override a system-supplied link file with a local file if needed;
777 a symlink in <filename>/etc</filename> with the same name as a link file in
e0e009c0 778 <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
2b51bd3c 779 disables the link file entirely.</para>
1f06807c
TG
780
781 <para>The link file contains a <literal>[Match]</literal> section, which
782 determines if a given link file may be applied to a given device; and a
783 <literal>[Link]</literal> section specifying how the device should be
784 configured. The first (in lexical order) of the link files that matches
785 a given device is applied.</para>
786
787 <para>A link file is said to match a device if each of the entries in the
788 <literal>[Match]</literal> section matches, or if the section is empty.
789 The following keys are accepted:</para>
790
791 <variablelist class='network-directives'>
792 <varlistentry>
c8f57f59 793 <term><varname>MACAddress=</varname></term>
1f06807c
TG
794 <listitem>
795 <para>The hardware address.
796 </para>
797 </listitem>
798 </varlistentry>
799 <varlistentry>
c8f57f59 800 <term><varname>Path=</varname></term>
1f06807c 801 <listitem>
a03c5fd2
TG
802 <para>The persistent path, as exposed by the udev property <literal>ID_PATH</literal>.
803 May contain shell style globs.</para>
1f06807c
TG
804 </listitem>
805 </varlistentry>
806 <varlistentry>
c8f57f59 807 <term><varname>Driver=</varname></term>
1f06807c 808 <listitem>
9b1c2626 809 <para>The driver currently bound to the device, as exposed by the
bf175aaf
TG
810 udev property <literal>DRIVER</literal> of its parent device, or if
811 that is not set the driver as exposed by <literal>ethtool -i</literal>
812 of the device itself.</para>
1f06807c
TG
813 </listitem>
814 </varlistentry>
815 <varlistentry>
c8f57f59 816 <term><varname>Type=</varname></term>
1f06807c 817 <listitem>
d69b12ac 818 <para>The device type, as exposed by the udev property <literal>DEVTYPE</literal>.</para>
1f06807c
TG
819 </listitem>
820 </varlistentry>
a03c5fd2 821 <varlistentry>
c8f57f59 822 <term><varname>Host=</varname></term>
a03c5fd2
TG
823 <listitem>
824 <para>Matches against the hostname or machine ID of the
825 host. See <literal>ConditionHost=</literal> in
826 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
827 for details.</para>
828 </listitem>
829 </varlistentry>
830 <varlistentry>
c8f57f59 831 <term><varname>Virtualization=</varname></term>
a03c5fd2
TG
832 <listitem>
833 <para>Checks whether the system is executed in a virtualized
834 environment and optionally test whether it is a specific
835 implementation. See <literal>ConditionVirtualization=</literal> in
836 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
837 for details.</para>
838 </listitem>
839 </varlistentry>
840 <varlistentry>
c8f57f59 841 <term><varname>KernelCommandLine=</varname></term>
a03c5fd2
TG
842 <listitem>
843 <para>Checks whether a specific kernel command line option is
844 set (or if prefixed with the exclamation mark unset). See
845 <literal>ConditionKernelCommandLine=</literal> in
846 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
847 for details.</para>
848 </listitem>
849 </varlistentry>
edbb03e9 850 <varlistentry>
c8f57f59 851 <term><varname>Architecture=</varname></term>
edbb03e9
TG
852 <listitem>
853 <para>Checks whether the system is running on a specific
854 architecture. See <literal>ConditionArchitecture=</literal> in
855 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
856 for details.</para>
857 </listitem>
858 </varlistentry>
1f06807c
TG
859 </variablelist>
860
861 <para>The <literal>[Link]</literal> section accepts the following keys:</para>
862
863 <variablelist class='network-directives'>
864 <varlistentry>
c8f57f59 865 <term><varname>Description=</varname></term>
1f06807c 866 <listitem>
d2df0d0e
TG
867 <para>A description of the device.</para>
868 </listitem>
869 </varlistentry>
870 <varlistentry>
c8f57f59 871 <term><varname>Alias=</varname></term>
d2df0d0e
TG
872 <listitem>
873 <para>The <literal>ifalias</literal> is set to this value.</para>
1f06807c
TG
874 </listitem>
875 </varlistentry>
876 <varlistentry>
c8f57f59 877 <term><varname>MACAddressPolicy=</varname></term>
1f06807c 878 <listitem>
bcddd5bf
JSJ
879 <para>The policy by which the MAC address should be set. The
880 available policies are:
881 </para>
1f06807c
TG
882 <variablelist>
883 <varlistentry>
884 <term><literal>persistent</literal></term>
885 <listitem>
bcddd5bf
JSJ
886 <para>If the hardware has a persistent MAC address, as most
887 hardware should, and this is used by the kernel, nothing is
888 done. Otherwise, a new MAC address is generated which is
889 guaranteed to be the same on every boot for the given
890 machine and the given device, but which is otherwise random.
1f06807c
TG
891 </para>
892 </listitem>
893 </varlistentry>
894 <varlistentry>
895 <term><literal>random</literal></term>
896 <listitem>
bcddd5bf
JSJ
897 <para>If the kernel is using a random MAC address, nothing is
898 done. Otherwise, a new address is randomly generated each
899 time the device appears, typically at boot.
900 </para>
1f06807c
TG
901 </listitem>
902 </varlistentry>
903 </variablelist>
904 </listitem>
905 </varlistentry>
906 <varlistentry>
c8f57f59 907 <term><varname>MACAddress=</varname></term>
1f06807c 908 <listitem>
c8f57f59 909 <para>The MAC address to use, if no <literal>MACAddressPolicy=</literal>
bcddd5bf
JSJ
910 is specified.
911 </para>
1f06807c
TG
912 </listitem>
913 </varlistentry>
914 <varlistentry>
c8f57f59 915 <term><varname>NamePolicy=</varname></term>
1f06807c 916 <listitem>
bcddd5bf
JSJ
917 <para>An ordered, space-separated list of policies by which the
918 interface name should be set. <literal>NamePolicy</literal> may
38bf2b26 919 be disabled by specifying <literal>net.ifnames=0</literal> on the
bcddd5bf 920 kernel commandline. Each of the policies may fail, and the first
38bf2b26 921 successful one is used. The name is not set directly, but
bcddd5bf
JSJ
922 is exported to udev as the property <literal>ID_NET_NAME</literal>,
923 which is, by default, used by a udev rule to set
924 <literal>NAME</literal>. The available policies are:
925 </para>
1f06807c 926 <variablelist>
e51660ae
TG
927 <varlistentry>
928 <term><literal>database</literal></term>
929 <listitem>
930 <para>The name is set based on entries in the Hardware
931 Database with the key
932 <literal>ID_NET_NAME_FROM_DATABASE</literal>.
933 </para>
934 </listitem>
935 </varlistentry>
1f06807c
TG
936 <varlistentry>
937 <term><literal>onboard</literal></term>
938 <listitem>
bcddd5bf
JSJ
939 <para>The name is set based on information given by the
940 firmware for on-board devices, as exported by the udev
941 property <literal>ID_NET_NAME_ONBOARD</literal>.
942 </para>
1f06807c
TG
943 </listitem>
944 </varlistentry>
945 <varlistentry>
946 <term><literal>slot</literal></term>
947 <listitem>
bcddd5bf
JSJ
948 <para>The name is set based on information given by the
949 firmware for hot-plug devices, as exported by the udev
950 property <literal>ID_NET_NAME_SLOT</literal>.
951 </para>
1f06807c
TG
952 </listitem>
953 </varlistentry>
954 <varlistentry>
955 <term><literal>path</literal></term>
956 <listitem>
bcddd5bf
JSJ
957 <para>The name is set based on the device's physical location,
958 as exported by the udev property
959 <literal>ID_NET_NAME_PATH</literal>.
960 </para>
1f06807c
TG
961 </listitem>
962 </varlistentry>
963 <varlistentry>
964 <term><literal>mac</literal></term>
965 <listitem>
bcddd5bf
JSJ
966 <para>The name is set based on the device's persistent MAC
967 address, as exported by the udev property
968 <literal>ID_NET_NAME_MAC</literal>.
969 </para>
1f06807c
TG
970 </listitem>
971 </varlistentry>
972 </variablelist>
973 </listitem>
974 </varlistentry>
975 <varlistentry>
c8f57f59 976 <term><varname>Name=</varname></term>
1f06807c 977 <listitem>
bcddd5bf 978 <para>The interface name to use in case all the policies specified
c8f57f59
LP
979 in <varname>NamePolicy=</varname> fail, or in case
980 <varname>NamePolicy=</varname> is missing or disabled.
bcddd5bf 981 </para>
1f06807c
TG
982 </listitem>
983 </varlistentry>
984 <varlistentry>
733f7a2c 985 <term><varname>MTUBytes=</varname></term>
1f06807c 986 <listitem>
5556b5fe
LP
987 <para>The maximum transmission unit in bytes to set for
988 the device. The usual suffixes K, M, G, are supported and
989 are understood to the base of 1024.</para>
1f06807c
TG
990 </listitem>
991 </varlistentry>
992 <varlistentry>
733f7a2c 993 <term><varname>BitsPerSecond=</varname></term>
1f06807c 994 <listitem>
5556b5fe
LP
995 <para>The speed to set for the device, the value is
996 rounded down to the nearest Mbps. The usual suffixes K, M,
997 G, are supported and are understood to the base of
998 1000.</para>
1f06807c
TG
999 </listitem>
1000 </varlistentry>
1001 <varlistentry>
c8f57f59 1002 <term><varname>Duplex=</varname></term>
1f06807c 1003 <listitem>
bcddd5bf
JSJ
1004 <para>The duplex mode to set for the device. The accepted values
1005 are <literal>half</literal> and <literal>full</literal>.
1006 </para>
1f06807c
TG
1007 </listitem>
1008 </varlistentry>
1009 <varlistentry>
c8f57f59 1010 <term><varname>WakeOnLan=</varname></term>
1f06807c 1011 <listitem>
bcddd5bf
JSJ
1012 <para>The Wake-on-LAN policy to set for the device. The supported
1013 values are:
1014 </para>
1f06807c
TG
1015 <variablelist>
1016 <varlistentry>
1017 <term><literal>phy</literal></term>
1018 <listitem>
1019 <para>Wake on PHY activity.</para>
1020 </listitem>
1021 </varlistentry>
1022 <varlistentry>
1023 <term><literal>magic</literal></term>
1024 <listitem>
bcddd5bf 1025 <para>Wake on receipt of a magic packet.</para>
1f06807c
TG
1026 </listitem>
1027 </varlistentry>
1028 <varlistentry>
1029 <term><literal>off</literal></term>
1030 <listitem>
1031 <para>Never wake.</para>
1032 </listitem>
1033 </varlistentry>
1034 </variablelist>
1035 </listitem>
1036 </varlistentry>
1037 </variablelist>
1038 </refsect1>
1039
63749b1a
KS
1040 <refsect1>
1041 <title>See Also</title>
bcddd5bf
JSJ
1042 <para>
1043 <citerefentry>
b79f817b 1044 <refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum>
ad29a9f1 1045 </citerefentry>,
63749b1a
KS
1046 <citerefentry>
1047 <refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum>
bcddd5bf
JSJ
1048 </citerefentry>
1049 </para>
63749b1a
KS
1050 </refsect1>
1051</refentry>