Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have an arduino which sometimes gets bound to /dev/ttyUSB0 and other times to /dev/ttyUSB1 making my script fail.

I do not want to enumerate all the possibilities of where my device could be, but I rather have it be bound somewhere static, e.g. /dev/arduinio.

How do I achieve that?

share|improve this question
Just write a simple udev-rule which will assign symlink /dev/arduino to right devise by its VID & PID. –  Eddy_Em Mar 5 '13 at 8:00
Check arch-wiki: wiki.archlinux.org/index.php/Udev#Writing_udev_rules –  uzsolt Mar 5 '13 at 10:01
After you've changed the rules, see How to reload udev rules without reboot? –  Gilles Mar 5 '13 at 22:00

2 Answers 2

up vote 6 down vote accepted

As suggested, you can add some udev rules. I edited the /etc/udev/rules.d/10-local.rules to contain:

ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="my_uart"

You can check for the variables of your device by running

udevadm info -a -p  $(udevadm info -q path -n /dev/ttyUSB0)

There is a more in depth guide you can read on http://www.reactivated.net/writing_udev_rules.html

share|improve this answer
Worked like a charm. One question: How to exit udevam? And it is important to note that my_uart creates the symlink under /dev/my_uart. I first wrote /dev/arduino the first time and it failed whilst arduino is sufficient. –  k0pernikus Mar 7 '13 at 19:11
udevadm should exit by itself when it's done. –  Kotte Mar 8 '13 at 7:31
Then for some unknown reason it froze the terminal session to my Raspberry Pi while generating the report. –  k0pernikus Mar 8 '13 at 12:19
@Kotte- It's a small request to you to please help me with this, I have waited for a long time to get the answer over here. Please visit this question as you seem to be the top-scorer for Arduino SIR. –  shekhar suman Feb 21 at 18:36

The rule syntax above may work on some distributions, but did not work on mine (Raspbian). Since I never found a single document that explains all the ins and outs, I wrote my own, to be found here. This is what it boils down to.
1. find out what's on ttyUSB:

dmesg | grep ttyUSB  

2. list all attributes of the device and pick out a unique identifier set, eg idVendor + idProduct (and if necessary SerialNumber if you have more than one device with the same idVendor and idProduct).

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

3. Create a file /etc/udev/rules.d/99-usb-serial.rules with something like this line in it:

SUBSYSTEM=="tty", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", SYMLINK+="your_device_name" 

(assuming you don't need a serial number there, and of course with the numbers for idVendor and idProduct that you found in step 2.
4. Load the new rule:

sudo udevadm trigger

5. Verify what happened:

ls -l /dev/your_device_name  

will show what ttyUSB number the symlink went to. If it's /dev/ttyUSB1, then verify who owns that and to which group it belongs:

ls -l /dev/ttyUSB1   

Then just for the fun of it:

udevadm test -a -p  $(udevadm info -q path -n /dev/your_device_name)
share|improve this answer
Please add relevant parts of your link to your answer. Links can go down, answer should be able to stand on their own. –  k0pernikus Feb 7 at 14:21
@k0pernikus How 'bout that? –  RolfBly Feb 7 at 14:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.