simple-gpio is a simple command line tool designed for Raspberry Pi that allows you to export/unexport GPIO pins without sudo.
$ sudo make
Installation requires sudo!
Export a GPIO pin:
$ simple-gpio export 17
Now you can access the pin without sudo:
$ echo "out" > /sys/class/gpio/gpio17/direction
$ echo "1" > /sys/class/gpio/gpio17/value
When you're done, unexport the GPIO pin:
$ simple-gpio unexport 17
When you run sudo make to install simple-gpio three things happen:
- simple-gpio is compiled (nothing special here)
- The ownership of the compiled executable is set to "root".
- The setuid flag is set on the executable.
Now that the owner is "root" and the setuid flag is set, simple-gpio can be run without sudo.