Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

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
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