Previous post:

Next post:

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

by Ramesh

Create a new developer group.

# groupadd developers

Validate that the group was created successfully.

# grep developer /etc/group
developers:x:511:

Add an user to an existing group.

You cannot use useradd to modify an existing user, as you’ll get the following error message.

# useradd -G developers jsmith
useradd: user jsmith exists

# usermod -g developers jsmith

Validate the users group was modified successfully.

# grep jsmith /etc/passwd
jsmith:x:510:511:Oracle Developer:/home/jsmith:/bin/bash

# id jsmith
uid=510(jsmith) gid=511(developers) groups=511(developers)

# grep jsmith /etc/group
jsmith:x:510:
developers:x:511:jsmith
Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Previous post:

Next post:

Leave a Comment

Previous post:

Next post: