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

来源:互联网 发布:中国电信cn2网络 编辑:程序博客网 时间:2024/05/01 09:24

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

...Traceback (most recent call last):  File "/usr/bin/scons", line 190, in <module>    import SCons.ScriptImportError: 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.0drwx------ 3 root root 4096 10月 29 21:14 /usr/lib/scons-2.3.4# ll /usr/lib/scons-2.3.4/总用量 8drwx------ 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.pycdrwx------ 2 root root  4096 10月 29 19:58 compat...

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

查看 root 的 umask:

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

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





0 0