On 20 Nov 2024 17:49 -0500, from g...@wooledge.org (Greg Wooledge):
>> sudo echo "something" >>/etc/postfix/virtual_alias_maps
> 
>> Can you help me why the first sudo failed?
> 
> The redirection >> is being done before sudo is executed.

Indeed.

The usual pattern if you need to do this in a non-root-only script is
to do something like `echo | sudo tee` to tie the sudo to the thing
that needs write access to the output file.

-- 
Michael Kjörling
🔗 https://michael.kjorling.se

Reply via email to