Re: sudo and echo

2023-04-29 Thread Mimiko
On 29.04.2023 02:52, cor...@free.fr wrote: Hello list, When I run this command: $ sudo echo 123 > /root/123.txt A better use is to do: echo 123 | sudo tee /root/123.txt or sudo tee /root/123.txt <

Re: sudo and echo

2023-04-28 Thread Byung-Hee HWANG
writes: > (...) > My favourite alternative to tee for this is dd: you don't have to > "throw away" the other stream: > > echo 123 | sudo dd of=/root/123.txt > > Actually, any program willing to pass stdin to an output file > whose name you can choose will do the trick. Hellow tomas, It is ver

Re: sudo and echo

2023-04-28 Thread tomas
On Fri, Apr 28, 2023 at 10:10:03PM -0500, David Wright wrote: > On Fri 28 Apr 2023 at 20:35:25 (-0400), 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 thi

Re: sudo and echo

2023-04-28 Thread David Wright
On Fri 28 Apr 2023 at 20:35:25 (-0400), 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

Re: sudo and echo

2023-04-28 Thread The Wanderer
On 2023-04-28 at 20:36, Greg Wooledge wrote: > On Fri, Apr 28, 2023 at 08:00:02PM -0400, The Wanderer wrote: > >> 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. > > No,

Re: sudo and echo

2023-04-28 Thread coreyh
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

Re: sudo and echo

2023-04-28 Thread Greg Wooledge
On Fri, Apr 28, 2023 at 08:00:02PM -0400, The Wanderer wrote: > 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. No, that won't work. It'll try to execute a program named 'echo

Re: sudo and echo

2023-04-28 Thread Greg Wooledge
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

Re: sudo and echo

2023-04-28 Thread The Wanderer
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) pr

sudo and echo

2023-04-28 Thread coreyh
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? Thanks. Corey H