Permissions
First, the basic permissions of the file
The so-called permission is the user's ability to access the file, the basic permissions of the file include R (read), write, X (executable).
To view the permissions properties of a file with Ls-ld files:
Drwxr-xr-x 4 root root 4096 Jul 3 21:29 file
drwxr-xr-x: Description of file types, common file types are: D catalog file, L link file, c linear device file, B block device file, s Sorket file,-General file, p pipeline file
Drwxr-xr-x: This file (directory) belongs to the master user right
drwxr-xr-x: This file (directory) belongs to group user rights
Drwxr-xr-x: This file (directory) other user rights
1) The permissions for the directory and file specific meanings are as follows:
Directory:
R: You can use the LS command to view the list of files in the directory (using the LS-L parameter also cannot view the contents)
W: You can create and delete files in the directory
X: You can CD into this directory, and you can use LS-L to display metadata information for this file
File:
R: can view file contents
W: Can modify the contents of the file
X: This file can be executed as a script
2) The permissions model when the user accesses the file:
if (owner of the Running program = This program is accessing the owner of the file)
Access to the file in the owner's right of identity;
else if (the genus Group of the Running program = This program is accessing a group of files)
Access files as a group of identities;
Else
Access to other user's privileges;
3) Common file Rights Management commands
chmod changing file permissions
usage:chmod [Options] ... mode [, Mode] ... File...
Or: chmod [options] ... Octal mode file ...
Or: chmod [options] ...--reference= reference file ...
Manipulating objects |
Permission settings |
Permission value |
Example |
U file belongs to master permission
G Same group User rights o Other user rights A all users (including the above three types) |
+ Add Permissions -Cancel Permissions = Unique Set permissions |
R-->4 W-->2 X-->1 |
1, modify/tmp/test file owner's permission is rwx, group permissions are r-x, other user rights r-x Chmod 755 /tmp/test Or: chmod u=rwx,go=r-x /tmp/test 2, on the basis of 1 problems, belong to the master, belong to the group, other users have to remove the X permission Chmod a-x /tmp/test Or: chmod u-x,g-x,o-x/tmp/test Or: chmod 644 /tmp/tes 3, modify the/tmp/test1 directory file of the owner of the permission is rwx, the permissions of the group is r-x, other user rights r-x, and in the directory where all the files are this permission Chmod-r 755 /tmp/test1 Or: Chmod-r u=rwx,go=r-x /tmp/test1 4, on the basis of question 1, the permissions of the group become rwx Chmod 775/tmp/test Or: chmod g+w/tmp/test 5, with/tmp/test permissions as the basis, let/tmp/test2 file permissions and the same as he Chmod--reference=/tmp/test /tmp/test2 |
In general, you can choose a mode to modify permissions according to your preference.
Umask: Sets the system default mask for permissions when a new file or directory is first created.
For the directory, the newly created directory permission is 777-umask_value; for a file, the newly created file permission is 666-umask_value.
[[email protected] test]# umask 0022[[email protected] test]$ umask 0002[[email protected] test]$ ID centosuid=500 (CentOS) gid=500 (CentOS) groups=500 (CentOS), (magedu) [[email protected] ~]$ umask 0022[[email protected] ~]$ iduid=4400 ( Mandriva) gid=3302 (Linux) groups=3302 (Linux), 2201 (Gentoo), 3300 (distro), 3301 (Peguin)
The masks for administrators and ordinary users are generally not the same. The mask value of the newly created file or directory is 0002 for the same group and the master user name, and the mask value of the newly created file or directory is the same as the mask value of the administrator user for the genus Group and the master user name, which is 0022.
To be Continued ...
This article is from the "After Dark" blog, be sure to keep this source http://guoting.blog.51cto.com/8886857/1435019