免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1365 | 回复: 0
打印 上一主题 下一主题

chmod使用范例 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-12-18 11:13 |只看该作者 |倒序浏览
chmod 750 a.out
改变 a.out的权限为750;
chmod a+x a.out
对所有用户增加 a.out的执行权限,a(All)表示所有用户;
chmod u=rwx a.out
设置属主的权限为读、写和执行, u(user)表示属主用户;
chmod g+rw a.out
增加同组用户的读写权限, g(group)表示同组用户;
chmod o-w a.out
减少其他用户的写权限, o(others)表示其他用户;
chmod go= a.out
清除同组和其他用户的所有权限;
chmod o=u-w a.out

范例 :将档案 file1.txt 设为所有人皆可读取 :
chmod ugo+r file1.txt
将档案 file1.txt 设为所有人皆可读取 :
chmod a+r file1.txt
将档案 file1.txt 与 file2.txt 设为该档案拥有者,与其所属同一个群体者可写入,但其他以外的人则不可写入 :
chmod ug+w,o-w file1.txt file2.txt
将 ex1.py 设定为只有该档案拥有者可以执行 :
chmod u+x ex1.py
将目前目录下的所有档案与子目录皆设为任何人可读取 :
chmod -R a+r *
此外chmod也可以用数字来表示权限如 chmod 777 file
语法为:chmod abc file
其中a,b,c各为一个数字,分别表示User、Group、及Other的权限。
r=4,w=2,x=1
若要rwx属性则4+2+1=7;
若要rw-属性则4+2=6;
若要r-x属性则4+1=7。
范例:
chmod a=rwx file

chmod 777 file
效果相同
chmod ug=rwx,o=x file

chmod 771 file
效果相同
若用chmod 4755 filename可使此程序具有root的权限


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/52955/showart_444826.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP