linux - Unable to access devttyS0 as a regular user, despite having the right permissions - Stack Overflow

admin2025-04-30  1

I'm trying to access the UART connected to the standard GPIO pins 14/15. As root, I can access them just fine. As a regular user, I always see a super abstract message:

$ minicom -b 115200 -D /dev/ttyS0
minicom: cannot open /dev/ttyS0: Device or resource busy

However, this works just fine when run with sudo.

I checked the permissions to /dev/ttyS0 next, and everything appears to be in order:

$ ls -hall /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Jan  4 21:12 /dev/ttyS0
$ id
uid=1001(jude) gid=1001(jude) groups=1001(jude),5(tty),20(dialout),27(sudo),112(bluetooth),114(docker)

I'm a part of dialout, and just for fun, a part of tty too.

Next up, I ran strace on cat /dev/ttyS0:

...
openat(AT_FDCWD, "/dev/ttyS0", O_RDONLY) = -1 EBUSY (Device or resource busy)
...

So that's pretty much it - I'm stuck.

Does anybody know what's going on here?

I'm trying to access the UART connected to the standard GPIO pins 14/15. As root, I can access them just fine. As a regular user, I always see a super abstract message:

$ minicom -b 115200 -D /dev/ttyS0
minicom: cannot open /dev/ttyS0: Device or resource busy

However, this works just fine when run with sudo.

I checked the permissions to /dev/ttyS0 next, and everything appears to be in order:

$ ls -hall /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Jan  4 21:12 /dev/ttyS0
$ id
uid=1001(jude) gid=1001(jude) groups=1001(jude),5(tty),20(dialout),27(sudo),112(bluetooth),114(docker)

I'm a part of dialout, and just for fun, a part of tty too.

Next up, I ran strace on cat /dev/ttyS0:

...
openat(AT_FDCWD, "/dev/ttyS0", O_RDONLY) = -1 EBUSY (Device or resource busy)
...

So that's pretty much it - I'm stuck.

Does anybody know what's going on here?

Share Improve this question asked Jan 4 at 21:55 judepereirajudepereira 1,2972 gold badges17 silver badges25 bronze badges 3
  • That error message does not indicate a permission issue that is solvable by group membership (i.e. EACCES). Instead you need to review the boot log, e.g. the dmesg command, and/or the kernel command line for the console= parameter. That serial terminal is probably assigned as the system console. The error message indicates that you're not allowed to hijack the serial terminal that is already in use (as the system console). – sawdust Commented Jan 4 at 22:21
  • Can you post output of sudo lsof /dev/ttyS0 ? – Philippe Commented Jan 4 at 23:08
  • I checked dmesg, system logs (journalctl), and console=. The problem was a stray process that was reading off of /dev/ttyS0. Weirdly, root could always take control over it, but as a normal user, it would show it as busy. – judepereira Commented Jan 5 at 8:28
Add a comment  | 

1 Answer 1

Reset to default 0

The problem was a stray process that was reading off of /dev/ttyS0. Weirdly, root could always take control over it, but as a normal user, it would show it as busy.

I detected this by using sudo fuser -k /dev/ttyS0.

转载请注明原文地址:http://anycun.com/QandA/1746026027a91521.html