查看文件权限
[root@localhost ~]# touch a.txt
[root@localhost ~]# ll a.txt
-rw-r--r-- 1 root root 0 Feb 15 07:52 a.txt
文件基本权限
- rwx r-x r-x user1 user1 FILENAME
类型 拥有者的权限 所属组的权限 其他人的权限 拥有者 属组 对象
对于文件:r读 w写 x执行
对于目录:r读(看到目录里面有什么) ls
w建文件、删除、移动 touch mkdir rm mv cp
x进入 cd
修改权限的相关命令:
chmod
作用:修改文件权限
u-w user 拥有者
g+x group 组
o=r other 其他人
a+x all 所有人
[root@localhost ~]# ll a.txt
-rw-r--r-- 1 root root 0 Feb 15 07:52 a.txt
[root@localhost ~]# chmod u-w a.txt
[root@localhost ~]# ll a.txt
-r--r--r-- 1 root root 0 Feb 15 07:52 a.txt
[root@localhost ~]# chmod g+x a.txt
[root@localhost ~]# ll a.txt
-r--r-xr-- 1 root root 0 Feb 15 07:52 a.txt
[root@localhost ~]# chmod o-r a.txt
[root@localhost ~]# ll a.txt
-r--r-x--- 1 root root 0 Feb 15 07:52 a.txt
[root@localhost ~]# chmod a=r a.txt
[root@localhost ~]# ll a.txt
-r--r--r-- 1 root root 0 Feb 15 07:52 a.txt
修改目录的权限
[root@localhost ~]# mkdir test
[root@localhost ~]# ll -d test/
drwxr-xr-x 2 root root 6 Feb 15 08:07 test/
[root@localhost ~]# chmod u-w test/
[root@localhost ~]# ll -d test/
dr-xr-xr-x 2 root root 6 Feb 15 08:07 test/
一次性修改多个权限:
[root@localhost ~]# chmod u=rwx a.txt
[root@localhost ~]# ll a.txt
-rwxr--r-- 1 root root 0 Feb 15 07:52 a.txt
使用数字表示权限
- rwx r-x r-x user1 user1 FILENAME
类型 拥有者的权限 所属组的权限 其他人的权限 属主 属组
rwx
r-- -w- --x
100 010 001 二进制 进制转换器
4 2 1 十进制
rw- 的值是多少? 4+2 = 6
r-x 4+1 = 5
rw-r--r-- 的值是多少? rw-=6 r--=4 r--=4 rw-r--r--=644
[root@localhost ~]# chmod 622 a.txt
[root@localhost ~]# ll a.txt
-rw--w--w- 1 root root 0 Feb 15 07:52 a.txt
[root@localhost ~]#
chown
作用:修改文件拥有者和所属组
语法:chown USER:GROUP 对象
chown USER 对象
chown :GROUP 对象
[root@localhost ~]# chown rm:bin a.txt
[root@localhost ~]# ll a.txt
-rw--w--w- 1 rm bin 0 Feb 15 07:52 a.txt
[root@localhost ~]# chown daemon a.txt
[root@localhost ~]# ll a.txt
-rw--w--w- 1 daemon bin 0 Feb 15 07:52 a.txt
[root@localhost ~]# chown :sys a.txt
[root@localhost ~]# ll a.txt
-rw--w--w- 1 daemon sys 0 Feb 15 07:52 a.txt
-R递归(目录下的所有内容全部更改,否则只修改目录)
[root@localhost ~]# chown rm test/ -R
[root@localhost ~]# ll -d test/
dr-xr-xr-x 2 rm root 30 Feb 15 08:21 test/
[root@localhost ~]# ll test/
total 0
14.CentOS7文件权限管理
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 在centos7中,/etc/rc.local文件默认没有可执行权限 如果要执行一些命令,需要加入可执行权限 # ...
- 3.ACL访问控制列表 ACL访问控制列表是一种可以实现灵活的权限管理的工具,它相比传统的文件权限来说它可以对文件...
- 1用户权限 1.1文件权限 这一串字符“rwxr-xr-x”代表文件的权限,前三个是属主的权限,中间的三个是属组的...