# Inherited directory chflags(1)



## mk (Nov 1, 2010)

I regularly perform `$ rm -rf *` in my $home directory. Now I want to have a "persisting" directory after the above mentioned command. I run few experiments and what I want is to have root directory called *data* which have uunlink and uappend flags. I want those flags to be inherited by every file and directory created within *data*. This due the fact that contents of *data* is deletable. Running `$ chflags -R` every time is not acceptable.

Apparently regular permissions are not appropriate in this case. ACL too - they appear to be extension of regular permissions. 
I'm not interested in third party software. Of course the option of storing *data* content somewhere else (e.g. /data) is possible but I am looking for solution involving chflags()


P.S. Please keep ideas as "don't do rm -rf then.. " for yourself.


----------



## jalla (Nov 1, 2010)

I think (like ordinary file permissions) flags are never inherited.
Of course you can call your dir .data to protect it from the wildcard.

OTOH don't...ah, well, never mind


----------



## phoenix (Nov 1, 2010)

Simplest solution:  create 2 separate directories in your home folder ("data" which is not deleted and "somedir" which is deleted), and use the following command instead:
`$ rm -rf ~/somedir/*`


----------



## DutchDaemon (Nov 1, 2010)

There's also cron for repetitive and menial labor ...


----------



## SirDice (Nov 1, 2010)

At any rate, chflags aren't inherited. And changing the behavior to include that functionality probably means having to change the UFS filesystem itself too. 

Also realize (but perhaps that's intended) that inheriting the uunlink and uappend flags to all the files mean the files themselves cannot be changed or deleted either. Then there's the problem of applications ignoring chflags. 

The proper way to do it would be to set ACLs or permissions. That's what these things are supposed to do. And there's no way for any application to ignore those.


----------

