Which capabilities(7) do I need to give my binary or user to work with GPIO? Is it CAP_SYS_RAWIO?

I would like to avoid sudo for giving admin rights to a whole process. Capabilities seem like the right way to get around it.

What's the mechanism behind the gpio group on Raspbian? Is it perhaps sufficient to make the user running my binary member of some pre-existing group such as plugdev or dialout (which would be used for accessing serial I/O)?

I am not using Raspbian, because I am trying to get the fastest boot possible. So I decided to go for a customized Debian Stretch, built with this script.

2 Answers 2


Raspbian has a special device /dev/gpiomem which grants access to the GPIO registers to members of group gpio.

Given you are using a customized operating system you are probably on your own for the rest of the question.

  • The customized RPi kernel - and yes, I am running the "official" kernel from here - provides that device, not "Raspbian". But thanks, from this I can put the puzzle-pieces together, because it means I probably just need to adjust ownership (or group ownership) of that device to mimic what Raspbian provides out of the box. So no capabilities(7) needed, it seems. Will accept, as my assumption about the capabilities(7) was wrong in the first place, but you offer a route to the solution. Commented Nov 21, 2017 at 22:38

In order to extend on the answer by joan, the mentioned device on a Raspbian installation (just tested) has the following stat output:

$ stat /dev/gpiomem 
  File: /dev/gpiomem
  Size: 0               Blocks: 0          IO Block: 4096   character special file
Device: 6h/6d   Inode: 8581        Links: 1     Device type: f3,0
Access: (0660/crw-rw----)  Uid: (    0/    root)   Gid: (  997/    gpio)
Access: 2017-09-07 15:54:32.079999997 +0000
Modify: 2017-09-07 15:54:32.079999997 +0000
Change: 2017-09-07 15:54:32.079999997 +0000
 Birth: -

... meaning that it's owned by the gpio group and notably that group is allowed to read and write to the device.

By using the official kernel for the RPi, you will have the device and all that needs to be done during system startup is to chgrp it to a group gpio that - in my case - needs to be created by me.

So that's all there is to it. No need for capabilities(7) at all.

  • 1
    Just to add a minor note: I vaguely recall there's a udev rule in Raspbian that performs the chgrp on /dev/gpiomem but you could use just about anything on startup that you want.
    – Dave Jones
    Commented Nov 23, 2017 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.