chmod (change mode) changing permissions
[[email protected] ~]# ls-l total usage 8-rw-r--r--. 1 root root 0 June 8 14:16 2.txt-rw-------. 1 root root 7728 June 6 22:11 anaconda-ks.cfg.1
-rw-r--r--.
  this paragraph, except the first .
Indicates whether the file is subject to selinux limit * (SELinux if disabled, the new file/directory will not have this point, otherwise there will be) *, the middle of the nine-bit, Represents the permissions for the file or folder.
The first three bits represent the permissions of the file/directory owner.
The middle three bits represent the permissions of all the members in the group to which the file/directory belongs
The last three bits represent the way out of the owner and the owning group, other users ' permissions to the file/directory.
R:read--Read w:write--write X:execute--and execute
-rw-r--r--. 1 root root 0 June 8 14:16 2.txt
Root user has r and W permissions for 2.txt files, no X permissions root user group has R permissions on 2.txt files, no W and x permissions other users have R permissions on 2.txt files, no W and x permissions
x--2 of 0 Square W--and 2 of 1 square R--and 2 of 2 times the number of each segment is added to get the corresponding user's permission number for the file   rw-r--r--
  equals 6 4 4
Permissions that are represented using numbers
[[email protected] ~]# chmod 2.txt[[email protected] ~]# ls-l total usage 8-rwx------. 1 root root 0 June 8 14:16 2.txt-rw-------. 1 root root 7728 June 6 22:11 anaconda-ks.cfg.1
2. Permissions represented with R,w,x
[[email protected] ~]# chmod u=rw,g=rx,o=x 2.txt[[email protected] ~]# ls -l Total dosage 8-rw-r-x--x. 1 root root 0 6 month  8 14:16 2.TXT-RW-------. 1 root root 7728 6 Month 6 22:11 anaconda-ks.cfg.1
> U--user> G--and group> O--and other**== special note: Use this way, can not be written u=rw-,g=r-x,o=--x, the middle can not appear-, although sometimes can be passed, but this write is not Reasonable. As you will see later, there is a way to modify permissions by using the "+" or "-" numbers to control the increase and decrease of permissions. ==**3. Control permissions with +-sign
[Email protected] ~]# chmod a+x 2.txt[[email protected] ~]# ls-l total usage 8-rwxr-x--x. 1 root root 0 June 8 14:16 2.txt
> A--all, A + x, and all users add x permissions to the file/directory.
[Email protected] ~]# chmod a-r 2.txt[[email protected] ~]# ls-l total usage 8--wx--x--x. 1 root root 0 June 8 14:16 2.txt
> Reduce R permissions for files/directories for all users
[Email protected] ~]# chmod u+r 2.txt[[email protected] ~]# ls-l total usage 8-rwx--x--x. 1 root root 0 June 8 14:16 2.txt
> Add R permissions to user alone.
Modify permissions, all files within the directory, subdirectories are in effect
[[email protected] ~]# tree /tmp/allinlinux//tmp/allinlinux/└── 1.txt0 directories, 1 file[[email protected] ~]# ls -l /tmp/allinlinux/Total Dosage 0- Rw-r--r--. 1 root root 0 6 Month 8 14:58 1.txt[[email Protected] ~]# ls -l /tmp/allinlinux/1.txt -rw-r--r--. 1 root root 0 6 month 8 14:58 /tmp/allinlinux/1.txt
/tmp/allinlinux directory has a 1.txt file allinlinux/the permission to the directory is   1.txt file permissions are
[[email protected] ~]# chmod -r 777 /tmp/allinlinux/[[email protected] ~]# ls -l /tmp/allinlinux/Total dosage 0-rwxrwxrwx. 1 root root 0 6 Month 8 14:58 1.txt[[email protected] ~]# ls -l /tmp/allinlinux /1.txt -rwxrwxrwx. 1 root root 0 6 Month 8 14:58 /tmp/ Allinlinux/1.txt
The permissions for the/allinlinux/directory and its files have changed.
This article is from the "Linux Road" blog, make sure to keep this source http://allin28.blog.51cto.com/12931477/1933854
Linux change file or directory permissions