0

I would like to ensure that in only one particular directory on linux server will have newly-created directory setup particular group?

I.e.: I have directory /data with ownership "user1:global_group" and every new subdirectory should have group ownership the same. Once I create directory by using mkdir /data/subdir1 under user1 or user2 the ownership is "user1:grp_user1" or "user2:grp_user2".

How can I manage the subdirectory ownership?

Many thanks for any ideas ...

charkh
  • 169
  • 1
  • 3
  • 13

2 Answers2

1

You need chmod for that.

Apply this: chmod g+s directory on a parent directory. Every newly created file and directory, recursively, will have the group of the parent directory.

So:

chgrp target_group target_directory
chmod g+s target_directory
mkdir -p target_directory/subdirectory/another_one
ls -l target_directory/subdirectory/another_one 

And observe, how another_one directory has the desired group.

Piotr Zierhoffer
  • 5,005
  • 1
  • 38
  • 59
0

Use -R or --recursive option. And try chgrp --help first.

CiaPan
  • 9,381
  • 2
  • 21
  • 35