this is the first occurrence where su was required for me.

I read an article about changing the value in /sys/devices/virtual/backlight/acpi_video0/brightness to alter my laptop's screen brightness.

I first noticed that when I would $ sudo echo 10 > brightness I would get permission denied.

I switched to root using su and # echo 10 > brightness changed my brightness almost instantly.

The last weird thing to me happened when I tried # echo 20 > brightness (maxbrightness file holds the value 15) and I got a write error

Could someone explain this difference between sudo and su to me? Understanding the write error would be an added bonus. Any help, pointers, and/or links would be much appreciated.


4 Answers 4


Redirection does not work that way. Appending > to a command will run that redirection as the invoking user (you) and not as root. Do it with tee:

echo 20 | sudo tee /sys/devices/virtual/backlight/acpi_video0/brightness

or by invoking the command in a separate privileged shell:

sudo bash -c "echo 20 > /sys/devices/virtual/backlight/acpi_video0/brightness"
  • Like the tee tip. It had not occurred to me during my 15 years of unix sysadmining :-) Obvious when seen.
    – Mr Shark
    Feb 11, 2011 at 12:15

This isn't because of sudo, it's because of the way your command is processed; I actually explained it in this question. When you do

$ sudo echo 10 > brightness

the shell runs the command sudo echo 10, which runs echo 10 as root. The shell then tries to open brightness so it can redirect the output from echo 10 into it, but it can't -- your shell is running with your permissions, not root. There are workarounds posted as answers on the question I linked to; a good one is:

$ echo 10 | sudo tee brightness

Now tee is the one to open brightness, and since it's running as root it succeeds


su = s witch u ser: Use the shell as a different user

sudo = s uper u ser do: execute following command as the root user.

In your case the following command is only echo 20, hence only echo 20 gets executed as root (as said before). The redirect is executed as you again.


You might want to take a look at /etc/sudoers file. If your a/c is not listed there then you will not be able to sudo.

  • True, but you'd get a specific error message in that case ("username is not in the sudoers file") Feb 1, 2011 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.