We have some "living documents", which are accessed by multiple peaple. Is there a way in unix to make a file only readable and writeable, but not moveable nor copyable nor deleteable?

The purpose of this is to ensure that there is only one copy of the file on the network.

  • 4
    How would a readable file not be copyable? Also, deletability is a property of the parent folder, not the file. – Kusalananda Jun 19 '18 at 6:27
  • Dear Kusalananda, I know that it is a difficult talk. so I would be happy if we can solve parts of it:We can approach it, putting the file into a folder. and making the folder non-deletable.The copy problem we could solve sending soft-links to the user instead the file itself. – Marcel Sonderegger Jun 19 '18 at 6:50
  • 1
    Making the parent folder non-writable would make the file non-deletable. But as soon as you have a readable file, meaning you can open it in an editor, you then it's copyable. Symbolic links will not change this. – Kusalananda Jun 19 '18 at 6:57
  • I am well aware, that when you open it in an editor, then it can be copied. However I could write an instruction, that the file shall not be saved with a new name (This is a compromise, I know) – Marcel Sonderegger Jun 19 '18 at 7:04
  • Then you don't have to make the file not-copyable. – Kusalananda Jun 19 '18 at 7:08

Assuming that the file and the directory the file lives in (its parent directory ) is owned by a totally separate user, and belongs to a joint group...

Making the parent directory of the file non-writable for the group would make the file non-deletable by the members of that group. By having the file non-deletable by group members, you ensure that the file can't be moved away from its parent directory by those group members.

You can't make the file readable and non-copyable since reading the file is inherently allowing users to copy it.

"Others" would have no permissions on the file or parent directory.

Ideally, you would use some form of system, possibly backed by git, that would allow people to collaborate on the file in a controlled manner. This would allow for easier access control, remote access, and also for revision control.

  • Both of your ideas are great. Using git would make it perfect, so probably we are going with this solution. – Marcel Sonderegger Jun 20 '18 at 12:23

On Solaris (on ZFS), you could call:

chmod S+cu file

On FreeBSD, you could call:

chflags sunlink file

On Linux, could could call

chattr +u file

In all cases you need to be superuser to set the flag.

Linux does not support this on ext* filesystems.

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.