Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I want to limit delete of a particular folder in the user's home folder and to restrict any add/change/delete on files in that restricted directory.

/home/myuser/_protected //no delete
/home/myuser/_protected/1.txt //only read

How can I do that on Ubuntu server?

share|improve this question

By saying limit delete and restrict add/delete/change, I presume you mean forbid those actions for the user?
Note, folder can not be deleted unless all it's files are deleted first. So by forbidding deleting of files, folder can not be deleted as well.

To make file read only for everyone but the root, create file as root, set appropriate flags with chmod, e.g. chmod 444 read_only_file.txt.

EDIT: To prevent folder from deletion, even if it's empty, you need to make the parent folder read only. E.g. chmod 555 parentFolder. This will prevent renaming, creating or deleting any files in the parent folder.

A bit simplier solution would be to always have one read only file in the protected folder, in that case there wouldn't be any need to set special rights for the parent folder.

share|improve this answer
The directory initially is empty, and can be sometimes empty. – Pentium10 Jun 24 '11 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .