Operating System - HP-UX
1826325 Members
3515 Online
109692 Solutions
New Discussion

Re: Automatically add existing user in a new group

 
SOLVED
Go to solution
Sébastien N
Advisor

Automatically add existing user in a new group

Hi,

I want to automatically add exisiting users in a new created group...
The command "groupadd" create the group, but how to include users in it ?

Thanx,
Sebastien.
12 REPLIES 12
justin berkman
Frequent Advisor

Re: Automatically add existing user in a new group

hi guys
for this problem
use the sam application
a addition the users to
the group created
Jean-Louis Phelix
Honored Contributor

Re: Automatically add existing user in a new group

Hi,

Try usermod -G group,group,...

Regards.
It works for me (© Bill McNAMARA ...)
Pete Randall
Outstanding Contributor

Re: Automatically add existing user in a new group

Sebastien,

Perhaps the easiest way would be to edit /etc/group and add each of the users manually.

Pete

Pete
Vicente Sanchez_3
Respected Contributor

Re: Automatically add existing user in a new group

Hi Sebastien,

Can use SAM to assign users to groups or groups to users, as you need.

Regards, Vicente.
MANOJ SRIVASTAVA
Honored Contributor

Re: Automatically add existing user in a new group

Hi Sebastien


The best way is to edit /etc/group . Also you log in as that user and run the command groups to know what groups the user belongs to , ie primary and secondary. In case you jsut want to change hte primary membership edit /etc/passwd , always take a backup of the curretn file before modifying it.


Manoj Srivastava
justin berkman
Frequent Advisor

Re: Automatically add existing user in a new group

hi guys
you can use the command :
-->usermod

but with sam is more easy

if you use the usermod command

insert the option --> " -G"

example :


usermod -G newgroup username


jim bidebo
Regular Advisor

Re: Automatically add existing user in a new group

i guess that you want to add the user to an additional group (without changing the primary group in /etc/passwd).

this is how i would do it:
#usermod -G newgroup username

and if you run nis (which i do)you also have to create and push the nis database to all your nisclients:
#/var/yp/ypmake (or if its located at anotherplace on your installation)
Sébastien N
Advisor

Re: Automatically add existing user in a new group

The usermod command works properly, but I can not add root to this new group :
# usermod -G newgroup root
Login root is currently in use

I am logged as root...

Any idea ?
jim bidebo
Regular Advisor
Solution

Re: Automatically add existing user in a new group

well, its not nessasary to add root to any usergroups since root almost always have full access to the system. but if you want to add root anyways i would use vi (or any editior that you find useable), and then edit /etc/group by hand.

groupname:(password):groupid:list,of,users,separated,by,commas,but,no,comma,at,the,end,root

(password) is hardly ever used, thats why i put it in ().
justin berkman
Frequent Advisor

Re: Automatically add existing user in a new group

hello sebastien


you can edit the /etc/group
file ..

see this example:


##vi /etc/group
root::0:root
other::1:root,hpdb
bin::2:root,bin
sys::3:root,uucp
adm::4:root,adm
daemon::5:root,daemon

in this file insert this
row :

newgroup::6:root

now exit save the change

Pete Randall
Outstanding Contributor

Re: Automatically add existing user in a new group

Sebastien,

Since you said "automatically", I don't think there is a way without some fairly elaborate scripting. Editing the group file and using a cut and paste technique is most likely going to be the quickest and simplest method.

Pete

Pete
Sébastien N
Advisor

Re: Automatically add existing user in a new group

I finaly used the usermod command (without root) to obtain a 0 return code.

Thanx to all !