Control LED from Command Line – Raspberry Pi

Replace “4” with the GPIO pin your using.

echo "4" > /sys/class/gpio/export

Setup the direction.  If it was a button or switch we would change “out” to “in”.

echo "out" > /sys/class/gpio/gpio4/direction

Turn the LED on.

echo "1" > /sys/class/gpio/gpio4/value

Turn the LED off.

echo "0" > /sys/class/gpio/gpio4/value

1 = on and 0 = off.