View Full Version : echo into file permission denied
November 13th, 2008, 09:48 PM
from the user www-data i am trying to run this:
sudo echo -e "something" > /etc/apache2/sites-available/example.com.conf
now the reply i get when i run as su www-data i get:
"sh: /etc/apache2/sites-available/example.com.conf: permission denied"
November 13th, 2008, 09:50 PM
sudo echo -e "something" > sudo /etc/apache2/sites-available/example.com.conf
November 13th, 2008, 09:58 PM
echo "ciao" | sudo tee /path/to/filehas one advantage: the program that outputs data is run as normal user, so it's safer in the general case where the program is not a simple "echo".
More on this topic in the RootSudo (https://help.ubuntu.com/community/RootSudo#Downsides of using sudo) wiki page.
November 13th, 2008, 09:59 PM
echo -e "something" | sudo tee /etc/apache2/sites-available/example.com.conf
to append the file:
echo -e "something" | sudo tee -a /etc/apache2/sites-available/example.com.conf
November 13th, 2008, 10:21 PM
thanks guys that worked perfectly
November 13th, 2008, 10:28 PM
Please mark the thread solved by selecting
Mark this thread as solved from the Thread Tools.
November 13th, 2008, 11:05 PM
sudo sh -c "echo foo > /blah"
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.