权限位 | 数值 | 含义 |
r | 4 | 可读 |
w | 2 | 可写 |
x | 1 | 可执行 |
[root@web ~]# ll /etc/hosts
-rw-r--r-- 1 root root 261 Jun 16 15:18 /etc/hosts复制
如何修改文件或者目录对应的权限呢?
chmod [OPTION] filename 复制
[root@web tes]# ll
total 0
-rw-r--r-- 1 root root 0 Jun 24 14:25 1.txt
# 方式一:使用数值的方式,每一组都对应总数是7,r是4
[root@web tes]# chmod 744 1.txt
[root@web tes]# ll
total 0
-rwxr--r-- 1 root root 0 Jun 24 14:25 1.txt
[root@web tes]# ll 1.txt
-rw-r--r-- 1 root root 0 Jun 24 14:25 1.txt
方式一:使用数值的方式,每一组是3个加起来是7,如果是可读就是4,如果是可写就是2,如果可读可写就是6,三个数值,分别对应着所属的用户、用户组、其他用户
方式二:使用+的方式
[root@web tes]# chmod u+x 1.txt
[root@web tes]# ll
total 0
-rwxr--r-- 1 root root 0 Jun 24 14:25 1.txt
文件目录权限的不同
对于文件来说
我们可以看出,w和x权限想要运用自如都需要r权限的配合
对于目录来说
隐藏的权限位
[root@web ~]# lsattr 1.sh
-------------e-- 1.sh
默认的e属性表示文件正在使用区段来映射块
[root@web ~]# chattr +i 1.sh
[root@web ~]# lsattr 1.sh
----i--------e-- 1.sh
文章转载自小董的成长笔记,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。