Reputation: 3316
I am trying to prevent the creation of file posibility inside a linux folder, so that it will be impossible to create new files inside this specific folder. I have tried changing the mode to r only with:
chmod 0544 -R
but unfortunately this doesnt help.
how can I disable the creation of new files?
Upvotes: 2
Views: 742
Reputation: 158250
The above command will work - for all users expect of(!) the root
user.
As @BasileStarynkevitch suggested, Having that you are using an ext filesystem (or any other filesystem which supports the following attribute), you can use the chattr
program to restrict even the root
user from creating files in that directory by accident. (By accident, because root
is of course free to use chattr
again to reset the attribute).
sudo chattr +i /path/to/folder
i
means immutable. Use +i
to set the attribute and -i
to reset the attribute. Note that only the root
user can set or reset this attribute.
Upvotes: 3