日期:2014-05-16  浏览次数:20658 次

linux下的文件授权

//文件权限的设置 中间没有空格
格式:chmod [who]operator[permission] file
who:
?u 文件属主权限
?g 同组用户权限
?o 其他用户权限
?a 所有用户
operator
?+ 增加权限
?- 取消权限
?= 设置权限
permission //字母表示法
?r 读
?w 写
?x 执行
?l 加锁
permission //数字表示法
r-4 2-w x-1
权限位置上 每一个最大的值为7 最小0(没有任何权限)

例子:
chmod u+x myfile // 给所属用户添加执行权限
chmod u-x myfile // 取消所属用户的执行权限
chmod u-x-w-r myfile // 取消所属用户的x w? r权限 -xwr
chmod u+xwr myfile //给所属用户添加x w r权限 +x+w+r
chmod 777 myfile? //设置所有权限
chmod 770 myfile? //设置所有权限
chmod 730 myfile? //7 给所属用户设置所有权限 3 给同组用户+wx 给其他用户不设置权限
chmod 7777 myfile //其他用户也可对此文件进行操作 chmod u+s myfile

?

如果当前用户不为系统管理员,或者给chmod命令前面增加sudo命令