117-010 · Question #39
Which command displays the list of groups to which a user belongs?
The correct answer is D. id. See the full explanation below for the reasoning.
Question
Which command displays the list of groups to which a user belongs?
Options
- Awhoami
- Blsgroup
- Cwho
- Did
How the community answered
(49 responses)- A16% (8)
- B8% (4)
- C4% (2)
- D71% (35)
Community Discussion
4The answer is D, the id command. Run it and you get your user ID, your primary group ID, and every supplementary group you belong to, all in one shot. That is exactly what the question is testing. whoami just prints your username, nothing else, so A is out immediately. who shows who is logged into the system, not group memberships, so C is wrong. lsgroup does not exist as a standard Unix command, so B is a distractor designed to catch people who are guessing. If you actually understand that id prints uid, gid, and groups, you will never second-guess this on the exam or on the job.
D is right, but do you know why "whoami" alone is not enough here?
The id command is your ID badge, showing user, group, and all group memberships at once.
Panicked on this one, then id clicked for groups, marked D.