1

I'm messing around with my raspberry pi, and currently I'm trying to change the color of one of the LEDs on the board executing a shell script and its arguments:

pi@raspberrypi:~/morpheus/scripts $ bash ./set-rgb-led.sh level 50 50 50

When inputting above command, I receive following:

./set-rgb-led.sh: line 19: /sys/class/leds/morpheus:level:red/brightness: Permission denied
./set-rgb-led.sh: line 19: /sys/class/leds/morpheus:level:green/brightness: Permission denied
./set-rgb-led.sh: line 19: /sys/class/leds/morpheus:level:blue/brightness: Permission denied

To check up on permissions I ran getfacl set-rgb-led.sh, which tells me following information:

# file: set-rgb-led.sh
# owner: pi
# group: pi
user::rwx
group::--x
other::--x

I've tryed using the chmod +x command and alike permission changing commands, but I can't seem to gain proper access. What am I missing so I can gain control of the file?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Jon Dier
  • 43
  • 1
  • 2
  • 6

2 Answers2

0

There is no problem with your script in itself, but with the files it tries to access : all files & directories located under the /sys directory are belonging to root (which is not shown by the getfacl command).

What you can do is running the script as root, or to change the permissions of the files you try to access (but this is not recommended at all).

cocosushi
  • 143
  • 1
  • 8
0

Command:

setfacl -m u:root:rwx /path/to/file/set-rgb-led.sh 

should solve the problem. It will set rwx permissions for root with the ACL.

Sysadmin
  • 286
  • 1
  • 5