Linux 目录和文件的默认访问权限——umask

今天安装 SCons,编译项目时总是报错:

...
Traceback (most recent call last):
  File "/usr/bin/scons", line 190, in <module>
    import SCons.Script
ImportError: No module named SCons.Script


查明原因,是因为 scons lib 目录和文件普通用户无访问权限:

# ls -ld /usr/lib/scons*
...
drwx------ 3 root root 4096  2月 18 2014 /usr/lib/scons-2.3.0
drwx------ 3 root root 4096 10月 29 21:14 /usr/lib/scons-2.3.4

# ll /usr/lib/scons-2.3.4/
总用量 8
drwx------ 10 root root 4096 10月 29 19:58 SCons
-rw-------  1 root root  442 10月 29 21:14 scons-2.3.4-py2.6.egg-info

# ll /usr/lib/scons-2.3.4/SCons/
总用量 1064
-rw------- 1 root root 47844  9月 28 00:51 Action.py
-rw------- 1 root root 39718 10月 29 19:58 Action.pyc
-rw------- 1 root root 33996  9月 28 00:51 Builder.py
-rw------- 1 root root 30022 10月 29 19:58 Builder.pyc
-rw------- 1 root root  8083  9月 28 00:51 CacheDir.py
-rw------- 1 root root  6892 10月 29 19:58 CacheDir.pyc
drwx------ 2 root root  4096 10月 29 19:58 compat
...

为什么会这样呢?罪魁祸首是 umask

查看 root 的 umask:

# umask
0077
所以目录权限默认是 700,那么如何改变呢?

可以修改 /etc/bashrc 或者 /etc/profile, 笔者使用的 Linux 环境(公司内部订制的版本)/etc/bashrc 设置的是 077,而 /etc/profile 设置的是 022,最后取的是 077,如何修改,请根据自己的发行版 shell 环境配置文件的规则去尝试修改。





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值