How to add user to a Group in Linux

Add user to a Group

usermod - modify user account

A user does not belong to a specific group could cause application problem.

To check a user's existing group:
$ id user_name
To add an existing user to a group:
# usermod -aG group-name user-name

For example, to add user ec2-user to docker group:

$ sudo usermod -aG docker ec2-user

You need to logout and login to see the effect.

Be careful not to use

# usermod -g group-name user-name

It will change the user's primary group, instead of just adding to the group.

See also: How to remove user from a group in linux

Featured Post

Updated Coupons / promo codes for Google Apps for Work / Business

To redeem: 1. Sign up for Google Apps   2. Go to your billing settings  3. Choose your payment plan  4. Enter your promo code ...