CompTIA Linux+ Certification Practice Exam

Image Description

Question: 1 / 1520

What command would you use to add a user to a group in Linux?

usermod -g

usermod -aG

The command to add a user to a group in Linux is indeed "usermod -aG". This command utilizes the usermod utility, which is specifically designed for modifying user accounts. The options provided here have specific meanings:

- The "-a" option stands for "append," and is crucial when adding a user to an additional group without removing them from any groups they are already a part of. Without this option, the user would be removed from all other groups to which they belong, which is typically not the desired outcome.

- The "G" option specifies the group or groups that the user is being added to. You can list multiple groups by separating them with commas, for instance, "usermod -aG group1,group2 username".

In contrast, the other commands listed do not serve the purpose of adding a user to a group in the way that is intended. The "-g" option is used to set a user's primary group, which would change the user's main group rather than simply adding them to another. The "-r" option is meant for modifying system accounts and is not applicable for adding users to groups. The "-d" option is used for changing a user's home directory, which does not relate to group

Get further explanation with Examzify DeepDiveBeta

usermod -r

usermod -d

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy