3 ms·
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 runnin
by tbirdz 9y 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-to-redirect-output-to-a-location-i-dont-have-permission-to-wr https://stackoverflow.com/questions/82256/how-do-i-use-sudo-...
- saagarjha 9y agotee also prints to standard output, so I'd suggest piping to /dev/null if you're going to produce a lot of output.
- lainga 9y agoOr you can add your user to the `video` group. EDIT: it says so in TFA. Oops!
- digi_owl 9y agoMy first thought was to use the sh -c method.
- pwg 9y agoOr, just use 'su' to become root, then write to the device file.
- rusk 9y agosu 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.