如何在 Linux 的子目录中自动设置组
How to automatically setup group in subdirectory in Linux
我想确保在 linux 服务器上只有一个特定目录将有新创建的目录设置特定组?
即:
我的目录 /data
的所有权为 "user1:global_group",每个新的子目录都应具有相同的组所有权。在 user1 或 user2 下使用 mkdir /data/subdir1
创建目录后,所有权为 "user1:grp_user1" 或 "user2:grp_user2"。
如何管理子目录所有权?
非常感谢任何想法...
使用-R
或--recursive
选项。并先尝试 chgrp --help
。
为此你需要 chmod
。
在父目录上应用:chmod g+s directory
。每个新创建的文件和目录,递归地,都会有父目录的组。
所以:
chgrp target_group target_directory
chmod g+s target_directory
mkdir -p target_directory/subdirectory/another_one
ls -l target_directory/subdirectory/another_one
并观察 another_one
目录如何拥有所需的组。
我想确保在 linux 服务器上只有一个特定目录将有新创建的目录设置特定组?
即:
我的目录 /data
的所有权为 "user1:global_group",每个新的子目录都应具有相同的组所有权。在 user1 或 user2 下使用 mkdir /data/subdir1
创建目录后,所有权为 "user1:grp_user1" 或 "user2:grp_user2"。
如何管理子目录所有权?
非常感谢任何想法...
使用-R
或--recursive
选项。并先尝试 chgrp --help
。
为此你需要 chmod
。
在父目录上应用:chmod g+s directory
。每个新创建的文件和目录,递归地,都会有父目录的组。
所以:
chgrp target_group target_directory
chmod g+s target_directory
mkdir -p target_directory/subdirectory/another_one
ls -l target_directory/subdirectory/another_one
并观察 another_one
目录如何拥有所需的组。