linux 目录权限及归属,Linux文件/目录的权限及归属管理使用

一、文件的权限和归属概述

1、访问权限

读取r:允许查看文件内容、显示目录列表;

写入w:允许修改文件内容,允许在目录中新建、移动、删除文件或子目录;

可执行x:允许运行程序、切换目录

2、归属(所有权)

属主:拥有该文件或目录的用户账号;

属组:拥有该文件或目录的组账号;

3、查看文件的权限和归属

202002011357211.jpg

4、chmod设置文件权限

chmod命令的基本语法格式如下:

202002011357212.jpg

应用举例:

[root@centos01 ~]# touch 1.txt

[root@centos01 ~]# ll

总用量 8

-rw-r--r-- 1 root root 0 1月 11 22:27 1.txt

-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg

-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

[root@centos01 ~]# chmod u+x ./1.txt

[root@centos01 ~]# ll

总用量 8

-rwxr--r-- 1 root root 0 1月 11 22:27 1.txt

-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg

-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

[root@centos01 ~]# chmod u-x,g+x,o+w 1.txt

[root@centos01 ~]# ll

总用量 8

-rw-r-xrw- 1 root root 0 1月 11 22:27 1.txt

-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg

-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

[root@centos01 ~]# chmod 755 1.txt

[root@centos01 ~]# ll

总用量 8

-rwxr-xr-x 1 root root 0 1月 17 02:36 1.txt

-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg

-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

5、chown设置文件的归属

chown命令的基本语法格式如下:

202002011357213.jpg

应用举例:

[root@centos01 ~]# chown bob 1.txt

[root@centos01 ~]# ll

总用量 8

-rwxr-xr-x 1 bob root 0 1月 17 02:36 1.txt

-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg

-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

[root@centos01 ~]# chown :benet 1.txt

[root@centos01 ~]# ll

总用量 8

-rwxr-xr-x 1 bob benet 0 1月 17 02:36 1.txt

-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg

-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

[root@centos01 ~]# chown bob:benet 1.txt

[root@centos01 ~]# ll

总用量 8

-rwxr-xr-x 1 bob benet 0 1月 17 02:36 1.txt

-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg

-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

二、目录的权限和归属

1、访问权限

202002011357224.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值