0

On a Mac, is there a way to prevent files in a folder X from being moved by any means (by the Comd+C then Comd+Opt+V on Finder, or by mv command on the command line, or by other apps etc.) to another folder Y, but still allow files to be written/added to the folder X, and still allow files to be copied from the folder X?

If needed, please answer specific to Mac 10.11 to 10.14, and take into account both HFS+ and APFS file systems.

1
  • 1
    Change the owner/group to root:wheel and set the appropriate ACLs. See man chown and man chmod in Terminal. Commented Jul 17, 2019 at 15:37

2 Answers 2

1

You can use Access Control Lists for this. Run

chmod +a "USERID:deny:delete_child" DIRECTORY

to prevent the user USERID from deleting anything from the directory. To undo, run

chmod -a "USERID:deny:delete_child" DIRECTORY

PS: If you want to have it applied to current and future subfolders beneath DIRECTORY as well, use

"USERID:deny:delete_child,directory_inherit"
0

I came across the same question on my Mac. The way I achieved it was like this:

Say, your file is foo.txt and you want to have read/write access while no other application could move/rename the file.

  1. I stow my original file (foo.txt) either in another folder, or rename (if it must stay in the same folder), say, to bar.txt

  2. in the desired location I create a symlink to that file, e.g. if it's in the same folder then:

ln -s bar.txt foo.txt

  1. then I lock the symlink file itself with chflags -h uchg foo.txt

That way the file (symlink) foo.txt is locked (cannot be moved / deleted / renamed), while the original file bar.txt can be read/written.

You must log in to answer this question.

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