Study for the TestOut Linux Pro Exam with our engaging quiz. Prepare using our flashcards and comprehensive multiple choice questions, each with hints and explanations to help you succeed. Get ready for your Linux certification today!

Practice this question and more.


Which command adds a user to a secondary group?

  1. usermod -G groupname username

  2. adduser username groupname

  3. usermod --append -G groupname username

  4. addgroup username groupname

The correct answer is: usermod -G groupname username

The command that facilitates adding a user to a secondary group is indeed usermod -G groupname username. This command modifies the user's group memberships by assigning them to specified secondary groups. When using the -G flag, it is important to note that if this command is used without the --append option, it will replace all existing secondary group memberships with the ones specified, unless all desired groups are listed. The context of the command also helps clarify its use: secondary groups are those that a user can belong to in addition to their primary group, facilitating various permissions and access controls on resources associated with these groups. For example, if a user needs access to specific files owned by a group, adding them to that group ensures they receive the appropriate permissions. Other commands listed do not accomplish precisely what is asked. While some may manipulate user and group associations, they do not specifically add a user to a secondary group in the manner described by the question, making it clear why the correct command is the one identified.