On 2023-04-28 at 19:52, cor...@free.fr wrote: > Hello list, > > When I run this command: > > $ sudo echo 123 > /root/123.txt > > It tells me "permission rejected". > > Why this sudo can't get success?
If I'm not very much mistaken: because redirection like that is (as I understand matters) processed by the currently-active shell, not by the environment that will be created inside the sudo invocation. What this is almost certainly doing is passing 'echo' and '123' to sudo, and telling the *current* shell to redirect the output of 'sudo echo 123' into /root/123.txt. If the current shell process does not have permission to write to that location, then you will get that error. I would suspect that $ sudo 'echo 123 > /root/123.txt' would produce the effect you're after, but as I don't have sudo installed, cannot verify that myself. -- The Wanderer The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. -- George Bernard Shaw
signature.asc
Description: OpenPGP digital signature