On 29/04/2023 02:35, Greg Wooledge wrote:
On Sat, Apr 29, 2023 at 01:52:11AM +0200, cor...@free.fr wrote:
$ sudo echo 123 > /root/123.txt

It tells me "permission rejected".

Why this sudo can't get success?

Because the redirection is done by your shell before sudo is executed.

See <https://mywiki.wooledge.org/BashPitfalls#pf53> for suggestions,
but basically you're looking at variants of:

    sudo sh -c 'echo 123 > /root/123.txt'

Thanks for explanation. I appreciate it.

Reply via email to