###################################################################
##################### #第六单元 ######################################
###################################################################
1. File Properties View
ls-l filename
-rw-rw-r--1 root root 17:05 Oct 2 file
File file copy number file file size Last name
Type permissions (number of files stored) Everyone all groups Modified Time
2. View Directory Properties
ls -ld directoy
d rwxr-xr-x 3 root root / & nbsp 09:47 directory
File types Permissions subdirectories number directory owner Directory all groups sub-file attribute size time directory name
(File type and permissions total 10 bits, divided into four paragraphs, the first paragraph is the type, the second paragraph is the owner permission, the third paragraph belongs to the group member's permission, fourth paragraph other person's permission)
The seven file types in Linux:
D # #目录
-# #普通文件
L # #符号连接 (point to another file, like a shortcut under Windows)
S # #套接字文件 (socket is abstract, is a mechanism for interprocess communication)
B # #块设备文件 (binary file)
C # #字符设备文件
P # #命名管道文件
3. Changes to the file user group
Chown User name File # #更改文件所有人
CHGRP group name File # #更改文件所有组
Chown-r User Directory # #更改目录本身以及目录中的子文件的所有人
CHGRP-R Group name Directory # #更改目录本身以及目录中的子文件的所有组
(-R can be understood as recursive change)
4. Recognition of permissions (rwx three special privileges)
Ls-l in 2-10 characters for file permissions (that is, rwxr-x)
RWX r-x R-x
User rights group member permissions other user rights
Types of permissions
R
R permissions for files, which means you can view the contents of a file
R permissions for the directory, which means that you can view the file names that exist in the directory
W
W permissions against the file, indicating that the contents of the file can be changed
W permissions for the directory, which means that you can delete sub-files or subdirectories in the directory
X
X permission for a file, indicating that the program can be opened in the file
X permission for the directory, indicating that it can be entered in the directory
chmod # #用于修改权限
Eg:chmod ugo+=rwx File # #修改file文件的权限为rwxrwxrwx
U means that user G indicates that group o indicates that other a represents all
r=4 w=2 x=1-=0 (has been set)
u=rwx=7 | g=rwx=7 | O=rwx=7 (4+2+1=7)
rw-r--r--#用数字表示为644, u=rw-=6 g=r--=4 o=r--=4
7=rwx,6=rw-,5=r-x,4=r--,3=-wx,2=-w-,1=--x,0=---
Eg:chmod 755 File # #将file文件权限设置为rwxr-xr-x
CHOMD 444 file-r or Chmod-r 444 hh # #将hh目录下所有文件的权限改为444 (4=r--)
5. Default permissions for Files
Umask # #此命令显示系统预留权限值, create the default permissions for the file.
For files with a maximum setting of 6, the system does not allow a file to be created directly to execute permissions.
Umask nnn (nnn range is 000-777)
The Eg:umask value is 002, and the corresponding file and directory creation default permissions are 644 and 775, respectively.
As you can understand, for directory umask values + directory permissions =777
For file umask value + file permissions =666
Test: [[email protected] desktop]# umask
0022 at this point, the first 0 represents suid, which is typically used to define special permissions, and the latter three are valid permissions.
VIM/ETC/BASHRC 71 is a change for a normal user, and 73 is a super user change
Vim/etc/profile 60 is a change for a normal user, and 62 is a super user change
SOURCE/ETC/BASHRC # #刷新bash配置
Source/etc/profile # #刷新系统配置
Supplemental: The source command is also called a point command to re-execute the initial file that was just modified to take effect immediately.
Source also has a function of being able to execute the contents of a file as a shell.
6. Special Permissions
(1) Sticky bid # # #强制位
O+t # # #只针对目录, when a directory has T permissions, the files in this directory can only be deleted by the owner of the file, others cannot delete
T is 1 (binary corresponds to 001)
chmod o+t Directroy
chmod 1777 Directory
Eg:chmod O+t/mnt/public
(2) Sgid # # #粘制位
G+s # #针对目录, files created in the directory are automatically attributed to the group in which the directory is located.
# #针对二进制文件, the program recorded in the file does not have a relationship with the performer's group identity at execution time, but is executed as the identity of all the groups of the binary file.
(Give a normal user special permission to perform "Only root group permissions")
S is 2 (binary corresponds to 010)
chmod g+s File|directory
chmod 2777 File|directory
(3) SUID # # #冒险位
U+s # # #针对文件, the file record action is executed when the file owner is executed, regardless of who initiated it
(Allows a normal user to have special permissions to perform "Only root privileges")
S is 4 (binary corresponds to 100)
chmod u+s File
chmod 4777 File
This article is from the "12148275" blog, please be sure to keep this source http://12158275.blog.51cto.com/12148275/1897123
Linux Learning notes-file attributes, file permissions, and change commands