chmod, this Linux command in the previous VPS host installation environment and compile the script also need to use, used to set the site, file directory permissions, such as we give the site a directory and file set readable, read-only, etc., to ensure that the file and directory security settings.
hmod [options] mode files
Only file owners or privileged users can use this feature to change file access mode. Mode can be a digital form or expressed in the form of who opcode permission. Who is optional, by default is a (all users). Only one opcode (opcode) can be selected. Multiple mode can be specified, separated by commas.
Options
-c,--changes
Only the information of the changed file is exported
-f,--silent,--quiet
The user who does not notify the file when chmod cannot change the file mode
--help
Output help information.
-r,--recursive
Recursively traverse subdirectories and modify all files and subdirectories in the directory
--reference=filename
To set permissions by referencing the permissions of filename
-v,--verbose
Output information for each file, regardless of whether the modification was successful
--version
Output version information.
U:user, i.e. the owner of a document or directory;
G:group, that is, the group of files or directories;
O:other, in addition to file or directory owners or groups, other users belong to this scope;
A:all, that is, all users, including owners, groups and other users;
In the current identity of a file, permissions include itself, as well as permissions in the existing group, and permissions outside the group.
R: Read permission, the number is code-named "4";
W: Write permission, the number is code-named "2";
X: Execute the Authority, the numeral code is "1";
-: Without any authority, the digital code is "0";
S: Special Feature Description: Changes to the file or directory permissions.
Here file user identity is divided into 4 kinds, each user identity has corresponding different permissions, is generally read, write, execute. Generally we see the rwx corresponding number added, in fact, the same as the character representation, but need a separate setting.
Third, the explanation of examples
The code is as follows |
Copy Code |
Chmod-r 755 Itbulu
|
From this example we can see Setting 7 (Owner rights), 5 (the group permissions), 5 (Other group user rights) in the Itbulu folder and subdirectories.
The code is as follows |
Copy Code |
Chmod-r 644 Itbulu
|
Indicates that the owner has read and write access, and other users have read-only access.
The code is as follows |
Copy Code |
Chmod-r 777 Itbulu
|
Indicates that everyone has read, write, and execute permissions.
The code is as follows |
Copy Code |
chmod u+x,g+w Itbulu
|
This indicates that the owner user has execute permission and the group user member has write permission.
The code is as follows |
Copy Code |
chmod u=rxw,g=rwx,o=rwx Itbulu
|
This is the same as the 777 permissions we see above, and sometimes it is simpler to express numbers.
The code is as follows |
Copy Code |
chmod o-x itbulu.sh
|
Incidentally, here's a reference to =,+,-. These three represent a complete grant, add a permission, lose a certain permission, such as an example above may not need to give O other users to execute permissions, then here is the minus.
Summary, chmod, the set of permissions seems simple, but in the actual use of the more exquisite, can not disorderly set higher permissions, otherwise the file will have security risks, also can not set too low permissions, or recovery can not be implemented.
S