Unix file permissions

Unix file permissions come in threes. 

There are three numbers per file, each of which represents the permissions for one of these roles:
  • user (u) (i.e., owner),
  • group (g),
  • other (o).
There are three permissions:
  • read (r),
  • write (w),
  • execute (x).
The numbers range from 1 to 7. (A zero means "no permissions.") And because of how the numbers are constructed, each number uniquely identifies a set of permissions for the party it refers to.

Specifically, the each permission corresponds to these numbers:
  • read = 4
  • write = 2
  • execute = 1
By combining these, we get every possible combination of permissions (common ones in bold):
  • 1 = execute only (not read or write)
  • 2 = write only (not execute or read)
  • 3 = write + execute (but not read)
  • 4 = read only (not write or execute)
  • 5 = read + execute (but not write)
  • 6 = read + write (but not execute)
  • 7 = read + write + execute (i.e., everything)
So here are the meaning of some common permission sets:
  • 644 = user can read/write, group and others can only read.
  • 755 = user has full permissions; group and others cannot write.
  • 775 = user and group have full permissions; others cannot write.
References:
Comments