File Systems: The Interface

file permissions

On a shared computer, not everyone should be able to read everyone else's diary or delete the system's files. File permissions are the simple, time-tested rules that decide who may do what to each file. The classic Unix scheme answers two questions for every file: WHO is asking, and WHICH action do they want?

It divides the world into three classes relative to a file: the owner (usually the file's creator), the group (a named set of users who share access), and others (everyone else). For each class it grants or denies three actions: read (look at the contents), write (change the contents), and execute (run the file as a program; for a directory, execute means permission to enter it). That is three classes times three actions, nine bits in all, often shown as a string like rwxr-xr-x, read as owner rwx, group r-x, others r-x. The same nine bits can be written as an octal number, which is where chmod 755 comes from: 7 is rwx for the owner, each 5 is r-x. When a process touches a file, the OS checks the relevant class's bits and allows or refuses the action.

Why it matters: this scheme is the everyday foundation of protection on Unix-like systems, compact enough to store in a few bits yet expressive enough for most needs. Its honest limitation is exactly that compactness. With only three classes you cannot say "these two specific people may write, and these five may only read", the group is a single bucket. That gap is what access-control lists were invented to fill. A frequent misconception: making a file executable does not make it safe to run; the execute bit only grants permission, it says nothing about whether the program is trustworthy.

A script with permissions rwxr-xr-x (chmod 755): the owner can read, write, and run it; the group and others can read and run it but not modify it. Change it to rwxr-x--- (chmod 750) and others lose all access entirely.

Three classes (owner/group/other) times three actions (read/write/execute) = nine bits.

Three classes are too coarse to grant different rights to many specific users, that is what ACLs add. And the execute bit only grants permission to run a file; it says nothing about whether the program is safe.

Also called
permission bitsmode bits權限位元