Add new User Group on CentOS 6 terminal

To add a New User and Assign a Group on CentOS 6 terminal

#useradd -g <groupname> username

For instance, lets say you wanted to add a new user named user to the apache group:

#useradd -G apache user

And then you’ll want to assign a password for that user, of course:

passwd user

Add or update User to an an Group

#usermod -a -G <groupname> username

Change a User Primary Group

Sometimes a user has many group, this is switch out the primary group that a user is assigned to with this command:

#usermod -g <groupname> username

View a User Group Assignments by use the id command to see what groups the user is assigned to:

id <username>

This will display output something like this:

uid=500(howtogeek) gid=500(howtogeek) groups=500(howtogeek), 1093(admins)

 

Leave a Reply

Your email address will not be published. Required fields are marked *