Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
/home/myuser/_protected //no delete
/home/myuser/_protected/1.txt //only read

How can I do that on Ubuntu server?

share|improve this question
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.