3 ms·
One feature I've always wanted is to make a directory non-deletable without otherwise changing the directory's functionality. So if I do "rm -rf ~/work" I don't
by coldpie 10y ago
One feature I've always wanted is to make a directory non-deletable without otherwise changing the directory's functionality. So if I do "rm -rf ~/work" I don't lose anything, but I can still do "touch ~/work/whatever". As far as I know, this is impossible.
- slau 10y agoYou don't actually need write access to a file/directory to delete it. You only need write access to the parent (removing or adding a file modifies the container, not the contained). Remove write access to the parent directory, while keeping traversal and read rights, and you'll be sorted.
- coldpie 10y agoBut then I can't add files to my home directory...
- slau 10y agoYou said it was impossible. I simply indicated it wasn't.
- coldpie 10y agoThe question was perhaps imprecisely phrased, but I think you can figure out what I'm trying to accomplish.
- vidarh 10y agoSo don't put the stuff you want to protect this way in your home directory, but somewhere else, and symlink the relevant directories to your home directory.
- coldpie 10y agoQuite clumsy, but I guess it works. I'll keep it in mind, thanks for the idea.
- knodi123 10y ago# mkdir /tmp/foo # touch /tmp/foo/.immutable # chattr +i /tmp/foo/.immutable # rm -rf /tmp/foo It's not EXACTLY what you asked for, but the .immutable file cannot be deleted until you call chattr -i on it, which protects the directory....
- coldpie 10y agoThat doesn't protect siblings of <foo/.immutable>...