Get the App
SLTechnology News&Howtos  ›  Servers  › 

Application of File permission in Linux

Shulou Source: shulou.com Published: 2022-06-03 05:04:50 10月03日 Update

Linux system has very strict control over the permissions of files. If the operator performs some operation on a file, he must have the corresponding operation authority to execute successfully. The types of permissions generally include read, write and execute, and the corresponding letters are r, w, x respectively.

If we want to represent all the permission details of a file, there are two ways:

1. Ten-bit binary representation (each of the three genera groups uses a binary bit, plus a total of ten bits), which can be simplified to a three-bit octal form

2. Twelve-bit binary representation (twelve binary bits), which can be simplified to four-bit octal form

Ten-digit permission representation

Common expressions of permissions are:

-rw- (600) only the owner has read and write access.

-rw-r--r-- (644) only the owner has read and write access, while group users and other users only have read access.

-rwx- (700) only the owner has read, write and execute permissions.

-rwxr-xr-x owners have read, write and execute permissions, while group users and other users only have read and execute permissions.

-rwx--x--x owners have read, write, and execute permissions, while group users and other users only have execute permissions.

-rw-rw-rw- (666) all users have file read and write permissions.

Rwxrwxrwx (777) all users have read, write and execute permissions.

Analysis of the last nine digits: Linux permissions have a total of three subordinate groups, each using three locations to define three kinds of operation (read, write, execute) permissions, which together are the last nine digits of the permissions. Permissions are represented by characters above, where-represents no permission, r represents read permission, w represents write permission, and x represents execution permission.

In fact, the meaning of each location in the last nine digits (representing a permission belonging to a group) is fixed, and if the permissions of each location are replaced by binary numbers 1 and 0, then read-only, write-only, and execute-only permissions can be expressed as three-digit binary numbers.

Rmurf-= 100

-w-= 010

-- x = 001

-= 000

Explanation of the first highest bit: the last nine digits in the permission representation are mentioned above, and the remaining first bit represents the type of the file, which can be one of the following:

D stands for directory (directroy)

-represents a file (regular file)

S stands for set file (socket)

Pipe file (pipe) or named pipe file (named pipe) represented by p

L stands for symbolic link file (symbolic link)

B represents that the file is a block-oriented device file (block-oriented device file)

C represents a character-oriented device file (charcter-oriented device file).

The above are the details of the Linux file permissions, please pay more attention to other related articles!

Tags: Permissions files representatives users binary only owner three location form type highest octal pipeline representation device success about content meaning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Docker Shulou Information MySQL Huawei