14

On CrunchBang linux (Debian variant), I have a COM port on ttyS0, which I'm trying to use with an NFC device. libnfc responded that it couldn't see any NFC devices, so I tried directly opening the COM port. For this, I used:

sudo cu -l /dev/ttyS0 -s 9600

However, this command returns:

cu: open (/dev/ttyS0): Permission denied
cu: /dev/ttyS0: Line in use

I don't know what could possibly be using this connection. To find out, I've tried reading all open processes and filtering for the use of ttyS0:

ps -ef | grep tty

but for this command, nothing shows up that is using ttyS0. I've also tried grabbing all open files and filtering for a lock on ttyS0:

lsof | grep tty

but this returns nothing using ttyS0.

How is it possible the cu says the line is in use, but both ps and lsof return nothing using that line?

3
  • What about lsof /dev/ttyS0
    – Ciclamino
    Aug 9, 2014 at 1:45
  • @Ciclamino That doesn't change it - tty is a substring of /dev/ttyS0. That does, however, hide all the other ttys.
    – user218544
    Aug 9, 2014 at 1:57
  • I have the same problem. minicom works fine, but cu and screen refuse to talk to /dev/ttyUSB0. I was advised to add my user to the uucp and dialout groups and log out that didn't help.
    – Vorac
    Oct 31, 2015 at 1:23

4 Answers 4

13

There is probably no real usage of the line, but a permission issue. quick and dirty way to test for me was to execute:

ls -la /dev/ttyUSB0
sudo chmod 666 /dev/ttyUSB0

and retry cu. If it starts working, you need to take care of the respective udev file and the user permissions/groups. For my device it looked like this (being member in plugdev group):

> cat /etc/udev/rules.d/42-CP210x.rules 
ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SUBSYSTEMS=="usb",
ACTION=="add", MODE="0666", GROUP="plugdev"
1
  • I had this issue with ser2net, it just responded ´Device open failure: Object was already in use` and the root cause was the permissions.
    – Peter
    Jul 27, 2023 at 21:21
5

Serial devices privileges are granted to members of the dialout group. To get connected to /dev/ttyS0 I added the current user to the group using:

sudo adduser <username> dialout

2
  • 1
    sudo: adduser: command not found
    – c z
    Aug 17, 2020 at 18:00
  • It should be noted, that it is neccessary to re-login after being added to the dialout group. An already running process is not aware that the current user has been added to a annother group.
    – ktf
    May 16, 2021 at 12:45
3

It seems that this is a bug in cu. I solved this by changing owner group of /dev/ttyUSB0 using following command:

chown root:root /dev/ttyUSB0
1
  • 1
    chown: root: illegal group name
    – c z
    Aug 17, 2020 at 17:59
0

Add your user to the dialout group. Depending on the system, it may also be necessary to add your user to the uucp group.

Check the group for membership:

getent group dialout

Or check your user:

groups `whoami`

Add your user if necessary:

usermod -aG dialout `whoami`

verify with getent as mentioned above.

You must log in to answer this question.