Due to the interest of this subject, I would like to emphasize that udev rules has other very useful features, for example:
1. if you had GROUP="dialout", the device will belong to that group. This means that all users in the dialout group have special permissions to work with the device.
Code:
ACTION=="add", SUBSYSTEM=="usb_device", SYSFS{idVendor}=="040a", SYSFS{idProduct}=="0576", GROUP="dialout"
2. if you had SYMLINK+="ladys_camera", a ladys_camera device will be added to your /dev.
This could be very usefull if you use several usb devices (as most of us do), because their device (/dev/ttyUSB[0-9]) is set depending on plug order.
This way /dev/ladys_camera will always be your lady's camera.
Code:
ACTION=="add", SUBSYSTEM=="usb_device", SYSFS{idVendor}=="040a", SYSFS{idProduct}=="0576", SYMLINK+="ladys_camera"
3. Also notice that udev rules work with all king of devices: usb, serial, pcmcia, ...
udev rules is a simple and easy way to configure all devices (it can configure, load modules, run scripts, set permissions for all your hardware).
Final notes:
A. Each line is a device. If you want to break a line add \ at the end
Code:
ACTION=="add", SUBSYSTEM=="usb_device", \
SYSFS{idVendor}=="040a", SYSFS{idProduct}=="0576", \
SYMLINK+="ladys_camera"
B. You can add simultaneous actions in the same line (like group assignment and symbolic link)
Code:
ACTION=="add", SUBSYSTEM=="usb_device", SYSFS{idVendor}=="040a", SYSFS{idProduct}=="0576", GROUP="dialout", SYMLINK+="my_modem"
C. The rules file must be in /etc/udev/rules.d/. Restart udev service (sudo /etc/init.d/udev restart) after changes.
D. The rules filename must start with two digits, plus a dash (-), and must end with .rules
The two digits have a reason. See /etc/udev/rules.d/README
Bookmarks