Linux files are divided into three identities and four-way permissions.
- U: Owner of File
- G: The group to which the file belongs
- O: Other users
For each identity, there are four different permissions, namely:
- R: Permission to read files (read)
- W: Permission to write to file (write)
- X: Execute permission (execute)
- S: Special Permissions
In the Linux file permissions explained in detail, we know that there are two ways to represent file permissions in Linux, respectively, the number and symbol representation.
chmod changing file permissions in digital form
chmod 755 test.sh
Convert 755 into character form, rwxr-xr-x, that is, the file owner, group and other users can read and run test.sh this file, but only the owner can write to this file, that is, other people do not have the right to modify test.sh this file. (Of course, the root user does not have this limitation, who wants to change who, this is also an experience that embodies the supremacy of root account!) )
To change the permissions of the file through the mathematical form is relatively simple, as long as the implementation of the permissions required to give the file, and then call the chmod instruction, the call form is:
chmod New Permissions File list
chmod changing file permissions as characters
chmod +x test.sh
The mathematical form can change the file of all three identities of four permissions at a time, and the character form is more flexible, you can give a certain identity of a permission to set a separate, such as the above instruction is to give three kinds of identities to give execution permissions, you can also separate settings:
chmod u+x test.sh Only add executable permissions to the owner
chmod g+x test.sh Only add executable permissions to group identities
chmod o+x test.sh Only add executable permissions to other people
All of the above three directives are combined to be equivalent to the one above, which is the ability to turn on executable permissions for all identities, and you can do the following as well:
chmod a+x test.sh
The A here represents all of the 3 identities!
If you want to remove a certain privilege from an identity, you only need to change the + to-can, for example, remove the executable permission for someone else's identity:
chmod o-x test.sh
For read, write and other permissions, follow the above way to practice more, chmod through the character of the file permissions to change the operation see the following table:
chmod |
U G O A |
+ (plus) -(minus) = (set) |
R W X |
Documents or items |
Finally, a comprehensive example, after a similar problem extrapolate can:
chmod u=rwx,g+rx,o-x test.sh
Ext.: http://blog.csdn.net/wuwenxiang91322/article/details/9259877
chmod use of Linux