Linux文件权限管理命令

文件权限管理命令

概述

  • 文件权限分为3种:读r、写w、执行x

  • 文件归属分为3类:user、group、other;

  • 为了便于权限管理,每个权限都有对应的数字:

0表示没有权限、4表示读权限、2表示写权限、1表示执行权限

image-20240311005202475

方式1:数字表示法

  • chmod 777 -R 文件|文件夹 其中-R用于递归修改文件夹及其下所有子文件。
[root@node1 test]# ll
total 4
-rw-r--r-- 1 root root 2 Aug 16 18:32 1.txt
[root@node1 test]# chmod 777 1.txt 
[root@node1 test]# ll
total 4
-rwxrwxrwx 1 root root 2 Aug 16 18:32 1.txt
  • chmod 777 1.txt 代表所有用户都满权限

方式2:字母+-法

  • user->u group->g others->o all->a

  • +增加权限

  • -减少权限

[root@node1 test]# ll
total 4
-rwxrwxrwx 1 root root 2 Aug 16 18:32 1.txt
[root@node1 test]# chmod a-x 1.txt 
[root@node1 test]# ll
total 4
-rw-rw-rw- 1 root root 2 Aug 16 18:32 1.txt
[root@node1 test]# chmod u+x 1.txt 
[root@node1 test]# ll
total 4
-rwxrw-rw- 1 root root 2 Aug 16 18:32 1.txt
  • chmod a-x 1.txt 表示所有用户都添加执行权限

方法3:等号赋值法

  • chmod u=rwx,g=rw 文件|文件夹
[root@node1 test]# ll
total 4
-rwxr-xrw- 1 root root 2 Aug 16 18:32 1.txt
[root@node1 test]# chmod u=r,g=---,o=--- 1.txt     
[root@node1 test]# ll
total 4
-r-------- 1 root root 2 Aug 16 18:32 1.txt
posted @   七落安歌  阅读(148)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示