udev rules priority, disallow change by other rules with := operator

If you have ever modified udev rules, maybe you wondered, what are those numbers in the beginning of a rule name:


All rules files are collectively sorted and processed in lexical order.

lexical order in simple human language means that the rules are loaded according to the file names of the rules. This in turn **usually **means that larger number in the beginning of the filename gives it higher priority.

You have to keep in mind that lexical order is not the same as so called natural order (http://sourcefrog.net/projects/natsort/). So in, e.g. Konqueror with Natural sorting of items (Settings - Configure Konqueror - File Management - General), the files will appear this way:


But they will be really loaded in this way:


So better check the order from the console (the lower, the higher priority):

ls -l /etc/udev/rules.d/

However, there is easier way to make sure, that you rule will not be overwritten: use := operator. So even if your rule name starts with 00-, the rule statement will not be overwritten.

# Prevent an assignment being overridden by default rules - use the := operator
SUBSYSTEM=="usb", ATTR{idVendor}=="1234", ATTR{idProduct}=="1234", MODE:="0666"

Had I known it before modifying udev rules, I would save a couple of hours. Hope you will do.

Have fun!


udev rules doesn’t work with small number

How to write udev rules

Chapter 12. Dynamic Kernel Device Management with udev

udev - dynamic device management