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? Oct 2 '17 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
    Oct 2 '17 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
    Oct 2 '17 at 17:19
  • 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
    Oct 2 '17 at 18:03

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.