Recently, I deleted some files accidentally. Fortunately, I was able to recover them. That is why I would like to prevent deleting files in a particular directory but still allow to create new files and modify them. So, permissions should be rwx, but if I want to delete ANY file (created by ANY user) in this directory, I should be prompted to input a password. Is this possible somehow on Debian Testing?

  • similar question on AU How can I set up a password for the 'rm' command?, by the way you want password protect find -delete or mv * afile or any other scripting way? Commented Oct 2, 2017 at 17:03
  • I am just reading the thread you mentioned. I want to protect just the normal rm afile which I can do through the file manager. It does not have to be secure, but just prevent me from making mistakes.
    – tavkomann
    Commented Oct 2, 2017 at 17:10
  • This seems to be what I want: askubuntu.com/a/866003/692458 Is it possible to change the rm executable only in a specific directory and not everywhere?
    – tavkomann
    Commented Oct 2, 2017 at 17:19
  • see also How to prevent users from deleting a directory?. Commented Oct 2, 2017 at 17:27
  • Maybe directory protection would suffice for me. chattr +a directory also looks not bad. Is there something similar which allows me to rename and change the files?
    – tavkomann
    Commented Oct 2, 2017 at 18:03

1 Answer 1


You can do that with aufs / unionfs. You put the files which are to be protected in the read-only level.

Real file deletion could be realized with password protection by having the read-only directory in


with ro belonging to a special user and having 755 permissions. Deletions could be done with sudo then:

sudo -u rmuser rm /path/to/ro/file

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .