0

I'm trying to run a chmod command in rc.local so that it gets executed at startup. The command enables the I2C device to be accessed. However, I need to manually run rc.local in order for it to work. I am using ubuntu 16.04 LTS.

Here is my rc.local file:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo chmod 777 /dev/i2c-*
exit 0

1 Answers1

2

You don't have to sudo the chmod command as this script is executed as root.
Also did you add the execution bits on this script as noted in the comment part ? (ie sudo chmod +x /etc/rc.local)
You should also be sure to follow the instruction given in the link given by @steeldriver in the comments

A better way to achieve the task of setting the rights of a device would be to use udev rules like for exemple How can I set device rw permissions permanently on Raspbian? which explain how to set 666 rights on i2c device using udev (the raspberry pi part is irrelevant)

M4rty
  • 1,153