Possible Duplicate:
Redirecting stdout to a file you don't have write permission on
I am creating a script to change the brightness of my laptop. I discovered that I can do this using
echo 1000 > /sys/class/backlight/intel_backlight/brightness
for example. But I must to do this as root, not with sudo
command. Well, I created the file /usr/bin/brilho
containing
echo "$1" > /sys/class/backlight/intel_backlight/brightness
and now I can execute it with brilho 1000
. But the problem is the permission. This does not work with sudo brilho 1000
neither brilho 100
. Again I have to change to root.
So, I would like to know how to improve this to facilitate my job.
Regards and thanks.
sudo bash -c "..."
to do the job. But the first time, it ask password but after this, does not. Any idea?sudo
caches your credentials when you use it, so it won't ask for a password again for a while. You can usesudo -k
to make it forget