Persistent USB Device Names on Linux

It’s common when you unplug and plugin a usb device on linux for the device name to change. i.e. from /dev/ttyUSB1 to /dev/USB2. This poses a problem when you want to programmatically access these devices. You can however use udev rules to ensure the device always has a familiar name as a link to the underlying changing name.

After you’ve identified your device look for unique information about it. Use this udevadm command to identify one or more unique attributes.

udevadm info --name=/dev/ttyACM0 --attribute-walk

In my case I’m using a Teensy 3.2 connected as /dev/ttyACM0 which has a unique serial number.

Create a udev rule file.

sudo vi /etc/udev/rules.d/99-usb.rules

Add the unique attributes you discovered and the alias you want to use.