linux下的权限设定2

#####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目录将无法更改文件

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值