permission denied to echo a file in linux code example
Example 1: echo to file permission denied
sudo bash -c 'echo "hello" > f.txt'
Example 2: echo to file permission denied
echo "hello" | sudo tee f.txt # add -a for append (>>)
sudo bash -c 'echo "hello" > f.txt'
echo "hello" | sudo tee f.txt # add -a for append (>>)