3

Possible Duplicate:
Redirecting stdout to a file you don't have write permission on

I'm trying to install drupal according to the instructions given in this tutorial: http://how-to.linuxcareer.com/how-to-install-drupal-7-on-ubuntu-linux and am stuck on a step:

$ cd /etc/apache2/sites-available
$ sudo sed 's/www/www\/drupal/g' default > drupal
bash: drupal: Permission denied

The permissions for /var/www/drupal are set to 777.

3 Answers3

5

The tutorial does not use sudo and requires a root shell. You can get a root shell with sudo -i.

In case you prefer sudo, the redirection is handled by the shell and not by the sudo command. So you can't create a file in /etc/apache2/sites-available by directing the output as you did. According to the sudo manual, you should use a subshell like:

$ cd /etc/apache2/sites-available
$ sudo sh -c "sed 's/www/www\/drupal/g' default > drupal"
forcefsck
  • 7,964
0

First, you are not at /var/www/drupal/. You are trying to create the file drupal at /etc/apache2/sites-available/. If you want the file to be created at /var/www/drupal:

sed 's/www/www\/drupal/g' default >/var/www/drupal/drupal

Otherwise:

sed 's/www/www\/drupal/g' default | sudo tee drupal
admirabilis
  • 4,712
0

Apparently the permissions on /etc/apache2/sites-available are not 777, and that's where you're writing your output to. The redirection is processed separately from the sudo, and you don't have write permissions there. Now, there's nothing about /var/www/drupal there, is that where you're trying to write to? If so you can either use su -c "sed 's/www/www\/drupal/g' default > /var/www/drupal" or sed 's/www/www\/drupal/g' default | sudo tee drupal.

Kevin
  • 40,767