Permission denied editing .txt file

Yes.

See my previous comment:

And sudo echo >... won’t work anyway.

sudo echo >... will never work in this situation because the file is opened for output before the sudo is executed. The file is opened for output in the context of your shell process with only the access that you normally have, not the elevated access that sudo gives you temporarily.

That’s why the | sudo tee hack is needed.

1 Like