Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to change the brightness by overwriting the value on this file:

sudo echo 5 > /sys/class/backlight/acpi_video0/brightness
-bash: /sys/class/backlight/acpi_video0/brightness: Permission denied

It doesn't work even when using sudo. However if I switch to super-user with su, it works. Why is that?

share|improve this question

migrated from stackoverflow.com Oct 7 '12 at 20:45

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

up vote 9 down vote accepted

The error happens because sudo elevates permissions for the command (sudo echo 5) but not the redirection to write the file (> /sys/class/backlight/acpi_video0/brightness). The actual bash shell needs permission to write, which is why it fails with sudo but works as root.

You can work around this by running the tee command as root to write to the file:

echo 5 | sudo tee /sys/class/backlight/acpi_video0/brightness

Note that this will also echo "5" to your terminal. This is a normal side effect of the tee command.

share|improve this answer
    
Credit goes to @duskwuff for the clever tee solution –  mguymon Sep 20 '12 at 0:45
4  
I can't take credit for coming up with that -- it's a bit of UNIX folklore I picked up from who-knows-where. –  duskwuff Sep 20 '12 at 2:15
add comment

I've been struggling with this problem on my VAIO VPCEG for quite a time. After doing everything mentioned in every forum I found something interesting:

After changing the boot parameter acpi_osi=Linux acpi_backlight=vendor and trying to manually change /sys/class/backlight/[vendor - in my case intel_backlight]/brightness, I realized that changing permission to this file from root to my user and restarting acpid service, this would allow me to use brightness keys flawlessly.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.