#####3.文件权限的理解###########
[root@workstation Desktop]# ls -ld /etc
drwxr-xr-x. 139 root root 8192 1月 1 15:54 /etc
U:文件拥有者对文件的权限
G:文件拥有组对文件的权限
O:其他人对于文件的权限
r: readable(查看权限) 1.对于文件可查看文件中的内容 2.对于目录可列出目录中的文件名称
w:writeable(可写权限) 1.对于文件可更改文件记录的内容 2.对于目录可更改目录中文件元数据
x:excutable(执行权权限) 1.对于文件可用文件名称调用文件内记录的程序 2.对于目录可进入目录
权限对文件的影响:
[root@workstation Desktop]# su - lee ##进入lee用户
[lee@workstation ~]$ cd /mnt ##进入/mnt目录并查看目录
[lee@workstation mnt]$ ls
westos1 westos2 westos3 westosdir
[lee@workstation mnt]$ cat /mnt/westos1 ##有r是可显示文件内容
qqww
[root@workstation Desktop]# chmod u-r /mnt/westos1 ##新开一个shell去掉u下的r
[lee@workstation mnt]$ cat westos1 ##无法读取文件内容
cat: westos1: Permission denied
[root@workstation Desktop]# chmod u+r /mnt/westos1 ##加入u下r可在读取文件内容
[lee@workstation mnt]$ cat /mnt/westos1
qqww
[root@workstation Desktop]# chmod u-w /mnt/westos1 ##去掉u下的w文件将不可写入
[lee@workstation mnt]$ echo hello westos > /mnt/westos1 ##echo显示
-bash: /mnt/westos1: Permission denied
[root@workstation Desktop]# chmod u+w /mnt/westos1 ##加入u下的w文件可再次写入
[lee@workstation mnt]$ echo hello westos > /mnt/westos1
[lee@workstation mnt]$ cat westos1
hello westos
[lee@workstation mnt]$ vim westos1 ##编辑westos1 date
[root@workstation Desktop]# chmod u+x /mnt/westos1 ##加入调用指令
[lee@workstation mnt]$ /mnt/westos1 ##文件可被调用
2020年 01月 06日 星期一 13:59:31 EST
权限对目录的影响:
[lee@workstation mnt]$ cd /mnt/westosdir/ ##进入/mnt下的/westosdir目录
[lee@workstation westosdir]$ pwd
/mnt/westosdir
[lee@workstation westosdir]$ cd /mnt ##再次进入mnt目录
[root@workstation Desktop]# chmod u-x /mnt/westosdir/ ##去掉调用命令westosdir目录将无法调用
[lee@workstation mnt]$ cd /mnt/westosdir/
-bash: cd: /mnt/westosdir/: Permission denied
[root@workstation Desktop]# chmod u-w /mnt/westosdir/ ##去掉w westosdir目录将无法更改文件