Skip to main content
Clarify that this is talking specifically about the 'gpio' program included in WiringPi — as joan notes, if you used other WiringPi commands the solution below wouldn't work
Link
Aurora0001
  • 6.3k
  • 3
  • 24
  • 39

How can I require root privileges for invoking 'gpio' from WiringPi commands?

Source Link

How can I require root privileges for invoking WiringPi commands?

I removed my user from the gpio group, logged out and back in. I can still run e.g. gpio write 25 1.

I see from this answer how the memory mapping and permissions changed between Jessie and Stretch, but the instructions for leaving the gpio group did not seem to work. I asked on IRC, and someone told me that WiringPi now uses "set uid" for the permission structure, and I see that mentioned on the WiringPi website here:

The gpio command is designed to be installed as a setuid program and called by a normal user without using the sudo command or logging in as root.

Am I going to have to compile WiringPi from source in order to change this behaviour?

$ lsb_release -a
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster

$ gpio -v
gpio version: 2.50
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
  Type: Pi 3, Revision: 02, Memory: 1024MB, Maker: Unknown05 
  * Device tree is enabled.
  *--> Raspberry Pi 3 Model B Rev 1.2
  * This Raspberry Pi supports user-level GPIO access.