On Ubuntu my Brightness keys don't work. So instead to open Ubuntu settings every time, I want to write a shell script to use in my .bashrc. Now I don't understand at all why the tee command in the following line seems to be neessary! Thanks!

sudo echo "937" | sudo tee /sys/class/backlight/intel_backlight/brightness 
  • 1
    because redirection will not work with sudo... there are other ways of doing it, but tee is nice
    – Zanna
    Oct 12, 2016 at 13:43
  • 1
    So you understand what this command does and just don't know why tee is used or what? You can skip the first sudo )) and it will do same.
    – Pilot6
    Oct 12, 2016 at 13:44
  • @Zanna Why redirection does not work with sudo?
    – v217
    Oct 12, 2016 at 13:46
  • @Zanna Your comment is partly wrong. Even in root shell this does not work: root@mycomputer: echo "200" | /sys/class/backlight/intel_backlight/brightness bash: /sys/class/backlight/intel_backlight/brightness: Permission denied
    – v217
    Oct 12, 2016 at 13:47
  • 1
    The thing that's really not necessary about this command is the sudo before echo.
    – UTF-8
    Oct 12, 2016 at 18:05

1 Answer 1


tee is not necessary in that command.

You just need to edit the file /sys/class/backlight/intel_backlight/brightness to add 937, as the file is only writeable by the owner, root (user with UID 0), any manner that can do exactly that would suffice.

You could just do:

sudo bash -c 'echo "937" >/sys/class/backlight/intel_backlight/brightness' 

In that command, tee is being run with sudo i.e. being run as root as the file /sys/class/backlight/intel_backlight/brightness in only writable by root.

Even you can start an interactive-login session of your SHELL for root by:

sudo -i

and open-write-close the file with any command or your editor of choice (and later exit that session), but that would be clumsy and unnecessary as you want to run just a single command.

Also you don't need the sudo with echo, do:

echo "937" | sudo tee /sys/class/backlight/intel_backlight/brightness 
  • So why is sudo bash -c 'echo "937" >/sys/class/backlight/intel_backlight/brightness' possible but the same command in a root shell does not work
    – v217
    Oct 12, 2016 at 13:55
  • sudo will make you root (default), when in a root shell just do: echo "937" >/sys/class/backlight/intel_backlight/brightness
    – heemayl
    Oct 12, 2016 at 13:56
  • The idea is that this won't work: sudo something > some_file -- the redirection occurs as you, not root. Oct 12, 2016 at 14:28
  • @glennjackman But in a root's shell, that's moot.
    – heemayl
    Oct 12, 2016 at 14:31
  • Of course, but working in a root shell is like running with scissors. Oct 12, 2016 at 14:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .