2

I want to create a directory which is undeletable, and that you can only add files, not delete any file therein.

I was reading the man chattr page and I came across attribute a

A file with the 'a' attribute set can only be opened in append mode for writing. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

But it just mentions files. Can I apply it to a directory? Something like

sudo chattr +a +u /path/to/dir
3
  • Yes. Have you tried it yourself on a test directory? Commented Mar 31, 2022 at 21:54
  • @NasirRiley nice, yes, I tested and it works :) thanks Commented Apr 1, 2022 at 20:09
  • 3
    Does this answer your question? What is the effect of "chattr +a" on a directory Commented Feb 19, 2023 at 11:52

1 Answer 1

1

This works

sudo chattr +a +u /path/to/dir

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.