3
votes

I'm trying to access an ESP32 microcontroller connected via USB to /dev/ttyUSB0 on my Kubuntu 18.04 machine, but I'm getting a permission denied error:

SerialException: [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0'

My username is in the dialout group in both /etc/group and /etc/gshadow and I have rebooted since adding the dialout group membership.

$ sudo grep dialout /etc/group /etc/gshadow
/etc/group:dialout:x:20:steve
/etc/gshadow:dialout:*::steve
$ id -Gn steve
steve adm dialout cdrom sudo dip plugdev lpadmin sambashare vboxusers libvirt libvirt-qemu libvirt-dnsmasq
$ groups steve
steve : steve adm dialout cdrom sudo dip plugdev lpadmin sambashare vboxusers libvirt libvirt-qemu libvirt-dnsmasq

The ownership and permissions of the /dev/ttyUSB0 file are:

crw-rw---- 1 root dialout 188, 0 Nov 17 22:34 /dev/ttyUSB0

So I would expect the dialout group membership to work.

When I change the permissions on /dev/ttyUSB0 to '666', giving world read/write access, I can access the serial port:

crw-rw-rw- 1 root dialout 188, 0 Nov 17 22:34 /dev/ttyUSB0

Although usable as a solution, access should work for dialout group members, but, based on my experiments above, it seems that the dialout group membership is somehow ineffective.

This question is related to Serial port permission denied for non-root user with dialout group privileges even after reboot Ubuntu 18.04, but with some extra points.

1

1 Answers

2
votes

This is what I did, and it seems to work even after unplugging and reconnecting an Arduino.

Thinking maybe the tty device I needed was a link to another device, I gathered which tty's were added to the dev directory after plugging in the Arduino.

In my case, two of them: /dev/ttyprintk and /dev/ttyACM0, the second of which was root/dialout ownership we expect. I changed the first one which was root/root to also be root/dialout and things worked for me.