]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/udevadm.xml
travis: use UBSan checks from OSS-Fuzz
[thirdparty/systemd.git] / man / udevadm.xml
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
5
6 <refentry id="udevadm"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>udevadm</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>udevadm</refentrytitle>
16 <manvolnum>8</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>udevadm</refname><refpurpose>udev management tool</refpurpose>
21 </refnamediv>
22
23 <refsynopsisdiv>
24 <cmdsynopsis>
25 <command>udevadm</command>
26 <arg><option>--debug</option></arg>
27 <arg><option>--version</option></arg>
28 <arg><option>--help</option></arg>
29 </cmdsynopsis>
30 <cmdsynopsis>
31 <command>udevadm info <optional>options</optional> <optional>devpath</optional></command>
32 </cmdsynopsis>
33 <cmdsynopsis>
34 <command>udevadm trigger <optional>options</optional> <optional>devpath</optional></command>
35 </cmdsynopsis>
36 <cmdsynopsis>
37 <command>udevadm settle <optional>options</optional></command>
38 </cmdsynopsis>
39 <cmdsynopsis>
40 <command>udevadm control <replaceable>option</replaceable></command>
41 </cmdsynopsis>
42 <cmdsynopsis>
43 <command>udevadm monitor <optional>options</optional></command>
44 </cmdsynopsis>
45 <cmdsynopsis>
46 <command>udevadm test <optional>options</optional> <replaceable>devpath</replaceable></command>
47 </cmdsynopsis>
48 <cmdsynopsis>
49 <command>udevadm test-builtin <optional>options</optional> <replaceable>command</replaceable> <replaceable>devpath</replaceable></command>
50 </cmdsynopsis>
51 </refsynopsisdiv>
52
53 <refsect1><title>Description</title>
54 <para><command>udevadm</command> expects a command and command
55 specific options. It controls the runtime behavior of
56 <command>systemd-udevd</command>, requests kernel events, manages
57 the event queue, and provides simple debugging mechanisms.</para>
58 </refsect1>
59
60 <refsect1><title>Options</title>
61 <variablelist>
62 <varlistentry>
63 <term><option>-d</option></term>
64 <term><option>--debug</option></term>
65 <listitem>
66 <para>Print debug messages to standard error. This option is implied in <command>udevadm test</command> and
67 <command>udevadm test-builtin</command> commands.</para>
68 </listitem>
69 </varlistentry>
70
71 <xi:include href="standard-options.xml" xpointer="help" />
72 </variablelist>
73
74 <refsect2><title>udevadm info
75 <arg choice="opt"><replaceable>options</replaceable></arg>
76 <arg choice="opt" rep="repeat"><replaceable>devpath</replaceable>|<replaceable>file</replaceable>|<replaceable>unit</replaceable></arg>
77 </title>
78
79 <para>Query the udev database for device information.</para>
80
81 <para>Positional arguments should be used to specify one or more devices. Each one may be a device name
82 (in which case it must start with <filename>/dev/</filename>), a sys path (in which case it must start
83 with <filename>/sys/</filename>), or a systemd device unit name (in which case it must end with
84 <literal>.device</literal>, see
85 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
86 </para>
87
88 <variablelist>
89 <varlistentry>
90 <term><option>-q</option></term>
91 <term><option>--query=<replaceable>TYPE</replaceable></option></term>
92 <listitem>
93 <para>Query the database for the specified type of device data.
94 Valid <replaceable>TYPE</replaceable>s are:
95 <constant>name</constant>, <constant>symlink</constant>,
96 <constant>path</constant>, <constant>property</constant>,
97 <constant>all</constant>.</para>
98 </listitem>
99 </varlistentry>
100
101 <varlistentry>
102 <term><option>-p</option></term>
103 <term><option>--path=<replaceable>DEVPATH</replaceable></option></term>
104 <listitem>
105 <para>The <filename>/sys</filename> path of the device to query, e.g.
106 <filename><optional>/sys</optional>/class/block/sda</filename>. This option is an alternative to
107 the positional argument with a <filename>/sys/</filename> prefix. <command>udevadm info
108 --path=/class/block/sda</command> is equivalent to <command>udevadm info
109 /sys/class/block/sda</command>.</para>
110 </listitem>
111 </varlistentry>
112 <varlistentry>
113 <term><option>-n</option></term>
114 <term><option>--name=<replaceable>FILE</replaceable></option></term>
115 <listitem>
116 <para>The name of the device node or a symlink to query,
117 e.g. <filename><optional>/dev</optional>/sda</filename>. This option is an alternative to the
118 positional argument with a <filename>/dev/</filename> prefix. <command>udevadm info
119 --name=sda</command> is equivalent to <command>udevadm info /dev/sda</command>.</para>
120 </listitem>
121 </varlistentry>
122 <varlistentry>
123 <term><option>-r</option></term>
124 <term><option>--root</option></term>
125 <listitem>
126 <para>Print absolute paths in <command>name</command> or <command>symlink</command>
127 query.</para>
128 </listitem>
129 </varlistentry>
130 <varlistentry>
131 <term><option>-a</option></term>
132 <term><option>--attribute-walk</option></term>
133 <listitem>
134 <para>Print all sysfs properties of the specified device that can be used
135 in udev rules to match the specified device. It prints all devices
136 along the chain, up to the root of sysfs that can be used in udev rules.</para>
137 </listitem>
138 </varlistentry>
139 <varlistentry>
140 <term><option>-x</option></term>
141 <term><option>--export</option></term>
142 <listitem>
143 <para>Print output as key/value pairs. Values are enclosed in single quotes.
144 This takes effects only when <option>--query=property</option> or
145 <option>--device-id-of-file=<replaceable>FILE</replaceable></option> is specified.</para>
146 </listitem>
147 </varlistentry>
148 <varlistentry>
149 <term><option>-P</option></term>
150 <term><option>--export-prefix=<replaceable>NAME</replaceable></option></term>
151 <listitem>
152 <para>Add a prefix to the key name of exported values.
153 This implies <option>--export</option>.</para>
154 </listitem>
155 </varlistentry>
156 <varlistentry>
157 <term><option>-d</option></term>
158 <term><option>--device-id-of-file=<replaceable>FILE</replaceable></option></term>
159 <listitem>
160 <para>Print major/minor numbers of the underlying device, where the file lives on.
161 If this is specified, all positional arguments are ignored.</para>
162 </listitem>
163 </varlistentry>
164 <varlistentry>
165 <term><option>-e</option></term>
166 <term><option>--export-db</option></term>
167 <listitem>
168 <para>Export the content of the udev database.</para>
169 </listitem>
170 </varlistentry>
171 <varlistentry>
172 <term><option>-c</option></term>
173 <term><option>--cleanup-db</option></term>
174 <listitem>
175 <para>Cleanup the udev database.</para>
176 </listitem>
177 </varlistentry>
178 <varlistentry>
179 <term><option>-w<optional>SECONDS</optional></option></term>
180 <term><option>--wait-for-initialization<optional>=SECONDS</optional></option></term>
181 <listitem>
182 <para>Wait for device to be initialized. If argument <replaceable>SECONDS</replaceable>
183 is not specified, the default is to wait forever.</para>
184 </listitem>
185 </varlistentry>
186
187 <xi:include href="standard-options.xml" xpointer="help" />
188 </variablelist>
189 </refsect2>
190
191 <refsect2><title>udevadm trigger
192 <arg choice="opt"><replaceable>options</replaceable></arg>
193 <arg choice="opt"><replaceable>devpath</replaceable>|<replaceable>file</replaceable>|<replaceable>unit</replaceable></arg>
194 </title>
195 <para>Request device events from the kernel. Primarily used to replay events at system coldplug time.</para>
196
197 <para>Takes device specifications as positional arguments. See the description of <command>info</command>
198 above.</para>
199
200 <variablelist>
201 <varlistentry>
202 <term><option>-v</option></term>
203 <term><option>--verbose</option></term>
204 <listitem>
205 <para>Print the list of devices which will be triggered.</para>
206 </listitem>
207 </varlistentry>
208 <varlistentry>
209 <term><option>-n</option></term>
210 <term><option>--dry-run</option></term>
211 <listitem>
212 <para>Do not actually trigger the event.</para>
213 </listitem>
214 </varlistentry>
215 <varlistentry>
216 <term><option>-t</option></term>
217 <term><option>--type=<replaceable>TYPE</replaceable></option></term>
218 <listitem>
219 <para>Trigger a specific type of devices. Valid types are:
220 <command>devices</command>, <command>subsystems</command>.
221 The default value is <command>devices</command>.</para>
222 </listitem>
223 </varlistentry>
224 <varlistentry>
225 <term><option>-c</option></term>
226 <term><option>--action=<replaceable>ACTION</replaceable></option></term>
227 <listitem>
228 <para>Type of event to be triggered. Possible actions are <literal>add</literal>,
229 <literal>remove</literal>, <literal>change</literal>, <literal>move</literal>,
230 <literal>online</literal>, <literal>offline</literal>, <literal>bind</literal>,
231 and <literal>unbind</literal>. The default value is <literal>change</literal>.</para>
232 </listitem>
233 </varlistentry>
234 <varlistentry>
235 <term><option>-s</option></term>
236 <term><option>--subsystem-match=<replaceable>SUBSYSTEM</replaceable></option></term>
237 <listitem>
238 <para>Trigger events for devices which belong to a
239 matching subsystem. This option supports shell style pattern matching.
240 When this option is specified more than once, then each matching result is ORed, that is,
241 all the devices in each subsystem are triggered.</para>
242 </listitem>
243 </varlistentry>
244 <varlistentry>
245 <term><option>-S</option></term>
246 <term><option>--subsystem-nomatch=<replaceable>SUBSYSTEM</replaceable></option></term>
247 <listitem>
248 <para>Do not trigger events for devices which belong to a matching subsystem. This option
249 supports shell style pattern matching. When this option is specified more than once,
250 then each matching result is ANDed, that is, devices which do not match all specified
251 subsystems are triggered.</para>
252 </listitem>
253 </varlistentry>
254 <varlistentry>
255 <term><option>-a</option></term>
256 <term><option>--attr-match=<replaceable>ATTRIBUTE</replaceable>=<replaceable>VALUE</replaceable></option></term>
257 <listitem>
258 <para>Trigger events for devices with a matching sysfs attribute. If a value is specified along
259 with the attribute name, the content of the attribute is matched against the given value using
260 shell style pattern matching. If no value is specified, the existence of the sysfs attribute is
261 checked. When this option is specified multiple times, then each matching result is ANDed,
262 that is, only devices which have all specified attributes are triggered.</para>
263 </listitem>
264 </varlistentry>
265 <varlistentry>
266 <term><option>-A</option></term>
267 <term><option>--attr-nomatch=<replaceable>ATTRIBUTE</replaceable>=<replaceable>VALUE</replaceable></option></term>
268 <listitem>
269 <para>Do not trigger events for devices with a matching sysfs attribute. If a value is specified
270 along with the attribute name, the content of the attribute is matched against the given value
271 using shell style pattern matching. If no value is specified, the existence of the sysfs attribute
272 is checked. When this option is specified multiple times, then each matching result is ANDed,
273 that is, only devices which have none of the specified attributes are triggered.</para>
274 </listitem>
275 </varlistentry>
276 <varlistentry>
277 <term><option>-p</option></term>
278 <term><option>--property-match=<replaceable>PROPERTY</replaceable>=<replaceable>VALUE</replaceable></option></term>
279 <listitem>
280 <para>Trigger events for devices with a matching property value. This option supports shell style
281 pattern matching. When this option is specified more than once, then each matching result is ORed,
282 that is, devices which have one of the specified properties are triggered.</para>
283 </listitem>
284 </varlistentry>
285 <varlistentry>
286 <term><option>-g</option></term>
287 <term><option>--tag-match=<replaceable>PROPERTY</replaceable></option></term>
288 <listitem>
289 <para>Trigger events for devices with a matching tag. When this option is specified multiple times,
290 then each matching result is ANDed, that is, devices which have all specified tags are triggered.</para>
291 </listitem>
292 </varlistentry>
293 <varlistentry>
294 <term><option>-y</option></term>
295 <term><option>--sysname-match=<replaceable>NAME</replaceable></option></term>
296 <listitem>
297 <para>Trigger events for devices for which the last component (i.e. the filename) of the
298 <filename>/sys</filename> path matches the specified <replaceable>PATH</replaceable>. This option
299 supports shell style pattern matching. When this option is specified more than once, then each
300 matching result is ORed, that is, all devices which have any of the specified
301 <replaceable>NAME</replaceable> are triggered.</para>
302 </listitem>
303 </varlistentry>
304 <varlistentry>
305 <term><option>--name-match=<replaceable>NAME</replaceable></option></term>
306 <listitem>
307 <para>Trigger events for devices with a matching device path. When this option is specified more than once,
308 then each matching result is ORed, that is, all specified devices are triggered.</para>
309 </listitem>
310 </varlistentry>
311 <varlistentry>
312 <term><option>-b</option></term>
313 <term><option>--parent-match=<replaceable>SYSPATH</replaceable></option></term>
314 <listitem>
315 <para>Trigger events for all children of a given device. When this option is specified more than once,
316 then each matching result is ORed, that is, all children of each specified device are triggered.</para>
317 </listitem>
318 </varlistentry>
319 <varlistentry>
320 <term><option>-w</option></term>
321 <term><option>--settle</option></term>
322 <listitem>
323 <para>Apart from triggering events, also waits for those events to
324 finish. Note that this is different from calling <command>udevadm
325 settle</command>. <command>udevadm settle</command> waits for all
326 events to finish. This option only waits for events triggered by
327 the same command to finish.</para>
328 </listitem>
329 </varlistentry>
330 <varlistentry>
331 <term><option>--wait-daemon[=<replaceable>SECONDS</replaceable>]</option></term>
332 <listitem>
333 <para>Before triggering uevents, wait for systemd-udevd daemon to be initialized.
334 Optionally takes timeout value. Default timeout is 5 seconds. This is equivalent to invoke
335 invoking <command>udevadm control --ping</command> before <command>udevadm trigger</command>.</para>
336 </listitem>
337 </varlistentry>
338
339 <xi:include href="standard-options.xml" xpointer="help" />
340 </variablelist>
341
342 <para>In addition, optional positional arguments can be used
343 to specify device names or sys paths. They must start with
344 <filename>/dev</filename> or <filename>/sys</filename>
345 respectively.</para>
346 </refsect2>
347
348 <refsect2><title>udevadm settle
349 <arg choice="opt"><replaceable>options</replaceable></arg>
350 </title>
351 <para>Watches the udev event queue, and exits if all current events are handled.</para>
352 <variablelist>
353 <varlistentry>
354 <term><option>-t</option></term>
355 <term><option>--timeout=<replaceable>SECONDS</replaceable></option></term>
356 <listitem>
357 <para>Maximum number of seconds to wait for the event
358 queue to become empty. The default value is 120 seconds. A
359 value of 0 will check if the queue is empty and always
360 return immediately.</para>
361 </listitem>
362 </varlistentry>
363 <varlistentry>
364 <term><option>-E</option></term>
365 <term><option>--exit-if-exists=<replaceable>FILE</replaceable></option></term>
366 <listitem>
367 <para>Stop waiting if file exists.</para>
368 </listitem>
369 </varlistentry>
370
371 <xi:include href="standard-options.xml" xpointer="help" />
372 </variablelist>
373
374 <para>See
375 <citerefentry><refentrytitle>systemd-udev-settle.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
376 for more information.</para>
377 </refsect2>
378
379 <refsect2><title>udevadm control <replaceable>option</replaceable></title>
380 <para>Modify the internal state of the running udev daemon.</para>
381 <variablelist>
382 <varlistentry>
383 <term><option>-e</option></term>
384 <term><option>--exit</option></term>
385 <listitem>
386 <para>Signal and wait for systemd-udevd to exit. No option except for
387 <option>--timeout</option> can be specified after this option.
388 Note that <filename>systemd-udevd.service</filename> contains
389 <option>Restart=always</option> and so as a result, this option restarts systemd-udevd.
390 If you want to stop <filename>systemd-udevd.service</filename>, please use the following:
391 <programlisting>systemctl stop systemd-udevd-control.socket systemd-udevd-kernel.socket systemd-udevd.service</programlisting>
392 </para>
393 </listitem>
394 </varlistentry>
395 <varlistentry>
396 <term><option>-l</option></term>
397 <term><option>--log-priority=<replaceable>value</replaceable></option></term>
398 <listitem>
399 <para>Set the internal log level of
400 <filename>systemd-udevd</filename>. Valid values are the
401 numerical syslog priorities or their textual
402 representations: <option>emerg</option>,
403 <option>alert</option>, <option>crit</option>,
404 <option>err</option>, <option>warning</option>,
405 <option>notice</option>, <option>info</option>, and
406 <option>debug</option>.</para>
407 </listitem>
408 </varlistentry>
409 <varlistentry>
410 <term><option>-s</option></term>
411 <term><option>--stop-exec-queue</option></term>
412 <listitem>
413 <para>Signal systemd-udevd to stop executing new events. Incoming events
414 will be queued.</para>
415 </listitem>
416 </varlistentry>
417 <varlistentry>
418 <term><option>-S</option></term>
419 <term><option>--start-exec-queue</option></term>
420 <listitem>
421 <para>Signal systemd-udevd to enable the execution of events.</para>
422 </listitem>
423 </varlistentry>
424 <varlistentry>
425 <term><option>-R</option></term>
426 <term><option>--reload</option></term>
427 <listitem>
428 <para>Signal systemd-udevd to reload the rules files and other databases like the kernel
429 module index. Reloading rules and databases does not apply any changes to already
430 existing devices; the new configuration will only be applied to new events.</para>
431 </listitem>
432 </varlistentry>
433 <varlistentry>
434 <term><option>-p</option></term>
435 <term><option>--property=<replaceable>KEY</replaceable>=<replaceable>value</replaceable></option></term>
436 <listitem>
437 <para>Set a global property for all events.</para>
438 </listitem>
439 </varlistentry>
440 <varlistentry>
441 <term><option>-m</option></term>
442 <term><option>--children-max=</option><replaceable>value</replaceable></term>
443 <listitem>
444 <para>Set the maximum number of events, systemd-udevd will handle at the
445 same time.</para>
446 </listitem>
447 </varlistentry>
448 <varlistentry>
449 <term><option>--ping</option></term>
450 <listitem>
451 <para>Send a ping message to systemd-udevd and wait for the reply. This may be useful to check that
452 systemd-udevd daemon is running.</para>
453 </listitem>
454 </varlistentry>
455 <varlistentry>
456 <term><option>-t</option></term>
457 <term><option>--timeout=</option><replaceable>seconds</replaceable></term>
458 <listitem>
459 <para>The maximum number of seconds to wait for a reply from systemd-udevd.</para>
460 </listitem>
461 </varlistentry>
462
463 <xi:include href="standard-options.xml" xpointer="help" />
464 </variablelist>
465 </refsect2>
466
467 <refsect2><title>udevadm monitor
468 <arg choice="opt"><replaceable>options</replaceable></arg>
469 </title>
470 <para>Listens to the kernel uevents and events sent out by a udev rule
471 and prints the devpath of the event to the console. It can be used to analyze the
472 event timing, by comparing the timestamps of the kernel uevent and the udev event.
473 </para>
474 <variablelist>
475 <varlistentry>
476 <term><option>-k</option></term>
477 <term><option>--kernel</option></term>
478 <listitem>
479 <para>Print the kernel uevents.</para>
480 </listitem>
481 </varlistentry>
482 <varlistentry>
483 <term><option>-u</option></term>
484 <term><option>--udev</option></term>
485 <listitem>
486 <para>Print the udev event after the rule processing.</para>
487 </listitem>
488 </varlistentry>
489 <varlistentry>
490 <term><option>-p</option></term>
491 <term><option>--property</option></term>
492 <listitem>
493 <para>Also print the properties of the event.</para>
494 </listitem>
495 </varlistentry>
496 <varlistentry>
497 <term><option>-s</option></term>
498 <term><option>--subsystem-match=<replaceable>string[/string]</replaceable></option></term>
499 <listitem>
500 <para>Filter kernel uevents and udev events by subsystem[/devtype]. Only events with a matching subsystem value will pass.
501 When this option is specified more than once, then each matching result is ORed, that is, all devices in the specified
502 subsystems are monitored.</para>
503 </listitem>
504 </varlistentry>
505 <varlistentry>
506 <term><option>-t</option></term>
507 <term><option>--tag-match=<replaceable>string</replaceable></option></term>
508 <listitem>
509 <para>Filter udev events by tag. Only udev events with a given tag attached will pass.
510 When this option is specified more than once, then each matching result is ORed, that is, devices which have one of the
511 specified tags are monitored.</para>
512 </listitem>
513 </varlistentry>
514
515 <xi:include href="standard-options.xml" xpointer="help" />
516 </variablelist>
517 </refsect2>
518
519 <refsect2><title>udevadm test
520 <arg choice="opt"><replaceable>options</replaceable></arg>
521 <arg><replaceable>devpath</replaceable></arg>
522 </title>
523 <para>Simulate a udev event run for the given device, and print debug output.</para>
524 <variablelist>
525 <varlistentry>
526 <term><option>-a</option></term>
527 <term><option>--action=<replaceable>string</replaceable></option></term>
528 <listitem>
529 <para>The action string.</para>
530 </listitem>
531 </varlistentry>
532 <varlistentry>
533 <term><option>-N</option></term>
534 <term><option>--resolve-names=<constant>early</constant>|<constant>late</constant>|<constant>never</constant></option></term>
535 <listitem>
536 <para>Specify when udevadm should resolve names of users
537 and groups. When set to <constant>early</constant> (the
538 default), names will be resolved when the rules are
539 parsed. When set to <constant>late</constant>, names will
540 be resolved for every event. When set to
541 <constant>never</constant>, names will never be resolved
542 and all devices will be owned by root.</para>
543 </listitem>
544 </varlistentry>
545
546 <xi:include href="standard-options.xml" xpointer="help" />
547 </variablelist>
548 </refsect2>
549
550 <refsect2><title>udevadm test-builtin
551 <arg choice="opt"><replaceable>options</replaceable></arg>
552 <arg><replaceable>command</replaceable></arg>
553 <arg><replaceable>devpath</replaceable></arg>
554 </title>
555 <para>Run a built-in command <replaceable>COMMAND</replaceable>
556 for device <replaceable>DEVPATH</replaceable>, and print debug
557 output.</para>
558 <variablelist>
559 <xi:include href="standard-options.xml" xpointer="help" />
560 </variablelist>
561 </refsect2>
562 </refsect1>
563
564 <refsect1>
565 <title>See Also</title>
566 <para><citerefentry>
567 <refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum>
568 </citerefentry>,
569 <citerefentry>
570 <refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum>
571 </citerefentry></para>
572 </refsect1>
573 </refentry>