Custom udev rules
udev (the device manager for the Linux kernel) uses rules to manage device events (e.g., when a USB is plugged in). Rules are typically stored in /etc/udev/rules.d/
or /lib/udev/rules.d/
as files with a .rules
extension (e.g., 10-my-rule.rules). Lower-numbered files are processed first.
udev Rule
A rule consists of match keys (conditions) and assignment keys (actions), written in the format:
- Match keys: Conditions to identify a device (e.g., SUBSYSTEM, ATTR).
- Assignment keys: Actions to take (e.g., NAME, RUN, SYMLINK).
demos
Set symbolic name
Set symbolic name every time my arduino mega connected
- udevadm: A utility for managing and querying udev, the Linux device manager.
- info: A subcommand that provides information about a device.
- -a : Walks up the device tree (from the specified device to its parents) and shows all attributes available for matching in udev rules.
- -p : Specifies the sysfs path of the device to query
/sys/class/tty/ttyACM0
.
result: Show only the part i use for the rule
/etc/udev/rules.d/91-arduino.rules | |
---|---|
check
- Disconnect / Connect the device for
add
event
TODO
- explain monitor
- explain device tree
- explain ATTR ATTRS ENV
- explain SUBSYSTEMS
Set permission
Set permission to usb device