Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's assume that I have a webhosting server running on my ubuntu 13.04 system. For each customer I get that wants to host a website on my server I create a user and add it to a group called 'customers'. All of these customers get a private folder in my /home/ folder, in which there is a folder tree that should not be deleted. So let's say that one of my customers' name is bob. He will get /home/bob/ as his private folder, but that folder should also contain a folder tree like this:

     |-> /www/
         |-> /
         |              |
         |              |-> /public_html/
         |              |-> /cgi_bin/
         |-> /
                        |-> /public_html/
                        |-> /cgi_bin/

Bob should obviously be the owner of /home/bob because otherwise bob couldn't create or delete files and folders inside his home folder. However, everything between /www/ and /public_html/ or /cgi_bin/ should never be removed. Everything from /public_html/ or /cgi_bin/ and down should be bob's choice wether he wants to delete it or not.

In order to do this, could I just set the folders between /www/ and /public_html/ or /cgi_bin/ as property of root, or would that cause bob being unable to add files to the /public_html/ and /cgi_bin/ folders?
If this is not possible, in what other way should I do this?

share|improve this question
up vote 3 down vote accepted

I found the answer to my question. I chowned the folders that I didn't want to be deleted to root:root, and then chmodded these folders using 'the sticky bit' (1775 instead of 0775). This way everybody can add files and folders over ftp as they please, but they could not remove the folders that I protected with the sticky bit since you'd have to be a file or folder owner to do that.

share|improve this answer
You definitely do not want to do it this way. As you say, everybody can add files. If Mal knows that Bob is a user on your system, and can figure out Bob's username and the domain name (neither of which is difficult), then Mal can arbitrarily add files to Bob's website. Mal still wouldn't be able to delete files, but with cgi-bin access and the suexec features which are now common, Mal could arbitrarily delete and edit files that way. – wyrm May 18 at 17:00

You were on the right track. If you want to prevent actions like file creation and deletion (including deleting directories) then the user cannot have write access to the parent folder. In this case, to preserve /home/<user>/www/<domain>/public_html and /home/<user>/www/<domain>/cgi_bin, the user cannot have write access to /home/<user>/www/<domain>. To do that, the domain directories should be owned by somebody else and not world-writable. Note that it doesn't need to be root, either: the nobody user should be fine.

`-- [drwxrwxr-x bob     ]  www
    |-- [drwxrwxr-x nobody  ]
    |   |-- [drwxrwxr-x bob     ]  cgi_bin
    |   `-- [drwxrwxr-x bob     ]  public_html
    `-- [drwxrwxr-x nobody  ]
        |-- [drwxrwxr-x bob     ]  cgi_bin
        `-- [drwxrwxr-x bob     ]  public_html
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.