The question has been edited to include a log of the problem being introduced, which includes the command:
# Taken from edited question
$ echo 'hello' > sudo tee /data/hello
In bash (which allows redirection operators at any point in a simple command), this is precisely equivalent to running:
# From question, with redirection moved to end to make actual behavior more readable
echo 'hello' tee /data/hello > sudo
That is, it's creating a file named sudo
in your current directory, not using sudo
to run tee
(in the above, tee
is just an argument to echo
).
What you want, by contrast, is:
# CORRECT: Using a pipe, not a redirection
echo 'hello' | sudo tee /data/hello
with a pipe (|
) rather than a >
.