The udevadm command is used to manage udev. It takes various subcommands, each of which performs a certain task to modify the behavior of the systemd-udevd daemon and related components. Some of these subcommands are described in the following table.
|info||Retrieve device information stored in the udev database, as well as detailed device attributes from the /sys/ filesystem. For example, you can view a device’s vendor ID, product ID, serial number, and much more.|
|control||Modify the running state of udev. For example, providing the –reload-rules option will ensure that udev is reading from any new rules files you’ve added.|
|trigger||Execute rules that apply to any device that is currently plugged in. You can also specify an action using the -c option, such as add, remove, or change. As the names imply, these will trigger events where a device is added, removed, or changed in the running kernel.|
|monitor||Watch for events sent by the kernel or by a udev rule.|
|test||Simulate a udev event running for a device, with results on output.|
With the udevadm monitor command, you can tap into udev in real time and see what it sees when you plug in different devices. Try it as root.
# udevadm monitor
The monitor function prints received events for
- UDEV: The event which udev sends out after rule processing.
- KERNEL: The kernel uevent.
With udevadm monitor running, plug in a thumb drive and watch as all kinds of information are spewed out onto your screen. Notice, particularly, that the type of event is an ADD event. That’s a good way of identifying what type of event you want.
The syntax of the udevadm command is:
# udevadm [options] [subcommand] [arguments]
udevadm Command Examples
1. Monitor all device events:
# udevadm monitor
2. Print `uevents` sent out by the kernel:
# udevadm monitor --kernel
3. Print device events after being processed by `udev`:
# udevadm monitor --udev
4. List attributes of a device:
# udevadm info --attribute-walk --path /dev/sda1
5. Reload all `udev` rules:
# udevadm control --reload-rules
6. Trigger all `udev` rules to run:
# udevadm trigger