Linux文件权限相关的几个问题

来源:岁月联盟 编辑:exp 时间:2012-05-24
Linux文件权限相关的几个问题 感觉linux基础不扎实,所以想通读一遍《鸟哥的Linux私房菜》(不要鄙视我。。。) 读到文件权限一章,chmod,发现一个问题:

 看出来没,chmod +r和chmod +x的效果相当于chmod a+r和chmod a+x,而chmod +w的效果仅相当于chmod u+w,“-”操作类似  www.2cto.com  为毛你“w”搞特殊?man一下吧:A combination of the letters ugoa controls which users' access to the file will be changed: the user who owns it (u), other users in the file's group (g), other users not in the file's group (o), or all users (a). If none of these are given, the effect is as if a were given, but bits that are set in the umask are not affected. 默认是a,但是在umask里设置的位是不受影响的,看下umask是啥:

 果然,group和other的w权限在umask里是有设置的 再测试确认下吧:

 嗯,符合预期,umask是0044,group和other的r权限有设置,这次理所当然换成“r”搞特殊了   www.2cto.com  最后总个结:1. chmod,不显式指定ugoa时,默认值为a,但在umask中设置的位不受影响。2. 遇到不明白的问题,先动脑想(我貌似没有这一步。。。惭愧),想不明白再动手查(最好先不要百度谷歌),实在不明白再百度谷歌,再不行就问大侠们吧。 搜索引擎是很好用,网络上的信息也很全很多,但是主动思考的过程还是不能少的。想都不想上来就百度谷歌的,即便问题解决了,效果也不如通过自己的思考和查原始资料解决来的好。   作者 wallenwang