How do I set the pullup using /sys/class/gpio/gpio$PIN/

echo 1 > /sys/class/gpio/gpio$PIN/value

does not seem to work.

1 Answer 1


I'm not sure that you can set the internal pull-up/pull-downs via the sysfs interface. I have never done so, but I don't often use sysfs.

From the command line there are many methods. The following examples assume Broadcom gpio 4.


pigs pud 4 u # up
pigs pud 4 d # down
pigs pud 4 o # off


raspi-gpio set 4 pu # up
raspi-gpio set 4 pd # down
raspi-gpio set 4 pn # off


gpio -g mode 4 up # up
gpio -g mode 4 down # down
gpio -g mode 4 tri # off
  • Correct, you can't set the pull-ups or any alt functions via /sys. You can only set the direction and check/set the value.
    – goldilocks
    Sep 20, 2015 at 11:50
  • I have created a script using gpio, which works, but I was hoping there was a method not dependant on installing other software. There seems to be a dearth of documentation on the /sys interface.
    – Milliways
    Sep 21, 2015 at 4:40
  • 1
    Documentation for the generic kernel GPIO interface in /sys is in the vanilla source tree, [src]/Documentation/gpio/sysfs.txt (also online). It's not specific to the pi, which is why it doesn't include stuff like the pull-ups or alt functions. The people responsible for the rpi kernel could have elaborated upon this and created a kernel driver for the pi, but AFAIK they didn't and neither did anyone else -- there is just the various userspace libraries.
    – goldilocks
    Sep 21, 2015 at 13:53
  • hi @joan, so there is no way to set pull up states using gpioset through "libgpiod" ?
    – nass
    Apr 30, 2020 at 21:24
  • Something like this gpioset 0 $PIN=1? Mar 15, 2021 at 21:29

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.