How to Make Files Inherit Parent Folder's Group in Linux?

A developer wants to ensure that all files and folders created inside a shared folder named /Group00DEV inherit the group name of the parent folder. Which of the following commands will help achieve this goal?

  1. chmod g+x /Group00DEV/
  2. chmod g+w /Group00DEV/
  3. chmod g+r /Group00DEV/
  4. chmod g+s /Group00DEV/ Source Reference Answer

Community Votes

D
83%
C
17%

83% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

This question tests your understanding of special permission bits, particularly the setgid bit, and the common trap is confusing it with ordinary read/write permissions like chmod g+w.

The setgid bit on a directory causes all new files and subdirectories to inherit the parent folder's group ownership. The correct command is chmod g+s /Group00DEV/, as confirmed by the community (83% chose D).

The most common wrong answer is C (chmod g+r) or B (chmod g+w), which only modify read/write permissions and do not enforce group inheritance. The setgid bit is the special mechanism required for this behavior.

Community Discussion (3 comments)

Qubert2 👍 4 Selected: D
Set the setgid Bit: To ensure that new files and directories inherit the group of the parent folder, set the setgid bit on the directory using the chmod command: sudo chmod g+s /Group00DEV The g+s option sets the setgid bit. When this bit is set on a directory, any files or subdirectories created within it will inherit the group of the directory rather than the group of the user who created the file.
Kashim 👍 1 Selected: D
To ensure that all files and folders created inside the /Group00DEV shared folder inherit the group name of the parent folder, the correct command is: D. chmod g+s /Group00DEV/ Explanation: Set Group ID (SGID) bit (g+s): When the SGID bit is set on a directory, any files or subdirectories created within that directory will inherit the group ownership of the directory rather than the primary group of the user who created the files or subdirectories. This is particularly useful in shared directories where you want all files and directories to remain accessible to a specific group.
IFBBPROSALCEDO 👍 1 Selected: C
C. docker run -it -p 8080:80 --name Web001 nginx Explanation: docker run is used to create and start a new container from an image. -it stands for interactive terminal, which keeps the container running and allows interaction. -p 8080:80 maps port 8080 on the host to port 80 inside the container. --name Web001 assigns the name Web001 to the container. nginx specifies the image to use for the container.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

The setgid bit (chmod g+s) on a directory ensures that any files or subdirectories created inside it inherit the group of the parent directory, not the primary group of the user who creates them. This is exactly what the developer needs for a shared folder.

As community comment [1] explains, setting the setgid bit with sudo chmod g+s /Group00DEV makes the directory's group ownership apply to new entries. Comment [2] reiterates that the SGID bit is the correct solution for group inheritance.

The symbolic mode g+s adds the setgid permission for the group, which is the standard Linux way to achieve this behavior.

Why the Other Options Are Wrong

Option A (chmod g+x) adds execute permission for the group. This allows group members to traverse or access the directory but does not affect group ownership of new files.

Option B (chmod g+w) adds write permission for the group. This allows group members to create files but does not set inheritance of the group name.

Option C (chmod g+r) adds read permission for the group. This allows group members to list the directory but has no bearing on group inheritance.

Only option D sets the special SGID bit, which is the mechanism specifically designed for group inheritance on directories.

Community Comment Notes

The top-voted comment (4 likes) directly identifies the correct command and explains the effect clearly: "To ensure that new files and directories inherit the group of the parent folder, set the setgid bit on the directory using the chmod command: sudo chmod g+s /Group00DEV." This comment aligns with the correct answer D.

Comment [2] adds further detail about the SGID bit. However, comment [3] appears to reference an unrelated Docker question, likely a mispost, and should be disregarded. The consensus is overwhelmingly D with 83 votes.

Official Reference

Exam Strategy

Memorize the three special permission bits: setuid (u+s), setgid (g+s), and sticky bit (o+t). For any question asking about inheriting group ownership on a shared directory, immediately think of the setgid bit and use chmod g+s <directory>.

Related Analysis

← Back to XK0-005 Study Guide