Hack 71. Create a new group and assign to an user

by Ramesh

Create a new developer group.

  1. # groupadd developers

Validate that the group was created successfully.

  1. # grep developer /etc/group
  2. developers:x:511:

Add an user to an existing group.

useradd -G developers jsmithuseradd: user jsmith exists # usermod -g developers jsmith

Validate the users group was modified successfully.

  1. # grep jsmith /etc/passwd
  2. jsmith:x:510:511:Oracle Developer:/home/jsmith:/bin/bash
  3.  
  4. # id jsmith
  5. uid=510(jsmith) gid=511(developers) groups=511(developers)
  6.  
  7. # grep jsmith /etc/group
  8. jsmith:x:510:
  9. developers:x:511:jsmith