CompTIA Linux+ (XK0-006)Services and User ManagementHard

A system administrator needs to implement a policy where all new files created by any user in the `/shared/data` directory automatically inherit the group ownership of the directory itself, rather than the user's primary group. Which command achieves this?

  1. Achmod g+s /shared/data
  2. Bsetfacl -m d:g:sharedgroup:rwx /shared/data
  3. Cchown root:sharedgroup /shared/data
  4. Dchmod +t /shared/data
Show answer & explanation

Correct answer: A. chmod g+s /shared/data

Setting the Set Group ID (SGID) bit on a directory (`chmod g+s`) causes new files and subdirectories created within it to inherit the group ownership of the parent directory, rather than the primary group of the user who created them. This is exactly what the scenario describes.

Why the other options are wrong

  • B. This `setfacl` command sets a default ACL for the group `sharedgroup` with rwx permissions, but it doesn't enforce group inheritance for new files in the same way SGID does for the directory's primary group.
  • C. This command changes the owner and group of the directory itself, but doesn't ensure that *new* files inherit the directory's group.
  • D. The `+t` (Sticky bit) on a directory prevents users from deleting or renaming files they don't own within that directory, even if they have write permissions.

SGID on Directories

When the Set Group ID (SGID) bit is set on a directory, any new files or subdirectories created within that directory will inherit the group ownership of the parent directory.

  • Applied to directories only.
  • Ensures group inheritance for new files/subdirectories.
  • Set using `chmod g+s` or `chmod 2770` (example).

Memory trick: SGID on a Directory guarantees Group Inheritance.

More Services and User Management questions