Linux下一个目录让任何人创建的文件和目录任何人都能读写
1. 使用 umask 和 setgid 位
chmod g+s /path/to/directoryumask 0002chown :target_group /path/to/directory2. 使用 ACL(访问控制列表)
示例
最后更新于
chmod g+s /path/to/directoryumask 0002chown :target_group /path/to/directory最后更新于
setfacl -d -m u::rwx,g::rwx,o::rx /path/to/directory
setfacl -d -m g:target_group:rwx /path/to/directorysetfacl -R -m u::rwx,g::rwx,o::rx /path/to/directory
setfacl -R -m g:target_group:rwx /path/to/directory# 创建组
sudo groupadd sharedgroup
# 更改目录的组
sudo chown :sharedgroup /shared
# 设置目录的 setgid 位
sudo chmod g+s /shared
# 设置 ACL
sudo setfacl -d -m u::rwx,g::rwx,o::rx /shared
sudo setfacl -d -m g:sharedgroup:rwx /shared
# 确保现有文件和目录具有正确的权限
sudo setfacl -R -m u::rwx,g::rwx,o::rx /shared
sudo setfacl -R -m g:sharedgroup:rwx /shared