设置 Linux 文件和文件夹权限的方法

it2025-06-05  74

1、字符表示法

类型 操作 权限

u + r

g - w

o = x

a

类型代表改动权限的对象,u表示文件的用户。g表示文件全部者的群组,o表示非用户组用户。a表示ugo

操作 + 表示添加权限,- 表示降低权限,= 表示赋予权限

权限 r 表示仅仅读,w 表示可写,x 表示可运行

[root@localhost ~] #  mkdir perm

[root@localhost ~] #  cd perm

[root@localhost perm] #  mkdir test

[root@localhost perm] #  cd test

[root@localhost test] #  touch test1

[root@localhost test] #  touch test2

下面是測试命令,详细见下图

chmod u-w test

chmod g+w test

chmod ug+w test

chmod ugo-x test

chmod a+x test

chmod o=w test

chmod a= perm

chmod -R a+rwx perm

2、数字表示法

权限 数字

r 4

w 2

x 1

- 0

比如rwx数字表示即4+2+1=7,实际上这是二进制表示,rwx三位bit,111,即7

样例:

chmod 577 test

chmod 555 test

chmod -R 754 test //-R 參数意为递归

转载于:https://www.cnblogs.com/bhlsheji/p/5350303.html

最新回复(0)