How to Add a User to a Group in Linux

In Linux, groups are small subsets of the larger user population who have access to a set of files. Groups can also be used to indicate which users can execute certain commands. A single user must be a member of one primary group, but can also be a member of one or several secondary groups.
The usermod command is used to change or modify the system account of an existing user, including changing a user's primary group and adding the user to secondary groups.

Things You'll Need

  • Linux Root Privileges
Show More

Instructions

  1. Instructions

    • 1

      Open a terminal window.
      The terminal window will be found under Application-> Utilities (GNOME) or Start-> Utilities (KDE).

    • 2

      Switch to root.
      su
      You must have administrator privileges to change or add user groups.

    • 3

      Add the user to the group. The usermod command has the following syntax to add a user to a group:
      usermod -aG group user
      For example, if you wanted to add "mary" to the "Others" group, the command would be:
      usermod -aG Others mary
      You must execute this command for each user you wish to add to the group.

    • 4

      Exit from the root session by typing "exit".

Tips & Warnings

  • The usermod command has two options for adding users to groups. The "-g" option changes the user's primary group. The "-G" option adds users to secondary groups. With the "-G" option, more than one group can be specified by placing a comma (,) between the group names.

  • If you do not specify the "-a" (append) option with "-G", the user will be removed from all secondary groups except the groups listed.

Related Searches:

Comments

You May Also Like

Related Ads

Featured