linux下如何共享文件夹共享

本文探讨了Linux环境下多人共同开发项目的权限管理问题,并介绍了两种有效解决方案:利用SETGIDBITS进行目录权限设置及通过setfacl实现更精细的文件访问控制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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:<span style="font-family: Arial, Helvetica, sans-serif;">group_name</span><span style="font-family: Arial, Helvetica, sans-serif;">:rwx dir/</span>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值