What do you use to add a user to a specific group in Linux?

Disable ads (and more) with a premium pass for a one time $4.99 payment

Boost your Linux skills with the CompTIA Linux+ Certification Exam simulator. Engage with multiple choice questions and detailed feedback. Master Linux concepts and prepare for your exam with confidence!

To add a user to a specific group in Linux, the command usermod -aG is used. The usermod command is specifically designed to modify an existing user account. The -a (append) option is essential because it ensures that the user is added to the specified group(s) without being removed from any existing groups. The -G option is used to specify the group(s) that the user should be added to.

Using this command correctly maintains the user's membership in all their current groups while adding them to the new group specified. This is crucial in environments where users may have multiple group memberships, and removing them from existing groups could lead to permission issues.

Other options listed serve different purposes. For instance, useradd -g is used to create a new user and assign it to a primary group at the time of user creation, but not for modifying existing users. groupmod -a is incorrect because groupmod is used for modifying existing groups, not for adding users to them. Lastly, groupadd is used for creating a new group, not for managing user memberships within existing groups. This clarifies why usermod -aG is

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy