udev Rules: Pin Device Names So They Stop Drifting
Production scripts written against /dev/ttyUSB0 break the moment USB order changes. udev binds stable names by hardware identity.
Why pin names
- Find identity: udevadm info -a -n /dev/ttyUSB0 shows idVendor, idProduct and serial — prefer the serial number, it’s unique;
- Write the rule: in /etc/udev/rules.d/99-local.rules, SUBSYSTEM==”tty”, ATTRS{serial}==”…”, SYMLINK+=”ttyPLC”;
- Apply and debug: udevadm control –reload plus udevadm trigger; if it doesn’t fire, read udevadm test output and check quotes and ==.
Use a 99- prefix so your rules load last; when several match one device, later filenames win.
Related products: RP01A dev board, IPA-RK3588 industrial board. Datasheets, firmware and SDKs are free at the Hugsun Documentation Center; for selection advice or volume pricing, talk to us.


