Accessing gpio without using sudo su

Hello,
I would like to ask how can i access gpio,I2C without using sudo su?

Thanks
Kt

I don’t know the incantation for gpio, but for I2C:

By default, I2C devices are owned by root. To change this, create a file /etc/udev/rules.d/90-i2c.rules and add the line:

sudo gedit /etc/udev/rules.d/90-i2c.rules

KERNEL==”i2c-[0-7]”,MODE=”0666″

As an alternative, you can do this straight from a command line:

$ sudo bash -c ‘echo \”KERNEL==\”i2c-[0-7]\”,MODE=\”0666\”\” > /etc/udev/rules.d/90-i2c.rules’

Thank you @Kangalow
I managed to access I2C without using sudo su. For accessing the GPIO, how can I add the new rules with the different owner?
In beaglebone I manged to get this done by following this person named molloyd. In his tutorial he added new rules as follow:

KERNEL=="gpio*", SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c
'chown -R molloyd:users /sys/class/gpio'"
KERNEL=="gpio*", SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c
'chown -R molloyd:users /sys/devices/virtual/gpio'"

How can I do the same in Jetson Tk1?

Thank you

I am on Jetson Xavier now. The i2c bus I am using is 8. Should I change the KERNEL==”i2c-[0-7]”,MODE=”0666″ to KERNEL==”i2c-[0-8]”,MODE=”0666″?

I’m not sure if this works on TK1, but at least on more recent devices, you can just add your user the “gpio” group. That should be all that is necessary as the devices’ groups are already “gpio”. Likewise all you heed to do to access the video devices (GPU, etc) is to add your user to the “video” group.

if you do need to add a udev rule for another device, you might consider not using mode 666. That allows every user to have full access to the device and malicious software could potentially be used to damage your device’s connected hardware. I know it says to do it everywhere (because it “works”), but it’s dangerous. Instead, use mode 660, and do something like this:

KERNEL=="whatever*" OWNER="root" GROUP="whatever" MODE="0660"

Real world examples are in /etc/udev/rules.d/ (at least on more recent Tegra devices).