Home >Operation and Maintenance >Linux Operation and Maintenance >How to set permissions on files in linux
Linux sets the permissions of directories and files:
Set the permissions of files or directories through the chmod command. You can use two forms of permission representation: character form and number. form. The r, w, and x permission characters can be represented as octal numbers 4, 2, and 1 respectively. When representing a permission combination, the numbers need to be accumulated. Related article tutorial sharing: linux tutorial
For example: "rwx" can be expressed as "7" in the form of accumulated numbers, and "r-x" can be expressed as "5", and "rwxr-xr-x" consists of three permission segments, so it can be expressed as "755"
Linux/Unix file calling permissions are divided into three levels: File owner , group, other. Use chmod to control how files are called by others.
Syntax
chmod [-cfvR] [--help] [--version] mode file...
Parameter description
mode: Permission setting string, the format is as follows:
[ugoa...][[+-=][rwxX]...][,...]
Example
Set file file1.txt to be readable by everyone:
chmod ugo+r file1.txt
Set file file1.txt to be readable by everyone:
chmod a+r file1.txt
Set file file1.txt to file2. txt is set as the owner of the file. People who belong to the same group can write to it, but others cannot write to it:
chmod ug+w,o-w file1.txt file2.txt
The above is the detailed content of How to set permissions on files in linux. For more information, please follow other related articles on the PHP Chinese website!