Hacker News new | ask | show | jobs
by tbirdz 2994 days ago
The reason why sudo wasn't working is that it runs the command with root privileges, but redirecting to a file with > is done through the shell, which is running under your normal user level privileges. If you want to redirect to a file that only root can write to, you can use the tee command. That command will write anything passed to it via stdin to the file given as an arg.

For example, echo "foo" | sudo tee /path/to/file

or any of the other ways listed here: https://stackoverflow.com/questions/82256/how-do-i-use-sudo-...

3 comments

tee also prints to standard output, so I'd suggest piping to /dev/null if you're going to produce a lot of output.
My first thought was to use the sh -c method.
Or, just use 'su' to become root, then write to the device file.
su isn't an option that's available to "regular" users. In particular in an environment where sudo has been set up correctly then it may be for the reason that you want regular users to be able to perform "some" powerful functions without giving them the keys to the system.
Or you can add your user to the `video` group.

EDIT: it says so in TFA. Oops!