directory attribute - protect from deleting?
Hi!
I would like to make a directory that (and maybe its content) can not be deleted but files can be copied into it. The best solution would be chattr +a Directory but it does not work. I create the directory (e.g., backup), and type chattr +a backup. It works so far: lsattr -d backup -----a------------ backup When I try to copy a file into it I get an error message: cp: cannot create regular file `***': Operation not permitted The file is created but its size is 0. The +u attribute does not work at all, I can delete both directories and files with this attribute. I also created a directory and changed the ownership to root.user and set the permissions to 770 but user also can delete the directory. I have ext3 file system and use ubuntu 7.10 Does anyone have a tip? Cheers Daniel |
if your worried that another user might delete it make it hidden ie ad a " . " to the front of the folder name
edit also i dont think an average user can delete files in /root but youll need to sudo in order to copy to it |
Hi!
Thanks for your reply. It is technically interesting for me. I am trying to make a home network with 2-3 PC-s and want to make some directories that cannot be (accidentally) removed. I am not afraid of another users but only want to make it 'child safe'. Daniel |
You may want to try looking at the 'Immutable' flag. Say I create a file and place this attribute on it. Now root cannot even remove it until said flag is removed. You may also be interested in the 'sticky bit' which allows a shared directory to be world-writable, but the files therein can only be removed by the users who put them there, if that makes sense.
You can search the LQ forums for more information on both of these terms and, failing that, Google. Best of luck! |
All times are GMT -5. The time now is 04:36 PM. |