Ubuntu: How to make a specific device have read/write permissions when pluged?



Question:

I have home made device that can be connected via USB port. When connected it gets ttyACM socket. So I have asked this question some time ago about how to set read/write permissions for device. Following the answer I have created /etc/udev/rules.d/50-ttyusb.rules file with this content:

KERNEL=="ttyUSB[0-9]*",MODE="0666"  KERNEL=="ttyACM[0-9]*",MODE="0666"  

All works fine! But if I understand correctly, now every device connected on any ttyUSB or ttyACM socket will have read/write permissions. Right?

My question is how can I automatically set read/write permissions only for this device when connected?

Relevant lsusb output:

Bus 003 Device 005: ID ffff:0005  


Solution:1

  • Yes, it gives permission to public users for all those serial devices.
  • You can use ATTRS{idVendor} & ATTRS{idProduct} to filter out target devices:

    ACTION=="add", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="ffff", ATTRS{idProduct}=="0005", MODE="0666"  

    I add ACTION=="add" to skip other unwanted event remove (device node removed already) & change (device node already added and configured)


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »