CompTIA Linux+ free question 3 / 10 · Domain 2: Services and User Management
An administrator runs useradd -r svc-backup to create an account for a background service. CREATE_HOME is set to yes in /etc/login.defs on this server. Which statement about the new account matches the useradd(8) manual page?
- Its numeric ID is chosen from the UID_MIN-UID_MAX range, like the ID of an ordinary account
- A home directory is not created for it unless -m is added, even when CREATE_HOME is set to yes
- It gets the normal password aging values, which are written to its line in /etc/shadow
- A home directory is created for it, as CREATE_HOME in /etc/login.defs applies to system accounts too
Show the answer and explanation
Answer: B
Why this is correct
The page describes -r, written --system, as creating a system account. System users get no aging information in /etc/shadow, and their numeric identifiers come from the SYS_UID_MIN-SYS_UID_MAX range in /etc/login.defs. The page also notes that useradd will not create a home directory for such a user, regardless of CREATE_HOME, so -m must be given when one is wanted.
Why the other options are wrong
"A home directory is created for it, as CREATE_HOME in /etc/login.defs applies to system accounts too" … The page says useradd will not create a home directory for a system account, regardless of the default setting in /etc/login.defs (CREATE_HOME). The -m option has to be given for that.
"It gets the normal password aging values, which are written to its line in /etc/shadow" … The page says system users are created with no aging information in /etc/shadow. Aging values for such an account have to be set afterwards with another tool.
"Its numeric ID is chosen from the UID_MIN-UID_MAX range, like the ID of an ordinary account" … The page says that -r selects the SYS_UID_MIN-SYS_UID_MAX range instead of UID_MIN-UID_MAX. The ordinary range is the one used when -r is not given.
Key points
useradd -r changes three defaults: the ID range, the aging information in /etc/shadow, and the home directory. A home directory for a system account needs an explicit -m.
Go to the CompTIA Linux+ practice app (10 free questions; purchase unlocks all questions)