Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8546107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:56:30+00:00 2026-06-11T12:56:30+00:00

This question might not be specific to the raspberry pi, of course. Also, I’m

  • 0

This question might not be specific to the raspberry pi, of course. Also, I’m relatively new to Linux.

I want to write a little library (in node.js, if that matters) to access the GPIO of the raspberry pi using the sysfs. However, accessing the sysfs requires sudo access, and that’s bad for obvious reasons.

Quick2Wire seems to have a solution, but I want to understand it better and not just blindly use it. They’ve used C of course, but from what I understand, the code isn’t complex, and probably can be pulled off with just bash, even if less elegantly. However, more than anything, I’m not sure why it works.

Any help will be great.

Edit: Thanks for the comments. It’s clear I need to rephrase the question. Here goes:
How is it that once installed (as root), the app doesn’t require any more root perms to use? How does adding someone to a group help in this case? /sys/devices/virtual/gpio isn’t the location where the gpio sysfs is available, so what’s the trickery with that? I’m really a n00b, so these questions might be n00b-ish, so please bear with me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:56:32+00:00Added an answer on June 11, 2026 at 12:56 pm

    Rakesh, I’ve just been trying to figure out exactly the same thing, and I think I’ve solved it.

    You don’t need to understand much of the makefile at all. The important lines are the following, which are executed in bash when you run sudo make install

    install: install-files
        groupadd -f --system gpio
        chgrp gpio $(DESTDIR)/bin/gpio-admin
        chmod u=rwxs,g=rx,o= $(DESTDIR)/bin/gpio-admin
    

    groupadd -f --system gpio creates a system group called gpio. chgrp gpio $(DESTDIR)/bin/gpio-admin changes the group of the binary (which the C file gpio-admin.c was compiled to) to gpio. The owner of the binary is still root (since you’re running make as root.) chmod u=rwxs,g=rx,o= $(DESTDIR)/bin/gpio-admin does two important things. Firstly, it lets a member of the gpio group run gpio-admin. Secondly, it sets the setuid bit on gpio-admin.

    When you add yourself to the gpio group, you can run gpio-admin, without using sudo, but gpio admin will act like it is being run under sudo. This allows it to write to the /sys/class/gpio/export file. It also allows it to change the owner of the files /sys/class/gpio/gpio[pin number]/direction etc. that get created.

    Even if you change the group of /sys/class/gpio/export to gpio, and set permissions to allow you to write to it

    sudo chgrp gpio /sys/class/gpio/export /sys/class/gpio/unexport
    sudo chmod g+rwx /sys/class/gpio/export /sys/class/gpio/unexport
    

    you can export a pin without superuser powers

    echo 22 > /sys/class/gpio/export
    

    but the files /sys/class/gpio/gpio22/direction etc. will still be create with root as the owner and group, and you’ll need to use sudo to change them. Also, ownership of the export and unexport files will revert to root after each reboot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question might not seem very technical but, out of curiosity,I want to know
This question might be specific to SoThink Video Encoder v2.5, but it might not.
This might not be a Microsft.Practices specific question (probably not but not 100% sure)
I'm not a regular C++er, so this question might be fairly trivial: Can anybody
Unfortunately I am not writing this question from my Developing PC so I might
This might be a stupid question, but I was wondering whether or not you
I know this might seem a controversial question but it really is not meant
I'm not sure if this might be a rather stupid question. But is it
I know, this might be a very basic question but I am not 100%
This question might be naive as I'm new to ColdFusion programming. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.