chmod使用范例

chmod使用范例

时间:2009-05-13 11:00 来源:互联网
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 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的权限
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值