Operating System - HP-UX
1752795 Members
6092 Online
108789 Solutions
New Discussion юеВ

Re: adding second secondray group to a user using command

 
SOLVED
Go to solution
Ravi_8
Honored Contributor

adding second secondray group to a user using command

Hi all

We knew that we can change the second secondary group to user(s) using sam. but how to achieve the same using command line.
groupmod changes the existing secondary group to the specified group.
Guys do u aware of any other alternatives.

thanx in advance
never give up
7 REPLIES 7
RAC_1
Honored Contributor

Re: adding second secondray group to a user using command

usermod -G secondary_groups is the one you are lokking for.

check usermod man page for details.
There is no substitute to HARDWORK
Ravi_8
Honored Contributor

Re: adding second secondray group to a user using command

Hi,

I am sorry, instead of usermod i have mentioned as groupmod in my question
never give up
RAC_1
Honored Contributor

Re: adding second secondray group to a user using command

modify /etc/group and adding user to groups.

run grpck afterwards.
There is no substitute to HARDWORK
Armin Feller
Honored Contributor

Re: adding second secondray group to a user using command

Hi,

see man groupadd

Regs
Armin
avsrini
Trusted Contributor

Re: adding second secondray group to a user using command

Hi Ravi,
When using secondary group to a user, it changes the existing secondary group.
But you can use my script to add additional secondary groups

EG=`/usr/bin/groups $1|sed 's/ /.g'`
NG=$EG,$2
/usr/sbin/usermod -G $NG $1


You can pass username and the secondary group name that has to be added.

Hope this helps u.


Srini.


Be on top.
avsrini
Trusted Contributor
Solution

Re: adding second secondray group to a user using command

Hi Ravi,

Sorry my previous post has a error on the sed. use the following.


When using secondary group to a user, it changes the existing secondary group.
But you can use my script to add additional secondary groups

EG=`/usr/bin/groups $1|sed 's/ /,/g'`
NG=$EG,$2
/usr/sbin/usermod -G $NG $1


You can pass username and the secondary group name that has to be added.

Hope this helps u.

Srini.


Be on top.
Ravi_8
Honored Contributor

Re: adding second secondray group to a user using command

Hi, srini

thanx, your script worked
never give up