Sunday, 11 March 2018

Using serial device file without sudo or root permissions

When we use the PL2303 or any other connector we get the serial device file as /dev/ttyUSBx where x=0,1,2,3... . If we see the permissions of this file we find that the owner is root and the group is dialout. Hence using a serial console program with normal user permissions will not work as I would not have the appropriate permissions. To fix this first add the user to the dialout group.

Next we modify the udev rules file with the appropriate rules as follows:

ATTRS{idVendor}=="xxxx",ATTRS{idProduct}=="yyyy", MODE="0660",GROUP="plugdev"

Replace "xxxx" and "yyyy" with your USB vendor ID and USB product ID respectively.

I create a file named <somenum>-serialadapter.rules in /etc/udev/rules.d/

Next to trigger the above rules we do the following:

sudo udevadm control --reload-rules && sudo udevadm trigger

Now we can use screen or minicom on the device file without using root or sudo.

No comments:

Post a Comment