views:

42

answers:

4

I'm installing a lighttpd server on a remote machine using a bash script. After installation, I need to configure the port for the server. The system says I don't have permission to modify the file /etc/lighttpd/lighttpd.conf even though I do

sudo echo "server.bind=2000" >> /etc/lighttpd/lighttpd.conf

How shall I modify this?

A: 

Try to change the file permission using chmod

$ sudo chmod a+x /etc/lighttpd/lighttpd.conf
Nathan Campos
Uhm... who needs to EXECUTE that config file?
ndim
+4  A: 

What you're doing is running echo as root, then trying to append its output to the config file as the normal user.

What you want is sudo sh -c 'echo "server.bind=2000" >> /etc/lighttpd/lighttpd.conf'

THC4k
A: 

If you don't have the right to change the file /etc/lighttpd/lighttpd.conf check the man page of lighthttpd. If you can start it with a different config file, then create a config file somewhere and start lighthttpd with it.

tangens
A: 

The problem is that the bit on the right of >> is not run under sudo. Either use sudo -i to bring up a root shell a superuser and run the command, or just use an editor as mentioned before.

Adam Bard