1
I'm trying to set a small webserver for personal use. I have a fodler /srv/http/cgi-bin/
which I want to edit as user and not superuser. I tried to chmod it as mentioned here. Here is the result:
sudo chmod 755 /srv/http/cgi-bin/ -R
[yotam@myhost ~]$ echo "h" >> /srv/http/cgi-bin/h.py
bash: /srv/http/cgi-bin/h.py: Permission denied
Edit:
Here is some data due to the comments and answers:
[yotam@myhost ~]$ sudo chmod 760 -R /srv/http/cgi-bin
Password:
[yotam@myhost ~]$ echo "hh" >> /srv/http/cgi-bin/h.py
bash: /srv/http/cgi-bin/h.py: Permission denied
[yotam@myhost ~]$ ls -ld /srv/http/cgi-bin
drwxrw---- 2 root root 4096 May 20 15:54 /srv/http/cgi-bin
Also, the server is Ubuntu desktop running apache2. As far as I can tell, I didn't temper with any of the user settings so it all should be the default parameters
can you ls -l /srv/http/cgi-bin/h.py ? – None – 2012-05-20T13:13:58.903
Try
ls -ld /srv/http/cgi-bin
andls -l /srv/http/cgi-bin/h.py
and paste the result. You probbaly have the-R
flag in the wrong place. It needs to come first. – mkb – 2012-05-20T13:14:10.0301it mostly depends if it's gnu chmod or bsd chmod. if it's bsd chmod it's at the wrong place, but chmod should have failed with "chmod: -R: No such file or directory" whereas gnu chmod should have succeeded and 755 is rwxr-xr-x – None – 2012-05-20T13:15:35.837
The easy answer is if I just tell you to do chmod 777, but that will be a very irresponsible answer. To answer your question properly, without risking the security of your server, you need to know a couple things about your existing server configuration.
What is the user group of the web server (presumably Apache) process is running as? What is the user group of the user that the Apache process is running as? Should the web server be able to edit this file, e.g. on behalf of web user? And what is the user group of your current user? What is the owner and group of the file? – Lie Ryan – 2012-05-20T13:45:38.287
Your understanding of what the permIssions mean seems out of whack. Your
sudo chmod
works fine; but it grants the owner (apparentlyroot
) write permission, not you. It's not clear how exactly to solve this; my suggestion would be to copy the file, edit the cooy, usesudo
to replace the original with your edited version. – tripleee – 2012-05-21T09:13:06.930