Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Inherit group ownership from user (not directory)?

avatar
Super Collaborator

It it possible for new files/dirs to inherit group ownership from the user instead of the parent directory?

For reference this is how default group permissions are handled:

"When a file or directory is created, its owner is the user identity of the client process, and its group is the group of the parent directory (the BSD rule).”

http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsPermissionsGuide.h

1 ACCEPTED SOLUTION

avatar

There is currently no way for a newly created directory in HDFS to set its group from the primary group of the creating user automatically. Instead, it always follows the rule quoted in the question: the group is the group of the parent directory.

One way I've handled this in the past is first to create an intermediate directory and then explicitly change its group to the user's primary group, using chmod on the shell or setOwner in the Java APIs. Then, additional files and directories created by the process would use this as the destination directory. For example, a MapReduce job could specify its output directory under this intermediate directory, and then the output files created by that MapReduce job would have the desired group.

View solution in original post

1 REPLY 1

avatar

There is currently no way for a newly created directory in HDFS to set its group from the primary group of the creating user automatically. Instead, it always follows the rule quoted in the question: the group is the group of the parent directory.

One way I've handled this in the past is first to create an intermediate directory and then explicitly change its group to the user's primary group, using chmod on the shell or setOwner in the Java APIs. Then, additional files and directories created by the process would use this as the destination directory. For example, a MapReduce job could specify its output directory under this intermediate directory, and then the output files created by that MapReduce job would have the desired group.