Linux file permissions identification mechanism

1. decoding

When we use the ls -l command to view file similar specific information, we can see that Linux files are displayed in the following form:

drwxr--r-- root root ...

What does it mean? How to resolve this string of identity?
Firstly, that identifies the file permissions drwxr - r-- string, the head of the d identifies the type of the file, Linux file types identified as follows:

(1)-:普通文件 
(2)d:目录
(3)c:字符设备文件
(4)b:块设备文件
(5)l:链接文件
(6)s:本地域套接口 (socket)
(7)p:有名管道 (pipeline)

After removal of the first file type identification, and the rest rwxr - r-- , which each have four optional identifier represents, respectively, as follows:

1. r:读权限
2. w:写权限
3. x:文件执行权限
4. -:无对应权限

It will be divided into 3 parts, respectively rwx r-- r-- , each part respectively:

    1. Owned by user (user) privileges
    1. Owned by group (group) rights
    1. Other users (other) authority

For the above permission to do the following explanation:

  • Owned by user (root) have R & lt (read), w (write), x (execute) permissions
  • Owned by group (root) have R & lt (read) authority
  • R & lt owned by another user (read) authority

2. coding

File permissions identifier may be encoded as a decimal integer 3
EG. Rwx r-- r-- using the following encoding algorithm:
The sections are calculated. First, the first portion rwx terms, which represent three binary-coded bit, a first bit is readable identification (R & lt), whether the second identification bit writable (w), the third identifier is executable (x).
The value of each bit, 1 means enable, on the contrary represents 0 Unable, thus rwx the binary representation 111 , it is to decimal 7 .
Also for the two portions r-- r-- , which are binary coded 100 100 , respectively coded decimal 44 , thus identifying the file permissions rwx r-- r-- decimal coded as 744 .

3. Use

Coded decimal file permissions may be used in the identification chmod command may be used chmod -R 755 DirectoryName form of authorization to all files in the folder 755 , i.e. rwxrw-rw- .

Guess you like

Origin www.cnblogs.com/hyj2357/p/12177440.html