Lpic 1 Linux Administrator · Free Practice Question Medium

Question 27

Which command is used to add an existing user to a group named devs?

  • A

    usermod -G devs user

  • B

    usermod -a -G devs user

  • C

    gpasswd -a user devs

  • D

    adduser user devs

Reveal correct answer

Correct answer: B

A. The command "usermod -G devs user" is used to replace the user's existing groups with the specified group "devs". It does not add the user to the group, so it is not the correct command for adding an existing user to a group named "devs".

B. The command "usermod -a -G devs user" is the correct command to add an existing user to a group named "devs". The "-a" flag ensures that the user is added to the specified group without removing them from any existing groups.

C. The command "gpasswd -a user devs" is used to add a user to a group using the "gpasswd" utility. However, the standard way to add a user to a group in Linux is through the "usermod" command, so this is not the correct command for adding an existing user to a group named "devs".

D. The command "adduser user devs" is used to create a new user with the specified group "devs". It is not the correct command for adding an existing user to a group named "devs".

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need