What it does
When the kernel finds a device it sends an event; systemd-udevd applies the rules from /usr/lib/udev/rules.d/ and /etc/udev/rules.d/: create /dev names and links (like /dev/disk/by-uuid/), set owners, load modules, run programs. udevadm shows device properties (info), watches events (monitor), replays events (trigger), waits for them (settle) and reloads rules (control).
How to write it
udevadm [-d] COMMAND [OPTION]...Main parts
info- Show the properties of a device or the udev database.
monitor- Print kernel and udev events live.
trigger- Ask the kernel to send events again (apply new rules).
settle- Wait until all events are handled.
control- Control the udev daemon (reload rules, log level).
test- Simulate an event for a device and show the rules used.
test-builtin- Test a built-in command.
verify- Check rule files for errors (newer systemd).
wait- Wait until a device is ready.
lock- Lock a block device during a command.
cat- Show rule files (newer systemd).
Options 38
Most used
info
monitor
trigger
settle
control
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1Properties of a disk
udevadm info /dev/vdbID_SERIAL, ID_PATH, DEVLINKS (by-id, by-path …).
2Watch events while plugging in
udevadm monitor -pKernel events (KERNEL) and udev events (UDEV) with all properties.
3Only block devices
udevadm monitor -s blockDisks and partitions.
4Attributes for a rule
udevadm info -a -n /dev/sdc | lessUse ATTRS{serial}=="…" in your rule.
5A rule for a fixed name
echo 'SUBSYSTEM=="block", ENV{ID_SERIAL}=="SanDisk_Ultra_Fit_4C53…", SYMLINK+="backupdisk"' > /etc/udev/rules.d/90-backup.rules/dev/backupdisk appears for that stick.
6Reload and apply rules
udevadm control --reload udevadm trigger -s blockNew rules work without a reboot.
7Wait for devices in scripts
partprobe /dev/vdb; udevadm settlePartition devices exist after settle.
8Test which rules apply
udevadm test $(udevadm info -q path -n /dev/vdb) 2>&1 | tailDebug a rule that does not work.
9Find the stable names of a disk
udevadm info -q symlink -n /dev/vdbby-id and by-path names for fstab or LVM filters.
10Block rogue USB devices with a rule (security)
echo 'ACTION=="add", SUBSYSTEMS=="usb", ATTR{authorized}="0"' > /etc/udev/rules.d/99-usb-deny.rulesNew USB devices are not authorized (keyboards too! use USBGuard in production).
Nothing matches this filter.
Files
/usr/lib/udev/rules.d/- Rules from packages.
/etc/udev/rules.d/- Your rules (win over the same name).
/run/udev/data/- udev database.
Exit codes
0 | Done. |
1 | Error. |