Changing permissions on serial port

298,701

Solution 1

The issue with the permissions for /dev/ttyACM0 can be permanantly solved by adding yourself to the dialout group.

You can do this with:

  1. sudo usermod -a -G dialout $USER

  2. Logout and then log back in for the group changes to take effect.

Solution 2

I couldn't get Rinzwind's suggestion to work, because it complained that the user account already exists. Instead, I used this command to add an existing user (terrik) to an existing group (dialout), as described on the Ubuntu Help Wiki.

sudo adduser terrik dialout

Also useful is this command for listing your current groups, although as Rinzwind says, you have to log out and log in before the serial port starts letting you in.

groups terrik

Solution 3

Another possibility is to make a rules file in /etc/udev/rules.d/ directory. I had similar problem and I have created 50-myusb.rules file in the above directory with this content:

KERNEL=="ttyACM[0-9]*",MODE="0666"

Note that this will give any device connected to ttyACM socket read/write permissions. If you need only specific device to get read/write permissions you must also check idVendor and idProduct. You can find those by running lsusb command twice, once without your device connected and once when it is connected, then observe the additional line in the output. There you will see something like Bus 003 Device 005: ID ffff:0005. In this case idVendor = ffff and idProduct = 0005. Yours will be different. Than you modify the rules file to:

ACTION=="add", KERNEL=="ttyACM[0-9]*", ATTRS{idVendor}=="ffff", ATTRS{idProduct}=="0005", MODE="0666"

Now only this device gets the permissions. Read this to know more about writing udev rules.

Solution 4

I couldn't get Terrik's answer working, but I could if I made this slight adjustment to the path for ttyACM0.

sudo chmod 666 /dev/ttyACM0

Would post as a comment but I don't have the privileges for that yet...

Solution 5

Try going into System / Users and Groups and checkeing the box on your username in the TTY Group.

Share:
298,701
Terrik
Author by

Terrik

Freelance Web Developer, mostly doing it for fun!

Updated on September 18, 2022

Comments

  • Terrik
    Terrik almost 2 years

    I'm using the Arduino IDE in Ubuntu, and am having issues with the serial port. It has worked in the past, but for reasons that may be unnecesary, I felt the need to change the ownership of some of the files from root ownership to my users ownership.

    This made the IDE work correctly, but I lost the ability to use the correct serial port. In the dev folder, the port I need is listed as permission 166. Someone (who is no longer in the area to help me) swapped the permissions to 666, which made it all work gloriously.

    However, it reverted back as soon as I restarted my computer, and if I now try to use the command:

    sudo chmod 666 ttyACM0
    

    nothing happens. No error messages, but no permission change either.

    How can I change it, and how can I get it to change permanently.

    I apologize if this question is overly simplistic or unclear, I'm an ubuntu noob, and I wouldn't begrudge feedback!

    • Admin
      Admin about 10 years
      sudo chmod 666 /dev/ttyACM0 This was the only suggestion on this page that worked on my 14.04 beta2 live environment. Thanks!
  • Ufoguy
    Ufoguy over 10 years
    I learnt about this when Arduino IDE asked to give to root to add itself to the "Dailout group". Now I know what it is.
  • user1063287
    user1063287 over 9 years
    [Errno 13] Permission denied: '/dev/ttyACM0'. As well as tty group, user is also in dialout group. Linux Mint 17.1.
  • user1063287
    user1063287 over 9 years
    The permissions seem to reset when unplugging and replugging Arduino back in.
  • Freddy
    Freddy about 9 years
    does not work. :(
  • Kaos
    Kaos almost 9 years
    it works , well as well. but requires udev rule to re-permit on repplugging
  • Vladimir S.
    Vladimir S. over 8 years
    @user1063287 Try sudo chmod a+rw /dev/ttyACM0
  • Rich.T.
    Rich.T. about 8 years
    I just purchased a Pulse-Eight USB - CEC Adapter for use with my new TV and found that it did not initially work with Kodi in Ubuntu. After checking the crash-log and googling the error message "ERROR: CecLogMessage - error opening serial port '/dev/ttyACM0': Permission denied", this page came up as a result. Thanks to you (and Don Kirkby, below - that works, too), I was able to rectify the problem immediately.
  • Rich.T.
    Rich.T. about 8 years
    Also, the answer from "user247020" gave me another solution: Open the GUI tool "Users and Groups" and make yourself an "Administrator". This will add you to the "dialout" group (ie. "Use Modems"), amongst others.
  • user1063287
    user1063287 about 8 years
    I tried sudo chmod 666 /dev/ttyACM0 and it doesn't work when starting up again. Does anyone have a solution?
  • J261
    J261 almost 8 years
    usermod -a -G dialout pi works ok, after sudo chgrp dialout /dev/ttyS0 and work well but when i reboot all the config is lost. I'm on raspberry pi 3
  • Rinzwind
    Rinzwind almost 8 years
    Add any command you need to redo to a startup script. So bash or /etc/profile or init.
  • johndodo
    johndodo over 7 years
    Note that logout means "log out of X session", not just "open new X terminal". Took me some time to figure that out.
  • Yankee
    Yankee about 7 years
    My 2 cents: I decided I rather enjoy the behaviour of permissions resetting after unplugging/rebooting. I'm not sure what the security implications are for being in the dialout group unnecessarily, but I think it's a good idea to keep serial-and-other external communications as a root-only privilege if possible. It's easy enough to just reset permission back to 0666 when you're ready to flash, unless you're doing a lot of unplugging and replugging. /paranoid
  • Rinzwind
    Rinzwind almost 7 years
    To the anon user editing: I rejected it. A chmod in /dev/ gets overwritten during a reboot.
  • user171780
    user171780 almost 6 years
    This didn't worked for me in Xubuntu 18.04.
  • Rinzwind
    Rinzwind almost 6 years
    Why not? it is a generic solution. We all have a "dialout" user and the device is owned by "dialout".
  • Craig Wilcox
    Craig Wilcox over 4 years
    Add the following two lines to the end of your ~/.bashrc # Give permissions to serial port used by Arduino IDE sudo chmod 666 /dev/ttyACM0