55

Since I updated from Ubuntu 10.04 (Lucid Lynx) to Ubuntu 12.04 (Precise Pangolin), I am unable to access the device connected in /ttyUSB0 if I don't have root access.

To be more specific, I use a USB-to-serial com port converter to access and configure Cisco equipment with software called PuTTY. It happens that, since I upgraded to 12.04, PuTTY only sees the connected device when I run it as gksudo putty. If not, it says "unable to connect to port /ttyUSB0".

I have managed to change the permissions via chmod 666, and it works, but if I disconnect the USB device and reconnect, it goes back to root only. How do I permanently allow non-root access? I have a clue it might be via udev rules, but I have no idea how to do it.

Obs.: Manufacturer and drivers are "PROLIFIC"

0

10 Answers 10

13

It's possible this is related to modemmanager, as detailed here.

I removed that (sudo apt-get remove modemmanager) and it fixed my problem.

You still need to be in the dialout group though.

5
  • 2
    What if I can't remove modemmanager? I have a friend that has a 3G modem, and it seems he can't remove modemmanager because of that. How can he access /ttyUSB0 on 12.04 without root, but without removing modemmanager? Jul 19 '13 at 12:22
  • You can try by stopping it? sudo stop modemmanager It worked for me.
    – Aleks
    Aug 12 '14 at 9:19
  • Been a few years, but this is still the case in Ubuntu 17.10. Had to do a sudo apt-get purge modemmanager before sudo usermod -a -G dialout $USER had the desired effect.
    – Stéphane
    Nov 6 '17 at 3:29
  • 2
    Please note: being in dialout group is sufficient if you do not use modemmanager in any way. The modemmanager removal is very case-specific to OPs situation, and is not a requirement every time. Dec 15 '19 at 1:44
  • Thank you bro. That solved my problem. I got access denied fron non-root user while the permission of /dev/ttyUSB0 was 777 !
    – SuB
    Aug 1 at 7:29
126

The device is most likely attached to user group dialout. Just add your user to the dialout group so you have appropriate permissions on the device.

sudo usermod -a -G dialout $USER

(You may need to logout and back in for the new group to take effect.)

No need to mess around with permissions or udev rules.

10
  • 1
    no success... still no acces to ttyUSB0 without root... any other ideas???
    – yurividal
    May 11 '12 at 16:16
  • 1
    @tom-hennen I guess you should add it first as a comment rather than edit it directly.
    – MadMike
    Oct 29 '14 at 13:33
  • 2
    This doesn't work for Debian
    – Mike
    May 16 '15 at 16:51
  • 2
    Kudos for including "may need to logout and back in". Jul 26 '18 at 13:57
  • 3
    In Ubuntu (I'm on 18.04), logout/login doesn't work. we have to reboot after doing usermod. Mar 2 '19 at 6:42
11
sudo adduser <the user you want to add> dialout
sudo reboot

Mentioned by "Try now" worked for me. Check that You have dialout as group for ttyUSB0:

ls -l /dev/ttyUSB0

in my case the output is:

crw-rw---T 1 root dialout 188, 0 Feb 12 12:01 /dev/ttyUSB0
2
  • in Linux Mint 18 Cinnamon I get this error when calling ' ls -l /dev/ttyUSB0 ' ls: cannot access '/dev/ttyUSB0': No such file or directory Dec 8 '16 at 22:56
  • It can also be ttyACM0 (instead of ttyUSB0): ls -l /dev/ttyACM0 Dec 14 '19 at 19:29
3

This worked for me. Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command below.

sudo adduser <the user you want to add> dialout
sudo reboot
id -Gn

Try now.

3

As reported by Rinzwind, start by typing:

sudo usermod -a -G dialout $USER

But that is only part of the solution, as then you must reboot the system:

sudo reboot
3
  • 6
    1) Please don't post comments as answers. 2) No need to reboot; just log out and log back in.
    – gertvdijk
    Sep 11 '14 at 12:07
  • 1
    I had to reboot to get this to work. A Logoff didn't propagate the change. Jun 3 '19 at 20:19
  • @gertvdijk: I agree with user1182988. It is not always sufficient to log out and log back in (empirical knowledge, e.g. observed on later versions of Ubuntu: Ubuntu 16.04, Ubuntu 18.04, Ubuntu 19.04, and Ubuntu 19.10). Sometimes it is fixed by rebooting. Though this does not preclude other measures that could prevent a reboot - it would be interesting to know about such measures. Dec 14 '19 at 19:35
2

I tried both

sudo usermod -a -G dialout $USER #(worked perfectly)

And sudo chmod 666 /dev/ttyUSB0 (worked but had to type the command again)

I also removed the mode manager but did not really help. Therefore, the best command that worked for me was

sudo usermod -a -G dialout $USER
1

On Ubuntu 18.04 I had to add myself to the tty group.

I got hinted by the minicom command output:

minicom  /dev/ttyUSB0
minicom: cannot open /dev/tty8: Permission denied


ls -la /dev/tty8
crw--w---- 1 root tty 4, 8 juil. 31 08:27 /dev/tty
3
  • Why not group "dialout"? Dec 14 '19 at 19:50
  • @PeterMortensen Because in this particular situation minicom application also opens /dev/tty8 which is handled by entirely different group than dialout. Issue isn't directly related to /dev/ttyUSB0 in this particular scenario and adding to dialout group won't fix the problem. But it does prevent one from using /dev/ttyUSB0 , hence it is one of the possible answers to the question Dec 15 '19 at 1:47
  • Checking the group associated to /dev/ttyUSB0 (group uucp on Arch Linux) and adding my user to that group was the solution for me. Thanks.
    – Paolo M
    Jul 1 '20 at 8:22
0

On Ubuntu 18.04:

  1. sudo adduser <user> dialout
  2. Full reboot, for some reason mere logout/login is not sufficient (bug report.).
1
-1

I had this problem with /dev/ttyS0 in Mint Rosa. Adding the user to the dialout group is required but in my case the device access was restricted and I had to expand it to give r/w access to group level also.

1
  • 1
    Welcome to Ask Ubuntu! I recommend editing this answer to expand it with specific details about how to do this. (See also How do I write a good answer? for general advice about what sorts of answers are considered most valuable on Ask Ubuntu.) Sep 4 '16 at 18:42
-5

navigate to /etc/ folder and edit the group file add your username like this dialout:x:20:USER

worked perfect for me :)

1
  • 5
    It is generally considered bad practice to edit these files directly as some simple mistakes can cause loss of access.
    – flickerfly
    Apr 10 '15 at 20:49

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