linux下开发中会遇到一个常见的问题就是权限问题。
多个开发人员共同开发一个项目,如何管理唯一的一个运行环境的权限?
有两个可行的方案:
1、使用SETGID BITS
使用SETGID BITS可以在创建目录时将新建目录的组默认继承上级目录。
man chmod中的说明:
SETUID AND SETGID BITS
chmod clears the set-group-ID bit of a regular file if the file’s group ID does not match the user’s effective group ID or one of the user’s supplementary
group IDs, unless the user has appropriate privileges. Additional restrictions may cause the set-user-ID and set-group-ID bits of MODE or RFILE to be ignored.
This behavior depends on the policy and functionality of the underlying chmod system call. When in doubt, check the underlying system behavior.
用法:
chgrp group_name dir/chmod g+s dir/
2、使用文件访问控制列表 setfacl
setfacl -m d:g:group_name:rwx dir/