Linux Permissions – Why Do ‘Owner’ Permissions Exist?

linuxpermissions

I think I rather understand how file permissions work in Linux. However, I don't really understand why they are split into three levels and not into two.

I'd like the following issues answered:

  • Is this deliberate design or a patch? That is – was the owner/group permissions designed and created together with some rationale or did they come one after another to answer a need?
  • Is there a scenario where the user/group/other scheme is useful but a group/other scheme will not suffice?

Answers to the first should quote either textbooks or official discussion boards.

Use cases I have considered are:

  • private files – very easily obtainable by making a group per-user, something that is often done as is in many systems.
  • allowing only the owner (e.g. system service) to write to a file, allowing only a certain group to read, and deny all other access – the problem with this example is that once the requirement is for a group to have write access, the user/group/other fails with that. The answer for both is using ACLs, and doesn't justify, IMHO, the existence of owner permissions.

NB I have refined this question after having the question closed in superuser.com.

EDIT corrected "but a group/owner scheme will not suffice" to "…group/other…".

Best Answer

History

Originally, Unix only had permissions for the owning user, and for other users: there were no groups. See the documentation of Unix version 1, in particular chmod(1). So backward compatibility, if nothing else, requires permissions for the owning user.

Groups came later. ACLs allowing involving more than one group in the permissions of a file came much later.

Expressive power

Having three permissions for a file allows finer-grained permissions than having just two, at a very low cost (a lot lower than ACLs). For example, a file can have mode rw-r-----: writable only by the owning user, readable by a group.

Another use case is setuid executables that are only executable by one group. For example, a program with mode rwsr-x--- owned by root:admin allows only users in the admin group to run that program as root.

“There are permissions that this scheme cannot express” is a terrible argument against it. The applicable criterion is, are there enough common expressible cases that justify the cost? In this instance, the cost is minimal, especially given the other reasons for the user/group/other triptych.

Simplicity

Having one group per user has a small but not insignificant management overhead. It is good that the extremely common case of a private file does not depend on this. An application that creates a private file (e.g. an email delivery program) knows that all it needs to do is give the file the mode 600. It doesn't need to traverse the group database looking for the group that only contains the user — and what to do if there is no such group or more than one?

Coming from another direction, suppose you see a file and you want to audit its permissions (i.e. check that they are what they should be). It's a lot easier when you can go “only accessible to the user, fine, next” than when you need to trace through group definitions. (Such complexity is the bane of systems that make heavy use of advanced features such as ACLs or capabilities.)

Orthogonality

Each process performs filesystem accesses as a particular user and a particular group (with more complicated rules on modern unices, which support supplementary groups). The user is used for a lot of things, including testing for root (uid 0) and signal delivery permission (user-based). There is a natural symmetry between distinguishing users and groups in process permissions and distinguishing users and groups in filesystem permissions.

Related Question