Possible Duplicate:
sudo & redirect output
I'm trying to create a file in /var/www, but even with sudo
this fails:
user@debVirtual:/var/www$ sudo echo "hello" > f.txt
-bash: f.txt: Permission denied
When I use sudo nano
, I can save something to this file.
Why can't I use sudo echo
?
The redirection is done by the shell before sudo is even started. So either make sure the redirection happens in a shell with the right permissions
or use tee