010-100 · Question #6
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. The useradd command requires -m to create the home directory and -g to set the primary group, making option C the only syntactically correct command.
Question
What command line will create the user falco with home directory assigned to the group users as primary group?
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
(26 responses)- A15% (4)
- B4% (1)
- C73% (19)
- D8% (2)
Why each option
The useradd command requires -m to create the home directory and -g to set the primary group, making option C the only syntactically correct command.
Option A uses -g to set the primary group correctly but omits -m, so no home directory is created for the user.
The -f flag in useradd sets the number of days after a password expires before the account is disabled, not the primary group.
The -m flag instructs useradd to create the user's home directory if it does not exist, and the -g flag sets the primary group by name or GID. Together, 'useradd -m -g users falco' satisfies both requirements stated in the question.
'add user' is not a valid Linux command; the correct utility is useradd (or adduser on some distributions with different syntax).
'add -user' is not a valid command or option syntax on any standard Linux distribution.
Concept tested: useradd flags for home directory and primary group
Source: https://man7.org/linux/man-pages/man8/useradd.8.html
Topics
Community Discussion
No community discussion yet for this question.