kazmax - Home Server on Linux

Symbolic notation and numerical notation of access right (permission)

We confirmed the file / directory access right with "ls - l". r, w, x, - represents access authority, but in addition to this it can also be represented by numbers.

If you are managing websites etc by FTP this representation may be more familiar.

Numeric representation of permissions is also used for permission management commands of files and directories described later and is often used in descriptions of open source systems deployed all over the world. It is something useful to remember.

Last Update : March 03, 2019

Symbolic notation and numerical notation of access right (permission) Contents

  1. Relationship between symbols and numbers representing access rights(permission)
  2. Express access rights(permission) numerically

1. Relationship between symbols and numbers representing access rights(permission)

Representation of authority by symbol can be replaced with numerical value as follows.

Symbol Number Corresponding authority
r 4 file can be read
w 2 file can be written to
x 1 file can be executed (if it is a program)
- 0 specific permission has not been assigned

2. Express access rights(permission) numerically

To express the access right as a numerical value, divide the notation of the access right represented by the symbol into sections of "owner", "group", "other", convert the symbol to a numerical value, Add a number to.

I will try to express access rights numerically by referring to the above table.

Example) In case of rwxr-xr--

Owner Group Other
rwx r-w r--
4 + 2 + 1
= 7
4 + 0 + 1
= 5
4 + 0 + 0
= 4

Since the authority for the owner is "rwx", replacing it with a numerical value will result in "4 + 2 + 1" and the result will be "7".

Since the authority for the group is "r - x", replacing it with a numerical value will result in "4 + 0 + 1" and the result will be "5".

Since the authority for others is "r--", replacing it with a numerical value, it will be "4 + 0 + 0" and the result will be "4".

When all together, "rwxr-xr--" can be denoted as "754".

Notes

Details are explained in the corresponding section, but for example,

# chmod 754 text.txt

Then you can change the permission of test.txt to 754 (rwxr-wr--).

In the open source distributed to the world, there are explanations such as "Make this directory permission 777", "Make this file 755", and so on.