Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have an Ubuntu 11.10 system with 2 users:

  • The first was created during the installation
  • The second instead was created after. It belongs to the sudoers group.

Now the problem is that when the second tries to use a device ttyUSB0 the following error is returned:

"Could not open serial port /dev/ttyUSB0"

I was able to fix it by using:

sudo chown :second_user /dev/ttyUSB0

However when I disconnect the device and reconnect it the problem comes back.

Is there a way to allow different users to access the devices? I suppose I have to add the user to a specific group. Currently the owner is root and the group is dialout. However I'm not sure about the group and I don't know how to add the user.

Thanks!

share|improve this question
add comment

3 Answers 3

up vote 9 down vote accepted

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
share|improve this answer
    
Thanks Jeremy! Does this work also for ssh access? Because when I access the pc via ssh I see two users with the same name. I suppose that one is the local user and the other the ssh one. How can I give the ownership to the ssh user? –  Maverik Mar 14 '12 at 15:44
1  
This will allow second_user to access the serial port from any login, ssh or local. You don't need to assign ownership to a particular login of that user. –  Jeremy Kerr Mar 15 '12 at 1:01
    
Yes, you are right. I had to logout and then login again to have the access vis ssh. –  Maverik Mar 15 '12 at 7:43
add comment

Fantastic -- the UDEV solution given here was the ticket for me.

I installed Icom's CS-F3020_F5010_F5020 program via Wine, created the link for the Com port as follows:

ln -s /dev/ttyUSB0 ~/.wine/dosdevices/com1 but nothing. 

Then I realised I needed to change permissions on /dev/ttyUSB0 to allow me to access it. That works great until you unplug/replug the USB in, then you need to re-change the permissions.

I tried adding my user to dialout group but this didn't solve the problem for some reason.

Using UDEV solves the final piece of the puzzle. Now I can program my Icom radio using Linux, plug and unplug the USB/Serial device without any more fuss. Woohoo. Thanks.

share|improve this answer
add comment

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.

share|improve this answer
1  
This worked for me, that is, I used the udev rules, but I changed the syntax to match my own case. linux.m2osw.com/sane-cannot-find-any-scanners -- note that if you use MODE="0666" then you probably don't need the GROUP. Only one or the other would be useful. –  Alexis Wilke Mar 11 at 3:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.