Manage Groups How to Add Existing Linux User to Group

Adding Existing Linux User to Group

To add an existing Linux user to a specified group, use the usermod command with root privileges.

Steps to Add User to Group

  • Step 1: Access a terminal with sudo or root access.
  • Step 2: Execute the command: usermod -aG groupname username
    • -a: Append to avoid removing existing groups.
    • -G: Specify the group name.
    • groupname: Replace with the target group.
    • username: Replace with the existing user.
  • Step 3: Confirm changes using groups username or id username to display assigned groups.

Important Considerations

Permissions: The command requires root privileges; use sudo if not root. Example: sudo usermod -aG groupname username.

Append Option: Always include -a to preserve current group memberships; omission may revoke other group access.

Manage Groups How to Add Existing Linux User to Group

Login Update: Changes apply after the user logs out and back in.

Verifying Group Membership

Run groups username to list current groups. Verify the output includes the newly added group.

Related News