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.
Subcommand | Used To |
---|---|
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. |
Syntax
The syntax of the udevadm command is:
# udevadm [options] [subcommand] [arguments]
If you encounter the below error while running the udevadm command:
udevadm: command not found
you may try installing the below package as per your choice of distribution:
OS Distribution | Command |
---|---|
Debian | apt-get install udev |
Ubuntu | apt-get install udev |
Alpine | apk add udev |
Arch Linux | pacman -S systemd |
Kali Linux | apt-get install udev |
CentOS | yum install udev |
Fedora | dnf install systemd-udev |
Raspbian | apt-get install udev |
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