tutor:File system
Permissions
Symbolic notation
Each class of permissions is represented by three characters.
- The first set of characters represents the user class.
- The second set represents the group class.
- The third and final set of three characters represents the others class.
Each of the three characters represent the read, write, and execute permissions respectively:
-
rif the read bit is set,-if it is not. -
wif the write bit is set,-if it is not. -
xif the execute bit is set,-if it is not.
Three groups of three
- first - what the owner can do
- second - what the group members can do
- third - what other users can do
The triplet
- first
- r: readable.
- second
- w: writable.
- third
- x: executable.
- s: executable and setuid.
- S: setuid but not executable.
The following are some examples of symbolic notation:
-
-rwxr-xr-xfor a regular file whose user class has full permissions and whose group and others classes have only the read and execute permissions. -
crw-rw-r--for a character special file whose user and group classes have the read and write permissions and whose others class has only the read permission. -
dr-x------for a directory whose user class has read and execute permissions and whose group and others classes have no permissions.
Octal notation
octal notation consists of a three- or four-digit base-8 value. With three-digit octal notation, each numeral represents a different component of the permission set:
- user class,
- group class,
- and "others" class respectively.
Each of these digits is the sum of its component bits, and as a result, specific bits add to the sum as it is represented by a numeral:
- The read bit adds 4 to its total (in binary 100),
- The write bit adds 2 to its total (in binary 010), and
- The execute bit adds 1 to its total (in binary 001).
These are the examples from the Symbolic notation section given in octal notation:
-
-rwxr-xr-xwould be represented as 755 in three-digit octal. -
-rw-rw-r--would be represented as 664 in three-digit octal. -
-r-x------would be represented as 500 in three-digit octal.
Here is a summary of the meanings for individual octal digit values:
0 --- no permission 1 --x execute 2 -w- write 3 -wx write and execute 4 r-- read 5 r-x read and execute 6 rw- read and write 7 rwx read, write and execute
Note the similarity to binary counting (starting at the right and going left):
0: 000 1: 001 2: 010 3: 011 4: 100 5: 101 6: 110 7: 111
Octal digit values can be added together to make Symbolic Notations:
(4=r)+(1=x) == (5=r-x) (4=r)+(2=w) == (6=rw-)
(4=r)+(2=w)+(1=x) == (7=rwx)
Here is a summary showing which octal digits affect permissions for user, group, and other:
- UGO = User, Group, Other
- 777 = "-rwxrwxrwx" = rwx for all
- 754 = "-rwxr-xr--" = rwx for owner, r-x for group, r-- for other
- 124 = "---x-w-r--" = x for owner, w for group, r for other