A Linux administrator needs to add a new user account 'jdoe' with UID 1500, primary group 'developers', home directory /home/jdoe, and login shell /bin/bash. Which command will accomplish this?
Trap 1: adduser -u 1500 -g developers -d /home/jdoe -s /bin/bash jdoe
adduser is a higher-level, interactive front-end for useradd and does not accept the same option flags in the same way on all distributions. On many Linux systems, adduser is a Perl script with different syntax, so this command may not work as intended.
Trap 2: usermod -u 1500 -g developers -d /home/jdoe -s /bin/bash jdoe
usermod modifies an existing user account, but 'jdoe' does not exist yet. Using usermod on a non-existent user will produce an error. The correct tool to create a new user with these attributes is useradd, not usermod.
Trap 3: passwd -u 1500 -g developers -d /home/jdoe -s /bin/bash jdoe
passwd is used to change user passwords and some password aging parameters, not to create accounts or set UID, group, home directory, or shell. The options -u, -g, -d, and -s have different meanings in passwd and would not achieve the desired result.
- A
adduser -u 1500 -g developers -d /home/jdoe -s /bin/bash jdoe
Why it fails: adduser is a higher-level, interactive front-end for useradd and does not accept the same option flags in the same way on all distributions. On many Linux systems, adduser is a Perl script with different syntax, so this command may not work as intended.
- B
usermod -u 1500 -g developers -d /home/jdoe -s /bin/bash jdoe
Why it fails: usermod modifies an existing user account, but 'jdoe' does not exist yet. Using usermod on a non-existent user will produce an error. The correct tool to create a new user with these attributes is useradd, not usermod.
- C
useradd -u 1500 -g developers -d /home/jdoe -s /bin/bash jdoe
The useradd command with -u sets the UID, -g sets the primary group, -d sets the home directory, and -s sets the login shell. This matches all requirements precisely and is the standard tool for creating local user accounts on Linux.
- D
passwd -u 1500 -g developers -d /home/jdoe -s /bin/bash jdoe
Why it fails: passwd is used to change user passwords and some password aging parameters, not to create accounts or set UID, group, home directory, or shell. The options -u, -g, -d, and -s have different meanings in passwd and would not achieve the desired result.