We know that file permissions for a system of security importance, but also know the permissions of the file for users and groups of relevance, then how to modify the properties and permissions of a file?
Here we introduce several directives that are commonly used for groups, owners, and various identities. As shown below:
CHGRP: Change the group that the file belongs to
Chown: Changing the file owner
chmod: Features that change file permissions, SUID, SGID, Sbit, and so on
1. Change the group you belong to, CHGRP
Options and Parameters:
-R: Continuous change of recursion (recursive), that is, all files and directories under the sub-directory are updated to the meaning of this group. Often used to change the status of all files in a directory.
Example:
Chgrp:invalid group name ' testing ' <== error message ~ Can't find this group name ~
2. Change the file owner, Chown
[[email protected] ~]# Chown [-r] Account name file or directory [[email protected] ~]# Chown [-r] Account name: Group name file or directory options and parameters:
-rw-r--r--1 root root 68495 June 08:53 Install.log
3. Change permissions, chmod
There are two ways to set permissions, and you can use numbers or symbols to change permissions.
3.1 Number types Change file permissions
There are nine basic permissions on the Linux file, each of which has its own Read/write/execute authority, owner/group/others three different identities.
Example: The file's permission character is-rwxrwxrwx this nine permission is three three a group! Where we can use numbers to represent individual permissions, the scores for each permission are as follows:
R:4 W:2 x:1
Each identity (Owner/group/others) 's respective three permission (R/W/X) scores are cumulative, such as when the permission is: [-rwxrwx---] score:
Owner = rwx = 4+2+1 = 7
Group = RWX = 4+2+1 = 7
others=---= 0+0+0 = 0
So when we set a change in permissions, the number of permissions on that file is 770! The syntax for the Change permission directive chmod is this:
[[email protected] ~]# chmod [-r] XYZ file or directory options and parameters: XYZ: Is the permission property of the number type just mentioned, which adds the value of the rwx attribute. -R: Continuous change of recursion (recursive), i.e. all files in the sub-directory will be changed
For example, if you want to set the. bashrc file with all permissions enabled, then release:
-rwxrwxrwx 1 root root 395 Jul 4 11:45. BASHRC
What if you want to turn permissions into-rwxr-xr--? Then the score of the privilege becomes [4+2+1][4+0+1][4+0+0]=754! So you need to release:
[Email protected] ~]# chmod 754 filename
3.2 Symbol Type change file permissions
There is also a way to change the permissions yo! From the previous introduction, we can find that basically nine permissions are (1) User (2) group (3) Others three kinds of identities! Then we can represent three kinds of identities by u, G, O! In addition, a represents all and all identity! Then the permission to read and write can be written as R, W, X! That is, you can see it in the following way:
Let's experiment! If we want to set a file's permission to become "-rwxr-xr-x", basically is:
o User (U): With readable, writable, executable permissions;
O Group and Others (G/O): Has the ability to read and not execute.
So it is:
-rwxr-xr-x 1 root root 395 Jul 4 11:45. BASHRC
So what if it's a privilege like "-rwxr-xr--"? You can use "chmod u=rwx,g=rx,o=r filename" to set it. Also, if we know the original file attributes, and I just want to increase the. BASHRC per-person writable permissions for this file, then I can use:
-rwxrwxrwx 1 root root 395 Jul 4 11:45. BASHRC
And if you want to remove permissions without changing other existing permissions? For example, to take out the executable permissions of all people:
-rw-rw-rw-1 root root 395 Jul 4 11:45. BASHRC
Ext.: http://www.cnblogs.com/yangjinjin/p/3165076.html
How Linux Changes file properties and permissions