4

I want to give access to serial port /dev/ttyACM0. How to execute the "sudo chmod 777 /dev/ttyACM0" command from shell script ?

4
  • 1
    you mean 774 or 770? Never give 777 permissions at a folder/file, you would create a huge security breach into your OS
    – damadam
    Commented Dec 4, 2019 at 13:51
  • You create a script to run that command and run it as root. Commented Dec 4, 2019 at 13:51
  • If you are asking how to run that command from a shell script without being prompted for a password, see this question: askubuntu.com/questions/159007/… Commented Dec 4, 2019 at 13:52
  • 1
    There is no need for this: you set the dialout group to include your user. Please keep away from using 777 with chmod. 7[57][05] is for dirs, 6[64][40] is for files. You can set /tmp and cache locations to 777 but then with the sticky bit.
    – Rinzwind
    Commented Dec 4, 2019 at 14:25

1 Answer 1

9

Giving 777 permission to a file is not at all recommended. Since you want to give access to the Serial port, you have to add the user to the dialout group

sudo usermod -a -G dialout <username>

Now, no permission will be asked while accessing the serial port.

Note that this solution will also work for uploading code to Arudino boards in Arduino IDE or Serial Monitor in Ubuntu.

1
  • 3
    THIS. The correct method is to add the user to the group. That is why dialout exists as a group.
    – Rinzwind
    Commented Dec 4, 2019 at 14:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .