Linux commands change document permissions and owner
- 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
CHGRP Description and examples
[Email protected] ~]# CHGRP [-R] Dirname/filename
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:
[Email protected] ~]# CHGRP users Install.log
[Email protected] ~]# ls-l-rw-r--r--1 root users 68495 June 08:53 Install.log
[[email protected] ~]# CHGRP testing install.log chgrp:invalid Group name ' testing ' <== there was an error message ~ I can't find this group name ~
Chown Description and examples
[[email protected] ~]# Chown [-r] Account name file or directory [[email protected] ~]
# chown [-r] Account name: Group name file or directory options and parameters:-r: Recursive (recursive) continuous change, that is, all files under the sub-directory are changed
Example: Change the owner of the Install.log to bin this account:
[Email protected] ~]# Chown bin Install.log
[Email protected] ~]# ls-l-rw-r--r--1 bin users 68495 June 08:53 Install.log
Example: Change the owner and group of Install.log back to root:
[Email protected] ~]# chown root:root Install.log
[Email protected] ~]# ls-l-rw-r--r--1 root root 68495 June 08:53 Install.log
Note
Tips: In fact, Chown can also use "Chown user.group file", which means adding a decimal point between the owner and the group. It's OK! However, many friends set the account, like to add a decimal point in the account (such as the Vbird.tsai account format), which will cause the system of miscalculation! Therefore, we recommend using the colon ":" to separate the owners and groups! In addition, Chown can also simply modify the group it belongs to! For example "Chown. sshd Install.log" is to modify the group ~ See? Is the use of the decimal point!
The basic rights of the Linux files are nine, respectively, owner/group/others three kinds of identities have their own Read/write/execute permissions, first review the data just mentioned above: The file's permission character: "-rwxrwxrwx", These nine permissions are three three groups! 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
chmod description and examples
[[email protected] ~]# chmod [-r] XYZ file or directory
Options and Parameters: XYZ: Is the permission property of the number type just mentioned, which is the sum of the numeric values of the Rwx property. -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, all permissions are enabled
[Email protected] ~]# ls-al. bashrc-rw-r--r--1 root root 395 Jul 4 11:45. BASHRC
[Email protected] ~]# chmod 777. BASHRC
[Email protected] ~]# ls-al. bashrc-rwxrwxrwx 1 root root 395 Jul 4 11:45. BASHRC
Symbol Type Change file permissions
When you set a file's permissions to be "-rwxr-xr-x", it is basically:
o User (U): With readable, writable, executable permissions;
O Group and Others (G/O): With the right to read and execute
[Email protected] ~]# chmod u=rwx,go=rx. BASHRC
# Watch out! The U=rwx,go=rx is connected, and there is no space in the middle!
[Email protected] ~]# ls-al. bashrc-rwxr-xr-x 1 root root 395 Jul 4 11:45. BASHRC
I just want to add. BASHRC per-person writable permissions for this file
[Email protected] ~]# ls-al. bashrc-rwxr-xr-x 1 root root 395 Jul 4 11:45. BASHRC
[Email protected] ~]# chmod a+w. BASHRC
[Email protected] ~]# ls-al. bashrc-rwxrwxrwx 1 root root 395 Jul 4 11:45. BASHRC
To take out all the people's executable permissions
[Email protected] ~]# chmod a-x. BASHRC
[Email protected] ~]# ls-al. bashrc-rw-rw-rw-1 root root 395 Jul 4 11:45. BASHRC
Linux commands change document permissions and owner