Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 16 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. – Am_I_Helpful Feb 21 '15 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:

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

(with your device number(s) instead of x, of course). Pick out a unique identifier set, eg idVendor + idProduct. You may also need SerialNumber if you have more than one device with the same idVendor and idProduct. SerialNumbers ought to be unique for each device.
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 '15 at 14:21
@k0pernikus How 'bout that? – RolfBly Feb 7 '15 at 14:57
So is there any solution if the idVendor and idProduct are exactly the same? (two sensors attached on identical model USB to UART modules) – Steven Lu Jul 22 '15 at 2:00
@StevenLu Yes, see step 2, do udevadm info --name=/dev/ttyUSB1 --attribute-walk for both devices and look for serial numbers, they should be unique for each device. If your sensors have no serial number, can you specify what they are? – RolfBly Jul 22 '15 at 9:31
that's awesome, i will report back when i try this out – Steven Lu Jul 22 '15 at 19:43

I was also able to find a unique device in /dev/serial/by-id. I haven't tried a reboot yet, but the files in that directory were just links to the appropriate device file (ttyACM[0-9]).`

I am running arch linux on Raspberry Pi, but I stumbled across them just by doing a find for filenames containing "Arduino". My python programs run fine using those files as devices to read/write data to/from my Arduinos (so far, two on a single Pi).

share|improve this answer

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.