010-100 · Question #39
Which command displays the list of groups to which a user belongs?
The correct answer is D. id. The id command displays a user's UID, primary GID, and all supplementary group memberships in a single output.
Question
Which command displays the list of groups to which a user belongs?
Options
- Awhoami
- Blsgroup
- Cwho
- Did
How the community answered
(41 responses)- A7% (3)
- B15% (6)
- C2% (1)
- D76% (31)
Why each option
The `id` command displays a user's UID, primary GID, and all supplementary group memberships in a single output.
`whoami` only prints the effective username of the current user and provides no information about group membership.
`lsgroup` is not a standard Linux command and does not exist as a built-in utility.
`who` shows which users are currently logged into the system and their login sessions, not group membership details.
The `id` command prints the real and effective user ID (UID), primary group ID (GID), and the full list of all supplementary groups the user belongs to. Running `id username` for a specific user or `id` alone for the current user provides complete group membership information. This makes it the definitive command for answering questions about group membership on Linux systems.
Concept tested: Linux user and group identity lookup with id
Source: https://man7.org/linux/man-pages/man1/id.1.html
Topics
Community Discussion
No community discussion yet for this question.