udevadm
Manage and monitor udev event subsystem
TLDR
Monitor all device events
Print uevents sent out by the kernel
Print device events after being processed by udev
List attributes of device /dev/sda
Reload all udev rules
Trigger all udev rules to run
Test an event run by simulating loading of /dev/sda
SYNOPSIS
udevadm [OPTIONS] COMMAND [COMMAND_OPTIONS] [ARGUMENTS]
Common commands include:
udevadm control [OPTIONS] COMMAND
udevadm info [OPTIONS] {DEVICE | FILE | PATH}
udevadm monitor [OPTIONS]
udevadm trigger [OPTIONS]
udevadm settle [OPTIONS]
udevadm test [OPTIONS] {DEVICE_PATH | SYSFS_PATH}
udevadm hwdb [OPTIONS] COMMAND
PARAMETERS
--debug, -d
Print debug messages to the console for detailed output.
--version
Show the version number of the udevadm utility.
--help
Show a help message for udevadm or a specific subcommand.
-q, --query=TYPE
(info subcommand) Query specified device properties of a given TYPE (e.g., name, path, all).
-a, --attribute-walk
(info subcommand) Query attributes of the specified device and all its parent devices in sysfs.
-p, --path=SYSFS_PATH
(info subcommand) Specify a device by its sysfs path (e.g., /sys/class/block/sda).
-n, --name=DEV_NAME
(info subcommand) Specify a device by its device node name (e.g., sda).
--log-priority=LEVEL
(control subcommand) Set the logging priority of the udev daemon to LEVEL (e.g., info, debug).
--reload-rules
(control subcommand) Request the udev daemon to reload its rules files from disk.
-k, --kernel
(monitor subcommand) Monitor kernel uevents directly from the kernel.
-u, --udev
(monitor subcommand) Monitor udev events, which include information processed by udev rules.
-s, --subsystem=SUBSYS
(monitor/trigger subcommands) Filter events by a specific device SUBSYS (e.g., block, net).
-t, --tag=TAG
(monitor/trigger subcommands) Filter events by a udev TAG defined in rules.
--dry-run
(trigger subcommand) Do not actually trigger events, just print what would be triggered.
--action=ACTION
(trigger/test subcommands) Specify the ACTION to simulate (e.g., add, change, remove).
--timeout=SECONDS
(settle subcommand) Wait for at most SECONDS for all pending events to finish processing.
-E, --exit-if-idle
(settle subcommand) Exit immediately if no events are pending, without waiting for the timeout.
DESCRIPTION
udevadm is a command-line utility used to manage the udev daemon, query the udev database, control udev device events, and debug udev rules. It provides various subcommands to interact with the udev system. For instance, it can monitor kernel events, trigger device events, test udev rules against specific devices, or settle pending udev events.
udev itself is a device manager for the Linux kernel, dynamically creating device nodes (/dev/) and handling device events. udevadm is an essential tool for system administrators and developers to understand and troubleshoot how the kernel detects and manages hardware devices. It plays a crucial role in ensuring that devices are correctly recognized, configured, and accessible upon connection or boot.
CAVEATS
Most operations of udevadm, particularly those involving modifications like control or trigger, require root privileges.
The udevadm test subcommand is a simulation tool and does not make any actual changes to the system; it's solely for debugging udev rules.
Effective use often requires a good understanding of the sysfs filesystem structure and udev rule syntax.
UDEV RULES
udevadm is frequently used in conjunction with udev rules, which are typically found in /etc/udev/rules.d/ and /lib/udev/rules.d/. These rules define how udev processes device events, allowing for actions like creating specific symbolic links, setting file permissions, or executing external scripts. The udevadm test subcommand is an indispensable tool for debugging and validating these rules before deployment.
DEVICE ATTRIBUTES IN SYSFS
The sysfs filesystem (mounted at /sys) exports a hierarchical view of the kernel's device model, exposing various device attributes. The udevadm info -a command is particularly useful as it traverses up the sysfs tree from a specified device, displaying all discoverable attributes. These attributes are fundamental for writing precise and robust udev rules that target specific hardware characteristics.
HISTORY
udev replaced the older devfs in the Linux kernel 2.6 series, addressing its limitations such as non-persistent device names. udev was designed to provide dynamic and persistent device naming based on unique device attributes like bus paths or serial numbers. udevadm was developed as the primary user-space utility to interact with this new device management system. Its functionality has evolved alongside udev, which eventually became an integral part of the systemd project, consolidating device management and initialization processes.