These commands have been run on Centos 6.5. They should work on RedHat implementations. On other linux versions, behavior can differ.
1. Create a User
useradd command creates a user. New username is written to system files as needed and home directory for user is created. In Centos and other RedHat derivatives, a default group with same name as the user is also created and user is assigned to this group.Creates user "javauser". This also creates a group name "javauser" and assign the user to it. You can see groups of new user by typing "groups javauser".
> useradd javauser
Creates a user and assigns it to a existing group.
> useradd -g devgroup javauser
Creates a user and assigns it to a secondary group. Also a new group with same name as user is created and assigned as primary group.
> useradd -G testgroup javauser
You can specify multiple secondary groups.
> useradd -G testgroup,sysgroup javauser
Creates a user but prevents default behaviour of creating a group with same name. Creating a new group is specific to RedHat derivatives.
> useradd -n javauser
2. Set Password for User
passwd command sets or updates a user's password.Sets or updates password for a user.
> passwd javauserWhen you enter the password and confirm it, password is set.
3. Change Groups of User
To change groups of an existing user, you can use usermod command. A user one primary group and multiple secondary groups.Updates primary group of a user to specifed group. Former primary group is removed from the list of user's groups.
> usermod -g gr1 javausergr1 becomes the primary group of javauser.
Sets specified group(s) as secondary groups of user. Former secondary groups are unassigned if they are not specified in new group list. Groups are passed as a comma seperated list with no spaces between.
> usermod -G gr2,gr3 javauserjavauser now has gr2 and gr3 in its secondary groups.
Appends specified group(s) to the user's groups.
> usermod -a -G gr4 javausergr4 will be added javauser's groups.
4. Delete a User
userdel command deletes the specified user.However, processes started by user, files owned by that user and jobs created by user must be handled seperately and in a planned order.
Deletes javauser
> userdel javauser
Deletes user and its home directory.
> userdel -r javauser
5. Create a Group
groupadd command creates a group.
Creates a group name mygroup
> groupadd mygroup
6. List Groups of a User
groups command list primary and secondary groups of a userPrints groups of javauser
> groups javauser
Prints groups of the effective user (current working user)
> groups
7. Further Reading
You can more in manuals of these commands:http://linux.die.net/man/8/useradd
http://linux.die.net/man/8/groupadd
http://linux.die.net/man/8/userdel
http://linux.die.net/man/8/usermod