Bash – Why doesn’t chmod work in this case


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/
bash: /srv/http/cgi-bin/ Permission denied

Here is some data due to the comments and answers:

[yotam@myhost ~]$ sudo chmod 760 -R /srv/http/cgi-bin 
[yotam@myhost ~]$ echo "hh" >> /srv/http/cgi-bin/
bash: /srv/http/cgi-bin/ 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

Best Answer

The mode string seems wrong. The mode string 755 means that

  • The owner of the file can read (4), write (2) and execute (1) - 4+2+1 = 7
  • Any member of the file's group can read (4) and execute (1) - 4+1 = 5
  • Anyone else can read (4) and execute (1) - 4+1 = 5

It looks like you want chmod -R 766 /src/http/cgi-bin, but this seems like a very unsafe permission setting...