How do I allow a non-default user to use serial device ttyUSB0?
As you've noticed, the /dev/ttyUSB0
device has the group of dialout
. All you need to do is add the second user to the dialout
group:
sudo adduser second_user dialout
second_user will need to log out & log back in again for this to take effect.
The easy way:
sudoedit /etc/udev/rules.d/50-myusb.rules
Save this text:
KERNEL=="ttyUSB[0-9]*",MODE="0666"
KERNEL=="ttyACM[0-9]*",MODE="0666"
Unplug the device and replug it, and it should be read/write from any user!
You could use UDEV. It's a system that triggers every time plug or unplug a device (amongst other stuff). With it, you script various things to happen, including setting permissions.
Run sudoedit /etc/udev/rules.d/50-ttyusb.rules
and stick this in there:
KERNEL=="ttyUSB[0-9]*",NAME="tts/USB%n",SYMLINK+="%k",GROUP="uucp",MODE="0666"
Save, exit and replug and you should be up and running. Setting the permission to 666 allows anybody to write to the device.
I'm basing this off this page which is from a few years ago but something like this should work if Jeremy's solution doesn't.