Serial port terminal > Cannot open /dev/ttyS0: Permission denied
The tty devices belong to the "dialout" group, I suspect you are not a member of this group and hence are denied access to /dev/ttyS0, so you need to add yourself to that group.
First check if you are a member of that group:
groups ${USER}
..this will list all the groups you belong to. If you don't belong to the dialout grup then add yourself to it, for example:
sudo gpasswd --add ${USER} dialout
You then need to log out and log back in again for it to be effective. Then see if it fixes your problem.
The only solution that works for me is to: (every time I boot the machine)
sudo chmod 666 /dev/ttys0
It really needs to be fixed at time of installation. I'm on 15.10 and have tried 16.04 LTS, still the same there. Seems like such a simple fix.
The older versions 10.04LTS did not have this problem.
On Ubuntu 18.04, I fixed this issue with the following commands:
sudo usermod -a -G tty $USER
sudo usermod -a -G dialout $USER
And after this, reboot.
If you still have issues, try to debug with:
strace -ff <COMMAND> > strace.txt 2>&1
And look for "denied" in the strace.
You can just use this command:
sudo adduser $USER dialout
This will add the current user to the dialout group. Login and out it to take effect.
Had a look around various forums and it looks to be a bug related to permissions. Here's how I got around the problem (long version). You WILL need BOTH cu
and setserial
packages installed.
In three terminal tabs, monitored output from # tail -f /var/log/messages
That's how we know if we have a /dev/ttyUSB0
or not.
In the second tab, simply ran a loop to ls -l
this device to see it's permissions and it's group ID is 'dialout'. THIS is the critical bit. For some reason, your user MUST use this GID to do the cu
, so...
In the third tab, as root, did # newgrp dialout
(to correspond with the GID of dialout). Tested with # touch /tmp/anything
... doing ls -l
on this file shows it is created by root with a dialout group, so we're ready to ... # cu -l /dev/ttyUSB0
In my case I needed to hit return again to see the expected prompt, in other cases speed may need to be specified.