CompTIA

XK0-006 practice question 15

CompTIA Linux+ · free question 15 of 20

Question

A Linux administrator wants to add a user to the Docker group without changing their primary group. Which of the following commands should the administrator use to complete this task?
  • A. sudo groupmod docker user
  • B. sudo usermod -g docker user
  • C. sudo usermod -aG docker user Correct
  • D. sudo groupmod -G docker user

Explanation

usermod -aG docker user adds docker to the user's supplementary groups and keeps the groups the user already has, because -a appends to the list given with -G. usermod -g would change the user's primary group, which is what the administrator wants to avoid. groupmod changes the properties of a group, not a user's memberships, and it has no -G option for this.

Practice the whole free set

Answer all 20 free XK0-006 questions with instant feedback, or unlock all 154 questions with Learn and Exam modes.