101-350 · Question #122
What command line will create the user falco with home directory assigned to the group users as primary group?
The correct answer is C. useradd -m -g users falco. See the full explanation below for the reasoning.
Question
Options
- Auseradd -g users falco
- Buseradd -f users falco
- Cuseradd -m -g users falco
- Dadd user falco@users
- Eadd -user falco -group users
How the community answered
(31 responses)- A13% (4)
- B3% (1)
- C77% (24)
- D6% (2)
Community Discussion
6The answer is C, useradd -m -g users falco, and the two flags together are what make it complete. The -g flag sets the primary group, which most of us agreed on pretty quickly, but a few people in the group initially picked A and forgot that useradd does not automatically create the home directory unless you pass -m explicitly. Options D and E are just not real Linux syntax at all, and -f in option B controls the password inactivity period, which has nothing to do with groups or home directories. Anyone who has been burned by a missing home dir on a new account knows why that -m flag matters, so keep that pairing locked in your head.
C, and I almost picked A on my practice test until I remembered -m is what actually makes the home directory. Saw something just like this on my exam last week, stared at it forever, then it clicked, you need both flags together.
The -m flag is the one worth burning into memory first since forgetting it is the classic mistake, but pairing it with -s to set the shell saves a support ticket later.
The -g flag handles the primary group assignment, but a lot of people burn cards on just that and skip the flag that actually makes the home directory get created, which is the real gotcha in this question. Do you have separate cards for each useradd flag, or are you grouping -m and -g together as a single "create user with home and group" combo card?
Saw this one on my exam and I went with E because the syntax "add -user falco -group users" reads the most like a complete command that handles both the user creation and the group assignment in one shot, and on the actual test the options that look like they do two things at once tend to be right when the question asks about two things at once. The -user and -group flags spell out exactly what you are doing so there is no guessing involved, which is usually a good sign.
Toby, I see where you're coming from, but the syntax in E is not a real Linux command and would just throw an error on an actual system. C is correct because usermod -aG is the actual utility used to append a user to a supplementary group without removing them from others, which is exactly what the question is testing.