4 ms·
Anybody knows why sudo did not work?
by fabiensanglard 6y ago
Anybody knows why sudo did not work?
- megous 6y agoRedirect to a file is done by the shell, not by sudo process. It even tells you that: > -bash: /dev/fb0: Permission denied ^^^^^
- drewbug 6y agoit only runs `cat` as root, not the write operation
- doublej472 6y agoThis will only run `cat /dev/urandom` as root, while the redirection is run as a normal user: sudo cat /dev/urandom > /dev/fb0 This should work just fine (with a /dev/null redirection so your terminal doesn't get garbled): cat /dev/urandom | sudo tee /dev/fb0 > /dev/null
- OskarS 6y agoWhen I encounter this limitation and can not quite remember the correct incantation to solve it, I usually do something like this in frustration: echo "cat /dev/urandom > /dev/fb0" | sudo sh I was quite proud of myself the first time I figured that out many years ago :)
- ChristianBundy 6y agoAlternatively: sudo sh -c "cat /dev/urandom > /dev/fb0"
- kkielhofner 6y agoI noticed this a while ago. I've always assumed it's because the redirection is being performed by the current shell running as $USER and not the new process launched as root by sudo.
- stragies 6y agoPermission problem for the redirection. From https://stackoverflow.com/a/82278/5208540 https://stackoverflow.com/a/82278/5208540 , here's how to "redirect with sudo": Use "| sudo tee /dev/fb0"
- thequux 6y agotee will also write to stdout, which can often mean that you get a bunch of binary gubbish splattered all over your terminal. I recommend instead using "|sudo dd of=/dev/fb0", or, if you have moreutils installed, "|sudo sponge /dev/fb0"
- hackmiester 6y agoBut 'sponge' will put it all in RAM, so that's not ideal either. Lots of pitfalls here, wow.
- rbanffy 6y agoShouldn't `| sudo cat > /dev/fb0` work?