Function Description: Change the file or directory permissions. Syntax: chmod [-cfRv] [-- help] [-- version] [& lt; permission range & gt; +/-/= & lt; permission settings... & gt;] [file or directory...] or chmod [-cfRv] [-- help] [-- version] [digit code] [file or directory...] or chmod [-cfRv]
Function Description:Change the permissions of a file or directory.
Syntax:Chmod [-cfRv] [-- help] [-- version] [ <权限范围> +/-/= <权限设置...> ] [File or directory...] or chmod [-cfRv] [-- help] [-- version] [digit code] [file or directory...] or chmod [-cfRv] [-- help] [-- reference = <参考文件或目录> ] [-- Version] [file or directory...]
Note:In the UNIX system family, the control of file or directory permissions is divided by reading, writing, and executing three general permissions, and three special permissions are available, then, combine the owner with the management permission range of the group. You can use the chmod command to change the permissions of files and directories. The permission of the symbolic connection cannot be changed. If you modify the permission of the symbolic connection, the permission change will be applied to the connected original file. The permission range is expressed as follows:
U: User, the owner of a file or directory.
G: Group, that is, the Group to which the file or directory belongs.
O: Other. All Users except the file or directory owner or group belong to this range.
A: All, that is, All users, including owners, groups, and other users.
For details about the permission code, go to the following list (calculated in binary notation, 111,011,001,000 respectively ):
R: Read Permission, number code: "4 ".
W: Write Permission. The number is "2 ".
X: execute or switch the permission. The number is "1 ".
-: You do not have any permission. The digit code is "0 ".
S: Special? B> Function Description: Change the file or directory permissions.
Parameters:
-C or -- changes has a similar effect to the "-v" parameter, but only the changed part is returned.
-F or -- quiet or -- silent Do Not Display error messages.
-R or -- recursive processing: all files and subdirectories under the specified directory are processed together.
-V or -- verbose displays the command execution process.
-- Help Online help.
-- Reference = <参考文件或目录> Set all permissions for the specified file or directory to the same as those for the reference file or directory.
-- Version: displays the version information.
<权限范围> + <权限设置> Enable the permission settings for files or directories within the permission range.
<权限范围> - <权限设置> Disable the permission settings for files or directories within the permission range.
<权限范围> = <权限设置> This permission is set for files or directories within the specified permission range.
Symbol mode:
You can set multiple projects in symbolic mode: who (user type), operator (operator), and permission (permission). The setting of each project can be separated by commas. The command chmod modifies the access permission of the user type specified by who to the file. The user type is indicated by the location of one or more letters in who, as shown in the who symbol mode table:
Who |
User Type |
Description |
U |
User |
File owner |
G |
Group |
File owner Group |
O |
Others |
All other users |
A |
All |
User used, equivalentUgo |
Operator symbol mode table:
Operator |
Description |
+ |
Add permissions for the specified user type |
- |
Remove permissions of the specified user type |
= |
Set the specified user permission to reset all permissions of the User Type |
Symbol mode table of permission:
Mode |
Name |
Description |
R |
Read |
Set as read permission |
W |
Write |
Set to writable |
X |
Execution permission |
Set as executable permission |
X |
Special execution permission |
The file permission can be set to executable only when the file is a directory file or other types of users have executable permissions. |
S |
Setuid/gid |
When an object is executed, set the setuid or setgid permission for the object based on the user type specified by the who parameter. |
T |
Paste bit |
Set the position to be pasted. Only the Super User can set this bit. Only the file owner u can use this bit. |
Linux community http://www.linuxidc.com]
Example 1: Set file1.txt to readable:
Chmod ugo + r file1.txt
Set file1.txt to readable:
Chmod a + r file1.txt
Set file1.txt and file2.txt as the owner of the archive, which can be written to the same group to which the archive belongs, but not to others:
Chmod ug + w, o-w file1.txt file2.txt
Set ex1. to only the owner of the file to execute:
Chmod u + x ex1
Set all files and subdirectories in the current directory to be readable by anyone:
Chmod-R a + r *
When another user executes the SQL plus program of Oracle, his identity will be changed to oracle for the time being.
Chmod u + s sqlplus
In addition, chmod can also use numbers to indicate permissions, such as chmod 777 file.
Syntax: chmod abc file
Each a, B, and c is a number, indicating the permissions of the User, Group, and Other respectively.
R = 4, w = 2, x = 1
If you want the rwx attribute, 4 + 2 + 1 = 7;
If the rw-attribute is required, 4 + 2 = 6;
If you want the r-x attribute, 4 + 1 = 5.
Example 2:
Chmod a = rwx file
And
Chmod 777 file
Same effect
Chmod ug = rwx, o = x file
And
Chmod 771 file
Same effect
If you use chmod 4755 filename, you can grant root permissions to this program.
Example 3:
Run the following command after cd/media/amasun/java/develop/array:
Chmod 777 ./
Is to set this directory (I .e./media/amasun/java/develop/array) to anyone readable, write, execute
If yesAdministratorThat is to say, ROOT users have the right to view all files.
Example 4:
Command |
Description |
Chmod a + rFile |
Add read permission to all users of the file |
Chmod a-xFile |
Delete all users who execute the file |
Chmod a + rwFile |
Add read/write permissions to all users of the file |
Chmod + rwxFile |
Add the read/write permission to all users of the file. |
Chmod u = rw, go =File |
Set the read and write permissions for the file owner, clear all permissions for the file user group and other users |
Chmod-R u + r, go-rDocs |
Add read permissions for all users to the directory docs and all files in its subdirectory hierarchy, and delete read permissions for user groups and other users. |
Chmod 664File |
Set the read and write permissions for the file owner and user group, and set the read permissions for other users. |