CompTIA Linux+ (XK0-006)Services and User ManagementEasy

A system administrator needs to create a new user account named `appuser` with a specific UID of `2000`, a primary GID of `2000`, a home directory at `/srv/appuser`, and a default shell of `/bin/bash`. Which command correctly accomplishes this?

  1. Auseradd --uid 2000 --gid 2000 --home /srv/appuser --shell /bin/bash appuser
  2. Buseradd -u 2000 -g 2000 -d /srv/appuser -s /bin/bash appuser
  3. Cmkuser -u 2000 -g 2000 -h /srv/appuser -s /bin/bash appuser
  4. Dadduser -u 2000 -g 2000 -h /srv/appuser -s /bin/bash appuser
Show answer & explanation

Correct answer: B. useradd -u 2000 -g 2000 -d /srv/appuser -s /bin/bash appuser

The `useradd` command is the standard Linux utility for creating new user accounts. The options `-u` for UID, `-g` for primary GID, `-d` for home directory, and `-s` for shell are the correct short-form flags for these parameters.

Why the other options are wrong

  • A. While `useradd` is correct, the long-form options `--uid`, `--gid`, `--home`, and `--shell` are also valid but the short-form is more common in practice and often expected.
  • C. `mkuser` is not a standard Linux command for creating users; `useradd` or `adduser` are used.
  • D. `adduser` is often a wrapper script for `useradd` but its options can vary by distribution. `-h` is not a standard `useradd` option for home directory.

useradd command

The `useradd` command is used to create a new user account on a Linux system, allowing specification of UID, GID, home directory, and shell.

  • Creates new user accounts.
  • Requires root privileges.
  • Options: `-u` (UID), `-g` (primary GID), `-d` (home directory), `-s` (shell).

Memory trick: USERADDs all the details for a new user.

More Services and User Management questions