首页 > 系统服务 > 详细

设置 Linux 文件和目录权限的方法

时间:2015-07-11 12:13:19      阅读:245      评论:0      收藏:0      [点我收藏+]

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 参数意为递归

技术分享

版权声明:本文为博主原创文章,未经博主允许不得转载。

设置 Linux 文件和目录权限的方法

原文:http://blog.csdn.net/qq_20480611/article/details/46839803

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!