Bird
0
0

Why does the groups command show different groups than id -Gn for the same user?

hard📝 Conceptual Q10 of 15
Linux CLI - Users and Groups
Why does the groups command show different groups than id -Gn for the same user?
Agroups shows only supplementary groups, id -Gn shows all groups
Bgroups shows primary group only, id -Gn shows supplementary groups
Cgroups requires root privileges to show all groups, id -Gn does not
Dgroups shows groups from /etc/group, id -Gn includes LDAP or other sources
Step-by-Step Solution
Solution:
  1. Step 1: Understand groups command source

    groups reads groups from local /etc/group file.
  2. Step 2: Understand id -Gn command source

    id -Gn shows all groups including those from network sources like LDAP.
  3. Final Answer:

    groups shows groups from /etc/group, id -Gn includes LDAP or other sources -> Option D
  4. Quick Check:

    groups vs id -Gn differ by data source [OK]
Quick Trick: groups reads /etc/group; id -Gn includes network groups [OK]
Common Mistakes:
MISTAKES
  • Thinking groups shows only supplementary groups
  • Assuming groups requires root privileges
  • Confusing primary and supplementary group outputs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes